diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-02-15 15:58:46 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-02-15 15:58:46 +0000 |
commit | c5b0120ca117dc54fa423077e5640fc89c76e334 (patch) | |
tree | f31e02cebdf7a0f2538be61b2eef4bc4c31995d7 | |
parent | fd937b95ac36e5b91d8c11bbf3d44db1b9dc5a74 (diff) | |
download | mandoc-c5b0120ca117dc54fa423077e5640fc89c76e334.tar.gz |
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@
-rw-r--r-- | compat_fts.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/compat_fts.c b/compat_fts.c index b830b184..7e78e829 100644 --- a/compat_fts.c +++ b/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) |