diff options
author | 2017-02-15 15:58:46 +0000 | |
---|---|---|
committer | 2017-02-15 15:58:46 +0000 | |
commit | 08e529bf9f1013c38e9f15c21bac1c75922a0d3e (patch) | |
tree | 7d291b643d1ab08249c13d4c82824277ca520879 /compat_fts.c | |
parent | f5092a4e085c3ab07292c7c0cc94535aa747b884 (diff) | |
download | mandoc-08e529bf9f1013c38e9f15c21bac1c75922a0d3e.tar.gz mandoc-08e529bf9f1013c38e9f15c21bac1c75922a0d3e.tar.zst mandoc-08e529bf9f1013c38e9f15c21bac1c75922a0d3e.zip |
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@
Diffstat (limited to 'compat_fts.c')
-rw-r--r-- | compat_fts.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/compat_fts.c b/compat_fts.c index c2cc9570..f0a9d4c8 100644 --- a/compat_fts.c +++ b/compat_fts.c @@ -6,7 +6,7 @@ int dummy; #else -/* $Id: compat_fts.c,v 1.12 2016/10/18 23:58:12 schwarze Exp $ */ +/* $Id: compat_fts.c,v 1.13 2017/02/15 15:58:46 schwarze Exp $ */ /* $OpenBSD: fts.c,v 1.56 2016/09/21 04:38:56 guenther Exp $ */ /*- @@ -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) |