some rather mechanical KNF, now that style(9) clarified on the status
of sizeof() as a function-like unary operator; use parenthesēs around sizeof and return args consistently too
This commit is contained in:
82
exec.c
82
exec.c
@ -22,7 +22,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.56 2009/05/16 18:40:05 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.57 2009/06/08 20:06:45 tg Exp $");
|
||||
|
||||
static int comexec(struct op *, struct tbl *volatile, const char **,
|
||||
int volatile, volatile int *);
|
||||
@ -54,7 +54,7 @@ execute(struct op *volatile t,
|
||||
struct tbl *tp = NULL;
|
||||
|
||||
if (t == NULL)
|
||||
return 0;
|
||||
return (0);
|
||||
|
||||
/* Caller doesn't care if XERROK should propagate. */
|
||||
if (xerrok == NULL)
|
||||
@ -62,7 +62,7 @@ execute(struct op *volatile t,
|
||||
|
||||
if ((flags&XFORK) && !(flags&XEXEC) && t->type != TPIPE)
|
||||
/* run in sub-process */
|
||||
return exchild(t, flags & ~XTIME, xerrok, -1);
|
||||
return (exchild(t, flags & ~XTIME, xerrok, -1));
|
||||
|
||||
newenv(E_EXEC);
|
||||
if (trap)
|
||||
@ -98,9 +98,9 @@ execute(struct op *volatile t,
|
||||
flags &= ~XTIME;
|
||||
|
||||
if (t->ioact != NULL || t->type == TPIPE || t->type == TCOPROC) {
|
||||
e->savefd = alloc(NUFILE * sizeof (short), ATEMP);
|
||||
e->savefd = alloc(NUFILE * sizeof(short), ATEMP);
|
||||
/* initialise to not redirected */
|
||||
memset(e->savefd, 0, NUFILE * sizeof (short));
|
||||
memset(e->savefd, 0, NUFILE * sizeof(short));
|
||||
}
|
||||
|
||||
/* do redirection, to be restored in quitenv() */
|
||||
@ -391,7 +391,7 @@ execute(struct op *volatile t,
|
||||
if (Flag(FERREXIT))
|
||||
unwind(LERROR);
|
||||
}
|
||||
return rv;
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -693,7 +693,7 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
|
||||
exstat = rv;
|
||||
unwind(LLEAVE);
|
||||
}
|
||||
return rv;
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -718,20 +718,20 @@ scriptexec(struct op *tp, const char **ap)
|
||||
#ifndef MKSH_SMALL
|
||||
if ((fd = open(tp->str, O_RDONLY)) >= 0) {
|
||||
/* read first MAXINTERP octets from file */
|
||||
if (read(fd, buf, sizeof (buf)) <= 0)
|
||||
if (read(fd, buf, sizeof(buf)) <= 0)
|
||||
/* read error -> no good */
|
||||
buf[0] = '\0';
|
||||
close(fd);
|
||||
/* scan for newline (or CR) or NUL _before_ end of buffer */
|
||||
cp = (unsigned char *)buf;
|
||||
while ((char *)cp < (buf + sizeof (buf)))
|
||||
while ((char *)cp < (buf + sizeof(buf)))
|
||||
if (*cp == '\0' || *cp == '\n' || *cp == '\r') {
|
||||
*cp = '\0';
|
||||
break;
|
||||
} else
|
||||
++cp;
|
||||
/* if the shebang line is longer than MAXINTERP, bail out */
|
||||
if ((char *)cp >= (buf + sizeof (buf)))
|
||||
if ((char *)cp >= (buf + sizeof(buf)))
|
||||
goto noshebang;
|
||||
/* skip UTF-8 Byte Order Mark, if present */
|
||||
cp = (unsigned char *)buf;
|
||||
@ -820,7 +820,7 @@ findfunc(const char *name, unsigned int h, int create)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return tp;
|
||||
return (tp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -864,7 +864,7 @@ define(const char *name, struct op *t)
|
||||
if (t->u.ksh_func)
|
||||
tp->flag |= FKSH;
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -981,7 +981,7 @@ findcom(const char *name, int flags)
|
||||
tp->u.fpath = npath.ro;
|
||||
}
|
||||
}
|
||||
return tp;
|
||||
return (tp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1012,7 +1012,7 @@ search_access(const char *lpath, int mode,
|
||||
struct stat statb;
|
||||
|
||||
if (stat(lpath, &statb) < 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
ret = access(lpath, mode);
|
||||
if (ret < 0)
|
||||
err = errno; /* File exists, but we can't access it */
|
||||
@ -1024,7 +1024,7 @@ search_access(const char *lpath, int mode,
|
||||
}
|
||||
if (err && errnop && !*errnop)
|
||||
*errnop = err;
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1045,7 +1045,7 @@ search(const char *name, const char *lpath,
|
||||
if (vstrchr(name, '/')) {
|
||||
if (search_access(name, mode, errnop) == 0)
|
||||
return (name);
|
||||
return NULL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
namelen = strlen(name) + 1;
|
||||
@ -1066,12 +1066,12 @@ search(const char *name, const char *lpath,
|
||||
XcheckN(xs, xp, namelen);
|
||||
memcpy(xp, name, namelen);
|
||||
if (search_access(Xstring(xs, xp), mode, errnop) == 0)
|
||||
return Xclose(xs, xp + namelen);
|
||||
return (Xclose(xs, xp + namelen));
|
||||
if (*sp++ == '\0')
|
||||
sp = NULL;
|
||||
}
|
||||
Xfree(xs, xp);
|
||||
return NULL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1089,7 +1089,7 @@ call_builtin(struct tbl *tp, const char **wp)
|
||||
shl_stdout_ok = 0;
|
||||
builtin_flag = 0;
|
||||
builtin_argv0 = NULL;
|
||||
return rv;
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1161,10 +1161,10 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
&emsg)) < 0) {
|
||||
warningf(true, "%s: %s",
|
||||
snptreef(NULL, 32, "%R", &iotmp), emsg);
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
if (u == iop->unit)
|
||||
return 0; /* "dup from" == "dup to" */
|
||||
return (0); /* "dup from" == "dup to" */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1172,7 +1172,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
if (do_open) {
|
||||
if (Flag(FRESTRICTED) && (flags & O_CREAT)) {
|
||||
warningf(true, "%s: restricted", cp);
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
u = open(cp, flags, 0666);
|
||||
}
|
||||
@ -1185,7 +1185,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
(iotype == IOREAD || iotype == IOHERE) ?
|
||||
"open" : "create", cp, strerror(u));
|
||||
}
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
/* Do not save if it has already been redirected (i.e. "cat >x >y"). */
|
||||
if (e->savefd[iop->unit] == 0) {
|
||||
@ -1215,7 +1215,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
strerror(ev));
|
||||
if (iotype != IODUP)
|
||||
close(u);
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
if (iotype != IODUP)
|
||||
close(u);
|
||||
@ -1231,7 +1231,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
}
|
||||
if (u == 2) /* Clear any write errors */
|
||||
shf_reopen(2, SHF_WR, shl_out);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1250,7 +1250,7 @@ herein(const char *content, int sub)
|
||||
/* ksh -c 'cat << EOF' can cause this... */
|
||||
if (content == NULL) {
|
||||
warningf(true, "here document missing");
|
||||
return -2; /* special to iosetup(): don't print error */
|
||||
return (-2); /* special to iosetup(): don't print error */
|
||||
}
|
||||
|
||||
/* Create temp file to hold content (done before newenv so temp
|
||||
@ -1264,7 +1264,7 @@ herein(const char *content, int sub)
|
||||
h->name, strerror(fd));
|
||||
if (shf)
|
||||
shf_close(shf);
|
||||
return -2 /* special to iosetup(): don't print error */;
|
||||
return (-2 /* special to iosetup(): don't print error */);
|
||||
}
|
||||
|
||||
osource = source;
|
||||
@ -1274,7 +1274,7 @@ herein(const char *content, int sub)
|
||||
source = osource;
|
||||
quitenv(shf);
|
||||
close(fd);
|
||||
return -2; /* special to iosetup(): don't print error */
|
||||
return (-2); /* special to iosetup(): don't print error */
|
||||
}
|
||||
if (sub) {
|
||||
/* Do substitutions on the content of heredoc */
|
||||
@ -1296,10 +1296,10 @@ herein(const char *content, int sub)
|
||||
fd = errno;
|
||||
warningf(true, "error writing %s: %s, %s", h->name,
|
||||
strerror(i), strerror(fd));
|
||||
return -2; /* special to iosetup(): don't print error */
|
||||
return (-2); /* special to iosetup(): don't print error */
|
||||
}
|
||||
|
||||
return fd;
|
||||
return (fd);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1327,11 +1327,11 @@ do_selectargs(const char **ap, bool print_menu)
|
||||
pr_menu(ap);
|
||||
shellf("%s", str_val(global("PS3")));
|
||||
if (call_builtin(findcom("read", FC_BI), read_args))
|
||||
return NULL;
|
||||
return (NULL);
|
||||
s = str_val(global("REPLY"));
|
||||
if (*s) {
|
||||
getn(s, &i);
|
||||
return (i >= 1 && i <= argct) ? ap[i - 1] : null;
|
||||
return ((i >= 1 && i <= argct) ? ap[i - 1] : null);
|
||||
}
|
||||
print_menu = 1;
|
||||
}
|
||||
@ -1354,7 +1354,7 @@ select_fmt_entry(const void *arg, int i, char *buf, int buflen)
|
||||
|
||||
shf_snprintf(buf, buflen, "%*d) %s",
|
||||
smi->num_width, i + 1, smi->args[i]);
|
||||
return buf;
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1395,7 +1395,7 @@ pr_menu(const char *const *ap)
|
||||
print_columns(shl_out, n, select_fmt_entry, (void *)&smi,
|
||||
dwidth + nwidth + 2, 1);
|
||||
|
||||
return n;
|
||||
return (n);
|
||||
}
|
||||
|
||||
/* XXX: horrible kludge to fit within the framework */
|
||||
@ -1406,7 +1406,7 @@ static char *
|
||||
plain_fmt_entry(const void *arg, int i, char *buf, int buflen)
|
||||
{
|
||||
shf_snprintf(buf, buflen, "%s", ((char *const *)arg)[i]);
|
||||
return buf;
|
||||
return (buf);
|
||||
}
|
||||
|
||||
int
|
||||
@ -1422,7 +1422,7 @@ pr_list(char *const *ap)
|
||||
print_columns(shl_out, n, plain_fmt_entry, (const void *)ap,
|
||||
nwidth + 1, 0);
|
||||
|
||||
return n;
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1441,7 +1441,7 @@ dbteste_isa(Test_env *te, Test_meta meta)
|
||||
const char *p;
|
||||
|
||||
if (!*te->pos.wp)
|
||||
return meta == TM_END;
|
||||
return (meta == TM_END);
|
||||
|
||||
/* unquoted word? */
|
||||
for (p = *te->pos.wp; *p == CHAR; p += 2)
|
||||
@ -1468,7 +1468,7 @@ dbteste_isa(Test_env *te, Test_meta meta)
|
||||
if (ret)
|
||||
te->pos.wp++;
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static const char *
|
||||
@ -1477,19 +1477,19 @@ dbteste_getopnd(Test_env *te, Test_op op, bool do_eval)
|
||||
const char *s = *te->pos.wp;
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
return (NULL);
|
||||
|
||||
te->pos.wp++;
|
||||
|
||||
if (!do_eval)
|
||||
return null;
|
||||
return (null);
|
||||
|
||||
if (op == TO_STEQL || op == TO_STNEQ)
|
||||
s = evalstr(s, DOTILDE | DOPAT);
|
||||
else
|
||||
s = evalstr(s, DOTILDE);
|
||||
|
||||
return s;
|
||||
return (s);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user