[klibc] utils: quick codingstyle cleanups
* nuke trailing spaces, non tab indenting, add missing space
* goto labels aren't indented
* don't assign in if condition
diff --git a/usr/utils/dmesg.c b/usr/utils/dmesg.c
index 877330b..8d2a719 100644
--- a/usr/utils/dmesg.c
+++ b/usr/utils/dmesg.c
@@ -20,7 +20,7 @@
int i = 0;
while ((opt = getopt(argc, argv, "c")) != -1) {
- switch(opt) {
+ switch (opt) {
/* Read and clear all messages remaining in the ring buffer */
case 'c':
cmd = 4;
@@ -53,10 +53,10 @@
while (buf[i] && i < len)
switch (buf[i]) {
case '<':
- if (i == 0 || buf[i-1] == '\n')
+ if (i == 0 || buf[i-1] == '\n')
i++;
case '0' ... '9':
- if (i > 0 && buf[i-1] == '<')
+ if (i > 0 && buf[i-1] == '<')
i++;
case '>':
if (i > 0 && isdigit(buf[i-1]))
diff --git a/usr/utils/halt.c b/usr/utils/halt.c
index a6656b5..eed0a46 100644
--- a/usr/utils/halt.c
+++ b/usr/utils/halt.c
@@ -6,50 +6,53 @@
static __noreturn usage(void)
{
- static char mesg[] = "Usage: {halt|reboot|poweroff} [-n]\n";
- write(2, mesg, sizeof(mesg) - 1);
- exit(1);
+ static char mesg[] = "Usage: {halt|reboot|poweroff} [-n]\n";
+ write(2, mesg, sizeof(mesg) - 1);
+ exit(1);
}
int main(int argc, char *argv[])
{
- int cmd = 0; /* initalize to shut gcc up */
- int do_sync = 1;
- char *ptr, *ptr2;
+ int cmd = 0; /* initalize to shut gcc up */
+ int do_sync = 1;
+ char *ptr, *ptr2;
- /* Which action (program name)? */
- ptr2 = ptr = argv[0];
- while (*ptr2)
- if (*ptr2++ == '/')
- ptr = ptr2;
- if (*ptr == 'r')
- cmd = LINUX_REBOOT_CMD_RESTART;
- else if (*ptr == 'h')
- cmd = LINUX_REBOOT_CMD_HALT;
- else if (*ptr == 'p')
- cmd = LINUX_REBOOT_CMD_POWER_OFF;
- else
- usage();
+ /* Which action (program name)? */
+ ptr2 = ptr = argv[0];
+ while (*ptr2)
+ if (*ptr2++ == '/')
+ ptr = ptr2;
+ if (*ptr == 'r')
+ cmd = LINUX_REBOOT_CMD_RESTART;
+ else if (*ptr == 'h')
+ cmd = LINUX_REBOOT_CMD_HALT;
+ else if (*ptr == 'p')
+ cmd = LINUX_REBOOT_CMD_POWER_OFF;
+ else
+ usage();
- /* Walk options */
- while (*++argv && **argv == '-')
- switch (*++*argv) {
- case 'f': break; /* -f assumed */
- case 'n': do_sync = 0; break;
- default:
- usage();
- }
- if (*argv)
- usage(); /* any args == error */
+ /* Walk options */
+ while (*++argv && **argv == '-')
+ switch (*++*argv) {
+ case 'f':
+ break; /* -f assumed */
+ case 'n':
+ do_sync = 0;
+ break;
+ default:
+ usage();
+ }
+ if (*argv)
+ usage(); /* any args == error */
- if (do_sync)
- sync();
- reboot(LINUX_REBOOT_CMD_CAD_OFF); /* Enable CTRL+ALT+DEL */
- if (!reboot(cmd)) {
- /* Success. Currently, CMD_HALT returns, so stop the world */
- /* kill(-1, SIGSTOP); */
- kill(getpid(), SIGSTOP);
- }
- write(2, "failed.\n", 8);
- return 1;
+ if (do_sync)
+ sync();
+ reboot(LINUX_REBOOT_CMD_CAD_OFF); /* Enable CTRL+ALT+DEL */
+ if (!reboot(cmd)) {
+ /* Success. Currently, CMD_HALT returns, so stop the world */
+ /* kill(-1, SIGSTOP); */
+ kill(getpid(), SIGSTOP);
+ }
+ write(2, "failed.\n", 8);
+ return 1;
}
diff --git a/usr/utils/minips.c b/usr/utils/minips.c
index fabf8b6..2547e28 100644
--- a/usr/utils/minips.c
+++ b/usr/utils/minips.c
@@ -303,8 +303,10 @@
int fd;
char *tmp;
struct stat sb; /* stat() used to get EUID */
+
snprintf(buf, 32, "/proc/%d/stat", pid);
- if ((fd = open(buf, O_RDONLY, 0)) == -1)
+ fd = open(buf, O_RDONLY, 0);
+ if (fd == -1)
return 0;
num = read(fd, buf, sizeof buf - 1);
fstat(fd, &sb);
diff --git a/usr/utils/mount_main.c b/usr/utils/mount_main.c
index 2fea3e3..cf5db69 100644
--- a/usr/utils/mount_main.c
+++ b/usr/utils/mount_main.c
@@ -22,7 +22,7 @@
int error = 0;
while ((s = strsep(&type, ",")) != NULL) {
- retry:
+retry:
if (mount(dev, dir, s, rwflag, data) == -1) {
error = errno;
/*
diff --git a/usr/utils/nuke.c b/usr/utils/nuke.c
index 829bd05..0a282c8 100644
--- a/usr/utils/nuke.c
+++ b/usr/utils/nuke.c
@@ -65,7 +65,8 @@
struct dirent *d;
int err = 0;
- if (!(dir = opendir(what))) {
+ dir = opendir(what);
+ if (!dir) {
/* EACCES means we can't read it. Might be empty and removable;
if not, the rmdir() in nuke() will trigger an error. */
return (errno == EACCES) ? 0 : errno;
diff --git a/usr/utils/sleep.c b/usr/utils/sleep.c
index 5df6aee..62b2238 100644
--- a/usr/utils/sleep.c
+++ b/usr/utils/sleep.c
@@ -19,7 +19,7 @@
return 0;
- err:
+err:
fprintf(stderr, "Usage: %s seconds[.fraction]\n", argv[0]);
return 1;
}
diff --git a/usr/utils/uname.c b/usr/utils/uname.c
index 704e385..6ea4dbe 100644
--- a/usr/utils/uname.c
+++ b/usr/utils/uname.c
@@ -28,7 +28,7 @@
UN_NR_FIELDS
};
-static void usage(FILE * stream, const char *progname)
+static void usage(FILE *stream, const char *progname)
{
fprintf(stream,
"Usage: %s [OPTION] . . .\n"
@@ -53,7 +53,8 @@
{
char *hardware;
- if (!(hardware = strdup(machine))) {
+ hardware = strdup(machine);
+ if (!hardware) {
fprintf(stderr, "strdup() failed: %s\n", strerror(errno));
goto end;
}
@@ -61,7 +62,7 @@
&& hardware[0] == 'i' && hardware[2] == '8' && hardware[3] == '6') {
hardware[1] = '3';
}
- end:
+end:
return hardware;
}
@@ -147,7 +148,7 @@
ec = 0;
- end:
+end:
if (uname_fields[UN_HARDWARE])
free(uname_fields[UN_HARDWARE]);
return ec;