dsdb: Clarify that most errors in make_error_and_update_badPwdCount() are not returned
authorAndrew Bartlett <abartlet@samba.org>
Thu, 31 Mar 2022 23:06:45 +0000 (12:06 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 5 May 2022 00:27:33 +0000 (00:27 +0000)
This is mainly just to be clear, and was done while failing to work around compiler
warnings.

For the curious it was gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (CentOS 7)
build with -O3, which gave with other, later patches:

../../source4/dsdb/samdb/ldb_modules/password_hash.c: In function ‘check_password_restrictions_and_log’:
../../source4/dsdb/samdb/ldb_modules/password_hash.c:3231:5: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
  if (ret == LDB_SUCCESS) {
     ^

Regardless, we make it clear that all values assigned to "ret" are
local small constants.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/password_hash.c

index 6de8c230397fa9e291c1df39a8fd0d2da5037f7f..f9eccd9c10b1a29dc9a53cd5239d9c5ab14ceb8b 100644 (file)
@@ -2609,7 +2609,8 @@ static int make_error_and_update_badPwdCount(struct setup_password_fields_io *io
        struct ldb_message *mod_msg = NULL;
        struct ldb_message *pso_msg = NULL;
        NTSTATUS status;
-       int ret;
+       int ret; /* The errors we will actually return */
+       int dbg_ret; /* The errors we can only complain about in logs */
 
        /* PSO search result is optional (NULL if no PSO applies) */
        if (io->ac->pso_res != NULL) {
@@ -2646,8 +2647,8 @@ static int make_error_and_update_badPwdCount(struct setup_password_fields_io *io
         * Checking errors here is a bit pointless.
         * What can we do if we can't end the transaction?
         */
-       ret = ldb_next_del_trans(io->ac->module);
-       if (ret != LDB_SUCCESS) {
+       dbg_ret = ldb_next_del_trans(io->ac->module);
+       if (dbg_ret != LDB_SUCCESS) {
                ldb_debug(ldb, LDB_DEBUG_FATAL,
                          "Failed to abort transaction prior to update of badPwdCount of %s: %s",
                          ldb_dn_get_linearized(io->ac->search_res->message->dn),
@@ -2659,8 +2660,8 @@ static int make_error_and_update_badPwdCount(struct setup_password_fields_io *io
        }
 
        /* Likewise, what should we do if we can't open a new transaction? */
-       ret = ldb_next_start_trans(io->ac->module);
-       if (ret != LDB_SUCCESS) {
+       dbg_ret = ldb_next_start_trans(io->ac->module);
+       if (dbg_ret != LDB_SUCCESS) {
                ldb_debug(ldb, LDB_DEBUG_ERROR,
                          "Failed to open transaction to update badPwdCount of %s: %s",
                          ldb_dn_get_linearized(io->ac->search_res->message->dn),
@@ -2671,10 +2672,10 @@ static int make_error_and_update_badPwdCount(struct setup_password_fields_io *io
                goto done;
        }
 
-       ret = dsdb_module_modify(io->ac->module, mod_msg,
+       dbg_ret = dsdb_module_modify(io->ac->module, mod_msg,
                                 DSDB_FLAG_NEXT_MODULE,
                                 io->ac->req);
-       if (ret != LDB_SUCCESS) {
+       if (dbg_ret != LDB_SUCCESS) {
                ldb_debug(ldb, LDB_DEBUG_ERROR,
                          "Failed to update badPwdCount of %s: %s",
                          ldb_dn_get_linearized(io->ac->search_res->message->dn),
@@ -2684,8 +2685,8 @@ static int make_error_and_update_badPwdCount(struct setup_password_fields_io *io
                 */
        }
 
-       ret = ldb_next_end_trans(io->ac->module);
-       if (ret != LDB_SUCCESS) {
+       dbg_ret = ldb_next_end_trans(io->ac->module);
+       if (dbg_ret != LDB_SUCCESS) {
                ldb_debug(ldb, LDB_DEBUG_ERROR,
                          "Failed to close transaction to update badPwdCount of %s: %s",
                          ldb_dn_get_linearized(io->ac->search_res->message->dn),
@@ -2695,8 +2696,8 @@ static int make_error_and_update_badPwdCount(struct setup_password_fields_io *io
                 */
        }
 
-       ret = ldb_next_start_trans(io->ac->module);
-       if (ret != LDB_SUCCESS) {
+       dbg_ret = ldb_next_start_trans(io->ac->module);
+       if (dbg_ret != LDB_SUCCESS) {
                ldb_debug(ldb, LDB_DEBUG_ERROR,
                          "Failed to open transaction after update of badPwdCount of %s: %s",
                          ldb_dn_get_linearized(io->ac->search_res->message->dn),