source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Style improvement, no functional change.
@ 2017-02-15 15:59 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-02-15 15:59 UTC (permalink / raw)
  To: source

Log Message:
-----------
Style improvement, no functional change.

As reported by Yuri Pankov, some versions of GCC whine that "tmp"
might be used uninitialized in fts_open(3).  Clearly, that cannot
actually happen, but explicitly setting it to NULL is safer anyway.
While here, rename the badly named variable "tmp" and make the 
inner "if" easier to understand.

Feedback and OK guenther@

Modified Files:
--------------
    mdocml:
        compat_fts.c

Revision Data
-------------
Index: compat_fts.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/compat_fts.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lcompat_fts.c -Lcompat_fts.c -u -p -r1.12 -r1.13
--- compat_fts.c
+++ compat_fts.c
@@ -84,7 +84,7 @@ fts_open(char * const *argv, int options
 	FTS *sp;
 	FTSENT *p, *root;
 	int nitems;
-	FTSENT *parent, *tmp;
+	FTSENT *parent, *prev;
 
 	/* Options check. */
 	if (options & ~FTS_OPTIONMASK) {
@@ -117,7 +117,7 @@ fts_open(char * const *argv, int options
 	parent->fts_level = FTS_ROOTPARENTLEVEL;
 
 	/* Allocate/initialize root(s). */
-	for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) {
+	for (root = prev = NULL, nitems = 0; *argv; ++argv, ++nitems) {
 		if ((p = fts_alloc(sp, *argv, strlen(*argv))) == NULL)
 			goto mem3;
 		p->fts_level = FTS_ROOTLEVEL;
@@ -139,11 +139,10 @@ fts_open(char * const *argv, int options
 		} else {
 			p->fts_link = NULL;
 			if (root == NULL)
-				tmp = root = p;
-			else {
-				tmp->fts_link = p;
-				tmp = p;
-			}
+				root = p;
+			else
+				prev->fts_link = p;
+			prev = p;
 		}
 	}
 	if (compar && nitems > 1)
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-15 15:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 15:59 mdocml: Style improvement, no functional change schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).