svn commit: samba r23584 - in branches: SAMBA_3_0/source/registry SAMBA_3_0_26/source/registry

obnox at samba.org obnox at samba.org
Fri Jun 22 11:42:17 GMT 2007


Author: obnox
Date: 2007-06-22 11:42:17 +0000 (Fri, 22 Jun 2007)
New Revision: 23584

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23584

Log:
Use a while loop instead of a for loop without increment... :-)

Michael


Modified:
   branches/SAMBA_3_0/source/registry/reg_api.c
   branches/SAMBA_3_0_26/source/registry/reg_api.c


Changeset:
Modified: branches/SAMBA_3_0/source/registry/reg_api.c
===================================================================
--- branches/SAMBA_3_0/source/registry/reg_api.c	2007-06-22 11:21:59 UTC (rev 23583)
+++ branches/SAMBA_3_0/source/registry/reg_api.c	2007-06-22 11:42:17 UTC (rev 23584)
@@ -691,7 +691,6 @@
 	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 @@
 		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)) {

Modified: branches/SAMBA_3_0_26/source/registry/reg_api.c
===================================================================
--- branches/SAMBA_3_0_26/source/registry/reg_api.c	2007-06-22 11:21:59 UTC (rev 23583)
+++ branches/SAMBA_3_0_26/source/registry/reg_api.c	2007-06-22 11:42:17 UTC (rev 23584)
@@ -691,7 +691,6 @@
 	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 @@
 		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)) {



More information about the samba-cvs mailing list