Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Jul 2005 16:32:42 GMT
From:      "Christian S.J. Peron" <csjp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 79565 for review
Message-ID:  <200507041632.j64GWg5g090952@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=79565

Change 79565 by csjp@csjp_xor on 2005/07/04 16:32:16

	-Implement strsep loop optimization to prevent a second
	 walk of the dependency list.
	-Remove un-used variables

Affected files ...

.. //depot/projects/trustedbsd/mac/usr.sbin/getfhash/getfhash.c#11 edit

Differences ...

==== //depot/projects/trustedbsd/mac/usr.sbin/getfhash/getfhash.c#11 (text+ko) ====

@@ -142,8 +142,8 @@
 static void
 process_depends(const char *pathname)
 {
-	char **av, *depends[10], *dependlist;
-	int ndeps, error, i, j;
+	char *av, *dependlist;
+	int error, j;
 	ssize_t nbytes;
 
 	nbytes = extattr_get_file(pathname, MAC_CHKEXEC_ATTRN,
@@ -162,17 +162,14 @@
 	error = extattr_get_file(pathname, MAC_CHKEXEC_ATTRN,
 	    MAC_CHKEXEC_DEP, dependlist, nbytes);
 	dependlist[nbytes] = '\0';
-	for (ndeps = 0, av = depends;
-	    (*av = strsep(&dependlist, ":")) != NULL; ndeps++)
-		if (**av != '\0')
-			if (++av > &depends[10])
-				break;
 	depth++;
-	for (i = 0; i < ndeps; i++) {
+	for (; (av = strsep(&dependlist, ":")) != NULL;) {
+		if (strlen(av) == 0)
+			continue;
 		for (j = 0; j < depth; j++)
 			fputs("    ", stdout);
-		print_hash(depends[i]);
-	}
+		print_hash(av);
+        }
 	depth--;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507041632.j64GWg5g090952>