From: Michael Adam Date: Fri, 22 Jun 2007 11:42:17 +0000 (+0000) Subject: r23584: Use a while loop instead of a for loop without increment... :-) X-Git-Tag: samba-misc-tags/initial-v3-0-unstable~135 X-Git-Url: http://git.samba.org/samba.git/?p=sfrench%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=fb4ade3b4d203eead7798b8d98938cff2abb9c29 r23584: Use a while loop instead of a for loop without increment... :-) Michael --- diff --git a/source/registry/reg_api.c b/source/registry/reg_api.c index e2bb56deea0..9147becf9b7 100644 --- a/source/registry/reg_api.c +++ b/source/registry/reg_api.c @@ -691,7 +691,6 @@ WERROR reg_deletekey_recursive(TALLOC_CTX *ctx, TALLOC_CTX *mem_ctx = NULL; WERROR werr = WERR_OK; struct registry_key *key; - uint32 idx = 0; char *subkey_name = NULL; mem_ctx = talloc_new(ctx); @@ -706,14 +705,8 @@ WERROR reg_deletekey_recursive(TALLOC_CTX *ctx, goto done; } - /* NOTE: we *must not* increment idx in this loop since - * the list of subkeys shrinks with each loop body. - * so this way, we repeatedly delete the *first* entry - * of a shrinking list. */ - for (idx = 0; - W_ERROR_IS_OK(werr = reg_enumkey(mem_ctx, key, idx, - &subkey_name, NULL)); - ) + while (W_ERROR_IS_OK(werr = reg_enumkey(mem_ctx, key, 0, + &subkey_name, NULL))) { werr = reg_deletekey_recursive(mem_ctx, key, subkey_name); if (!W_ERROR_IS_OK(werr)) {