diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-12-27 18:04:05 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-12-27 18:04:05 +0000 |
commit | 384aedab5807fb0ed022a80b92ac70a9cd18339f (patch) | |
tree | 460140e6f2859387224bc3cf5cc7148cf75b3745 /bin/sh/exec.c | |
parent | 5cb5104246dbcf696aa8647fded889f97728780f (diff) | |
download | src-384aedab5807fb0ed022a80b92ac70a9cd18339f.tar.gz src-384aedab5807fb0ed022a80b92ac70a9cd18339f.zip |
sh: Various warning fixes (from WARNS=6 NO_WERROR=1):
- const
- initializations to silence -Wuninitialized (it was safe anyway)
- remove nested extern declarations
- rename "index" locals to "idx"
Notes
Notes:
svn path=/head/; revision=201053
Diffstat (limited to 'bin/sh/exec.c')
-rw-r--r-- | bin/sh/exec.c | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c index f7096d8fffbd..2bdbab803c1b 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -109,7 +109,7 @@ STATIC void delete_cmd_entry(void); */ void -shellexec(char **argv, char **envp, const char *path, int index) +shellexec(char **argv, char **envp, const char *path, int idx) { char *cmdname; int e; @@ -120,7 +120,7 @@ shellexec(char **argv, char **envp, const char *path, int index) } else { e = ENOENT; while ((cmdname = padvance(&path, argv[0])) != NULL) { - if (--index < 0 && pathopt == NULL) { + if (--idx < 0 && pathopt == NULL) { tryexec(cmdname, argv, envp); if (errno != ENOENT && errno != ENOTDIR) e = errno; @@ -268,17 +268,17 @@ hashcmd(int argc __unused, char **argv __unused) STATIC void printentry(struct tblentry *cmdp, int verbose) { - int index; + int idx; const char *path; char *name; if (cmdp->cmdtype == CMDNORMAL) { - index = cmdp->param.index; + idx = cmdp->param.index; path = pathval(); do { name = padvance(&path, cmdp->cmdname); stunalloc(name); - } while (--index >= 0); + } while (--idx >= 0); out1str(name); } else if (cmdp->cmdtype == CMDBUILTIN) { out1fmt("builtin %s", cmdp->cmdname); @@ -314,7 +314,7 @@ find_command(const char *name, struct cmdentry *entry, int printerr, const char *path) { struct tblentry *cmdp; - int index; + int idx; int prev; char *fullname; struct stat statb; @@ -354,11 +354,11 @@ find_command(const char *name, struct cmdentry *entry, int printerr, } e = ENOENT; - index = -1; + idx = -1; loop: while ((fullname = padvance(&path, name)) != NULL) { stunalloc(fullname); - index++; + idx++; if (pathopt) { if (prefix("builtin", pathopt)) { if ((i = find_builtin(name, &spec)) < 0) @@ -377,8 +377,8 @@ loop: } } /* if rehash, don't redo absolute path names */ - if (fullname[0] == '/' && index <= prev) { - if (index < prev) + if (fullname[0] == '/' && idx <= prev) { + if (idx < prev) goto loop; TRACE(("searchexec \"%s\": no change\n", name)); goto success; @@ -415,7 +415,7 @@ loop: INTOFF; cmdp = cmdlookup(name, 1); cmdp->cmdtype = CMDNORMAL; - cmdp->param.index = index; + cmdp->param.index = idx; INTON; goto success; } @@ -494,18 +494,18 @@ void changepath(const char *newval) { const char *old, *new; - int index; + int idx; int firstchange; int bltin; old = pathval(); new = newval; firstchange = 9999; /* assume no change */ - index = 0; + idx = 0; bltin = -1; for (;;) { if (*old != *new) { - firstchange = index; + firstchange = idx; if ((*old == '\0' && *new == ':') || (*old == ':' && *new == '\0')) firstchange++; @@ -514,9 +514,9 @@ changepath(const char *newval) if (*new == '\0') break; if (*new == '%' && bltin < 0 && prefix("builtin", new + 1)) - bltin = index; + bltin = idx; if (*new == ':') { - index++; + idx++; } new++, old++; } @@ -724,15 +724,14 @@ typecmd_impl(int argc, char **argv, int cmd) { struct cmdentry entry; struct tblentry *cmdp; - char **pp; + const char *const *pp; struct alias *ap; int i; - int error = 0; - extern char *const parsekwd[]; + int error1 = 0; for (i = 1; i < argc; i++) { /* First look at the keywords */ - for (pp = (char **)parsekwd; *pp; pp++) + for (pp = parsekwd; *pp; pp++) if (**pp == *argv[i] && equal(*pp, argv[i])) break; @@ -793,7 +792,7 @@ typecmd_impl(int argc, char **argv, int cmd) if (cmd != TYPECMD_SMALLV) outfmt(out2, "%s: %s\n", argv[i], strerror(errno)); - error |= 127; + error1 |= 127; } } break; @@ -818,11 +817,11 @@ typecmd_impl(int argc, char **argv, int cmd) default: if (cmd != TYPECMD_SMALLV) outfmt(out2, "%s: not found\n", argv[i]); - error |= 127; + error1 |= 127; break; } } - return error; + return error1; } /* |