commit 291aedb87546fb565962a08aa94fbfc94ccd83f3
parent c50f7a3a27d879867bc6d442f878616895da68c2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Wed, 9 Jul 2014 15:39:32 +0000
code consistency fixes
Diffstat:
17 files changed, 58 insertions(+), 57 deletions(-)
diff --git a/id.c b/id.c
@@ -85,7 +85,7 @@ usernam(const char *nam)
errno = 0;
pw = getpwnam(nam);
- if(!pw) {
+ if (!pw) {
if (errno)
eprintf("getpwnam %s:", nam);
else
@@ -104,7 +104,7 @@ userid(uid_t id)
errno = 0;
pw = getpwuid(id);
- if(!pw) {
+ if (!pw) {
if (errno)
eprintf("getpwuid %d:", id);
else
diff --git a/insmod.c b/insmod.c
@@ -42,7 +42,7 @@ main(int argc, char *argv[])
buf = emalloc(blen);
n = read(fd, buf, blen);
- if(n < 0 || (size_t)n != blen)
+ if (n < 0 || (size_t)n != blen)
eprintf("read:");
argc--;
diff --git a/killall5.c b/killall5.c
@@ -52,15 +52,15 @@ main(int argc, char *argv[])
case 's':
v = EARGF(usage());
sig = strtol(v, &end, 0);
- if(*end == '\0')
+ if (*end == '\0')
break;
- for(i = 0; i < LEN(sigs); i++) {
- if(strcasecmp(v, sigs[i].name) == 0) {
+ for (i = 0; i < LEN(sigs); i++) {
+ if (strcasecmp(v, sigs[i].name) == 0) {
sig = sigs[i].sig;
break;
}
}
- if(i == LEN(sigs))
+ if (i == LEN(sigs))
eprintf("%s: unknown signal\n", v);
break;
case 'o':
diff --git a/login.c b/login.c
@@ -26,7 +26,8 @@ usage(void)
/* Write utmp entry */
static void
-writeutmp(const char *user, const char *tty) {
+writeutmp(const char *user, const char *tty)
+{
struct utmp usr;
FILE *fp;
diff --git a/mknod.c b/mknod.c
@@ -30,16 +30,16 @@ main(int argc, char *argv[])
usage();
} ARGEND;
- if(argc != 4)
+ if (argc != 4)
usage();
- if(strlen(argv[1]) != 1 || !strchr("ucb", argv[1][0]))
+ if (strlen(argv[1]) != 1 || !strchr("ucb", argv[1][0]))
eprintf("mknod: '%s': invalid type\n", argv[1]);
type = (argv[1][0] == 'b') ? S_IFBLK : S_IFCHR;
dev = makedev(estrtol(argv[2], 0), estrtol(argv[3], 0));
- if(mknod(argv[0], type|mode, dev) == -1)
+ if (mknod(argv[0], type|mode, dev) == -1)
eprintf("mknod: '%s':", argv[0]);
return EXIT_SUCCESS;
}
diff --git a/mount.c b/mount.c
@@ -41,26 +41,26 @@ parseopts(char *popts, unsigned long *flags, char *data, size_t datasiz)
char *name;
data[0] = '\0';
- for(name = strtok(popts, ","); name; name = strtok(NULL, ",")) {
+ for (name = strtok(popts, ","); name; name = strtok(NULL, ",")) {
validopt = 0;
- for(i = 0; optnames[i].opt; i++) {
- if(optnames[i].opt && strcmp(name, optnames[i].opt) == 0) {
+ for (i = 0; optnames[i].opt; i++) {
+ if (optnames[i].opt && strcmp(name, optnames[i].opt) == 0) {
*flags |= optnames[i].v;
validopt = 1;
break;
}
- if(optnames[i].notopt && strcmp(name, optnames[i].notopt) == 0) {
+ if (optnames[i].notopt && strcmp(name, optnames[i].notopt) == 0) {
*flags &= ~optnames[i].v;
validopt = 1;
break;
}
}
- if(!validopt) {
+ if (!validopt) {
/* unknown option, pass as data option to mount() */
- if((optlen = strlen(name))) {
- if(dlen + optlen + 2 >= datasiz)
+ if ((optlen = strlen(name))) {
+ if (dlen + optlen + 2 >= datasiz)
return; /* prevent overflow */
- if(dlen)
+ if (dlen)
data[dlen++] = ',';
memcpy(&data[dlen], name, optlen);
dlen += optlen;
@@ -110,9 +110,9 @@ catfile(FILE *in, FILE *out)
char buf[BUFSIZ];
size_t bytesread;
- while(!feof(in)) {
+ while (!feof(in)) {
bytesread = fread(buf, 1, sizeof(buf), in);
- if(ferror(in))
+ if (ferror(in))
return 0;
fwrite(buf, 1, bytesread, out);
}
@@ -157,10 +157,10 @@ main(int argc, char *argv[])
usage();
} ARGEND;
- if(argc < 1 && aflag == 0) {
- if(!(fp = fopen(files[0], "r")))
+ if (argc < 1 && aflag == 0) {
+ if (!(fp = fopen(files[0], "r")))
eprintf("fopen %s:", files[0]);
- if(catfile(fp, stdout) != 1) {
+ if (catfile(fp, stdout) != 1) {
weprintf("error while reading %s:", files[0]);
status = EXIT_FAILURE;
}
@@ -168,38 +168,38 @@ main(int argc, char *argv[])
return status;
}
- if(aflag == 1)
+ if (aflag == 1)
goto mountall;
source = argv[0];
target = argv[1];
- if(!target) {
+ if (!target) {
target = argv[0];
source = NULL;
- if(!(resolvpath = realpath(target, NULL)))
+ if (!(resolvpath = realpath(target, NULL)))
eprintf("realpath %s:", target);
target = resolvpath;
}
- for(i = 0; files[i]; i++) {
- if(!(fp = setmntent(files[i], "r"))) {
+ for (i = 0; files[i]; i++) {
+ if (!(fp = setmntent(files[i], "r"))) {
if (strcmp(files[i], "/proc/mounts") != 0)
weprintf("setmntent %s:", files[i]);
continue;
}
- while((me = getmntent(fp))) {
- if(strcmp(me->mnt_dir, target) == 0 ||
+ while ((me = getmntent(fp))) {
+ if (strcmp(me->mnt_dir, target) == 0 ||
strcmp(me->mnt_fsname, target) == 0 ||
(source && strcmp(me->mnt_dir, source) == 0) ||
(source && strcmp(me->mnt_fsname, source) == 0)) {
- if(!source) {
+ if (!source) {
target = me->mnt_dir;
source = me->mnt_fsname;
}
- if(!oflag)
+ if (!oflag)
parseopts(me->mnt_opts, &flags, data, datasiz);
- if(!types)
+ if (!types)
types = me->mnt_type;
goto mountsingle;
}
@@ -207,27 +207,27 @@ main(int argc, char *argv[])
endmntent(fp);
fp = NULL;
}
- if(!source)
+ if (!source)
eprintf("can't find %s in /etc/fstab\n", target);
mountsingle:
- if(mount(source, target, types, flags, data) < 0) {
+ if (mount(source, target, types, flags, data) < 0) {
weprintf("mount: %s:", source);
status = EXIT_FAILURE;
}
- if(fp)
+ if (fp)
endmntent(fp);
free(resolvpath);
return status;
mountall:
- if(!(fp = setmntent("/etc/fstab", "r")))
+ if (!(fp = setmntent("/etc/fstab", "r")))
eprintf("setmntent %s:", "/etc/fstab");
- while((me = getmntent(fp))) {
+ while ((me = getmntent(fp))) {
flags = 0;
parseopts(me->mnt_opts, &flags, data, datasiz);
- if(mount(me->mnt_fsname, me->mnt_dir, me->mnt_type, flags, data) < 0) {
- if(mounted(me->mnt_dir) == 0) {
+ if (mount(me->mnt_fsname, me->mnt_dir, me->mnt_type, flags, data) < 0) {
+ if (mounted(me->mnt_dir) == 0) {
weprintf("mount: %s:", me->mnt_fsname);
status = EXIT_FAILURE;
}
diff --git a/respawn.c b/respawn.c
@@ -52,7 +52,7 @@ main(int argc, char *argv[])
usage();
} ARGEND;
- if(argc < 1)
+ if (argc < 1)
usage();
if (fifo && delay > 0)
diff --git a/su.c b/su.c
@@ -55,7 +55,7 @@ main(int argc, char *argv[])
errno = 0;
pw = getpwnam(usr);
- if(!pw) {
+ if (!pw) {
if (errno)
eprintf("getpwnam: %s:", usr);
else
diff --git a/switch_root.c b/switch_root.c
@@ -118,7 +118,7 @@ main(int argc, char *argv[])
/* if -c is set, redirect stdin/stdout/stderr to console */
if (console) {
close(STDIN_FILENO);
- if(open(console, O_RDWR) == -1)
+ if (open(console, O_RDWR) == -1)
eprintf("open %s:", console);
if (dup2(STDIN_FILENO, STDOUT_FILENO) != STDOUT_FILENO)
eprintf("dup2 %s:", "stdin,stdout");
diff --git a/util/agetcwd.c b/util/agetcwd.c
@@ -10,7 +10,7 @@ agetcwd(void)
long size;
apathmax(&buf, &size);
- if(!getcwd(buf, size))
+ if (!getcwd(buf, size))
eprintf("getcwd:");
return buf;
diff --git a/util/apathmax.c b/util/apathmax.c
@@ -11,8 +11,8 @@ apathmax(char **p, long *size)
{
errno = 0;
- if((*size = pathconf("/", _PC_PATH_MAX)) == -1) {
- if(errno == 0) {
+ if ((*size = pathconf("/", _PC_PATH_MAX)) == -1) {
+ if (errno == 0) {
*size = BUFSIZ;
} else {
eprintf("pathconf:");
diff --git a/util/eprintf.c b/util/eprintf.c
@@ -39,7 +39,7 @@ venprintf(int status, const char *fmt, va_list ap)
vfprintf(stderr, fmt, ap);
- if(fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
fputc(' ', stderr);
perror(NULL);
}
diff --git a/util/estrtol.c b/util/estrtol.c
@@ -13,13 +13,13 @@ estrtol(const char *s, int base)
errno = 0;
n = strtol(s, &end, base);
- if(*end != '\0') {
- if(base == 0)
+ if (*end != '\0') {
+ if (base == 0)
eprintf("%s: not an integer\n", s);
else
eprintf("%s: not a base %d integer\n", s, base);
}
- if(errno != 0)
+ if (errno != 0)
eprintf("%s:", s);
return n;
diff --git a/util/estrtoul.c b/util/estrtoul.c
@@ -13,13 +13,13 @@ estrtoul(const char *s, int base)
errno = 0;
n = strtoul(s, &end, base);
- if(*end != '\0') {
- if(base == 0)
+ if (*end != '\0') {
+ if (base == 0)
eprintf("%s: not an integer\n", s);
else
eprintf("%s: not a base %d integer\n", s, base);
}
- if(errno != 0)
+ if (errno != 0)
eprintf("%s:", s);
return n;
diff --git a/util/proc.c b/util/proc.c
@@ -59,7 +59,7 @@ parsestat(pid_t pid, struct procstat *ps)
&ps->num_threads, &ps->itrealvalue, &ps->starttime,
&ps->vsize, &ps->rss, &ps->rsslim);
/* Filter out '(' and ')' from comm */
- if((len = strlen(ps->comm)) > 0)
+ if ((len = strlen(ps->comm)) > 0)
len--;
ps->comm[len] = '\0';
memmove(ps->comm, ps->comm + 1, len);
diff --git a/util/putword.c b/util/putword.c
@@ -9,7 +9,7 @@ putword(const char *s)
{
static bool first = true;
- if(!first)
+ if (!first)
putchar(' ');
fputs(s, stdout);
diff --git a/who.c b/who.c
@@ -47,7 +47,7 @@ main(int argc, char *argv[])
if (!(ufp = fopen(UTMP_PATH, "r")))
eprintf("fopen: %s:", UTMP_PATH);
- while(fread(&usr, sizeof(usr), 1, ufp) == 1) {
+ while (fread(&usr, sizeof(usr), 1, ufp) == 1) {
if (!*usr.ut_name || !*usr.ut_line ||
usr.ut_line[0] == '~')
continue;