[SSSD] [PATCH 0/1] Simplify writing update functions

Simo Sorce simo at redhat.com
Mon Nov 19 13:41:25 UTC 2012


On Mon, 2012-11-19 at 12:37 +0100, Sumit Bose wrote:
> On Wed, Nov 14, 2012 at 09:17:53AM -0500, Simo Sorce wrote:
> > While approaching the problem of updating the DB after a patch I am working
> > on I noticed that we do have a lot of biolerplate code in there that could
> > very simply be tucked into 2 helper functions, simplifying writing upgrade
> > functions and making it less likely a typo or copy&paste error will create
> > issues with version numbers.
> > 
> > I love the 425 deletions :-)
> > 
> > I tried to have a light hand in changing existing code to avoid introducing
> > bugs but I have added an example skeleton so that future upgrade functions
> > can stop using a tmp_ctx memory context and just use the new upgrade_ctx as
> > their local memory context.
> > 
> > Simo Sorce (1):
> >   Simplify writing db update functions
> > 
> >  src/db/sysdb_upgrade.c |  621 +++++++++++++++---------------------------------
> >  1 files changed, 196 insertions(+), 425 deletions(-)
> 
> ACK. Nevertheless I think you do not need 'struct upgrade_ctx **ctx' for
> finish_upgrade(), 'struct upgrade_ctx *ctx' should be sufficient. The
> attached patch adds the needed changes.

The code takes **ctx so that when you return from the function *ctx is
NULL (as it has been freed). Defensive programming, I do not think the
change you propose adds anything, it just removes a safety feature.

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York




More information about the sssd-devel mailing list