From 6ec437ccb5f96871589180d976e9ff44a764b11d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 20 Mar 2014 11:23:05 +0100 Subject: [PATCH] autorid: reverse logic flow in idmap_autorid_init_hwm(), decreasing indentation. I.e. move writing case to the end. Signed-off-by: Michael Adam Reviewed-by: Jeremy Allison --- source3/winbindd/idmap_autorid_tdb.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source3/winbindd/idmap_autorid_tdb.c b/source3/winbindd/idmap_autorid_tdb.c index 190999eb796..c347662e013 100644 --- a/source3/winbindd/idmap_autorid_tdb.c +++ b/source3/winbindd/idmap_autorid_tdb.c @@ -395,20 +395,24 @@ NTSTATUS idmap_autorid_init_hwm(struct db_context *db, const char *hwm) uint32_t hwmval; status = dbwrap_fetch_uint32_bystring(db, hwm, &hwmval); - if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { - status = dbwrap_trans_store_uint32_bystring(db, hwm, 0); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, - ("Unable to initialise HWM (%s) in autorid " - "database: %s\n", hwm, nt_errstr(status))); - return NT_STATUS_INTERNAL_DB_ERROR; - } - } else if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_IS_OK(status)) { + DEBUG(1, ("HWM (%s) already initialized in autorid database " + "(value %"PRIu32").\n", hwm, hwmval)); + return NT_STATUS_OK; + } + if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { DEBUG(0, ("unable to fetch HWM (%s) from autorid " "database: %s\n", hwm, nt_errstr(status))); return status; } + status = dbwrap_trans_store_uint32_bystring(db, hwm, 0); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Error initializing HWM (%s) in autorid database: " + "%s\n", hwm, nt_errstr(status))); + return NT_STATUS_INTERNAL_DB_ERROR; + } + return NT_STATUS_OK; }