aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-04-12 00:32:05 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-04-12 00:32:05 +0000
commite91ac05530803390f7aa5ca646d90ae26c48aa52 (patch)
tree7a912fc65ff43bdb09078d75bfc02ad8f5380b47
parent13adb67bb086c45d7191966ca5fa3bff1de2dd74 (diff)
downloadbusybox-w32-e91ac05530803390f7aa5ca646d90ae26c48aa52.tar.gz
busybox-w32-e91ac05530803390f7aa5ca646d90ae26c48aa52.tar.bz2
busybox-w32-e91ac05530803390f7aa5ca646d90ae26c48aa52.zip
style fixes. No code changes
git-svn-id: svn://busybox.net/trunk/busybox@18409 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--applets/applets.c2
-rw-r--r--archival/bbunzip.c2
-rw-r--r--archival/gzip.c2
-rw-r--r--archival/tar.c2
-rw-r--r--coreutils/rm.c6
-rw-r--r--debianutils/start_stop_daemon.c2
-rw-r--r--editors/awk.c3
-rw-r--r--editors/patch.c4
-rw-r--r--editors/vi.c2
-rw-r--r--findutils/xargs.c2
-rw-r--r--init/init.c2
-rw-r--r--libbb/copy_file.c2
-rw-r--r--libbb/get_console.c10
-rw-r--r--libbb/get_line_from_file.c9
-rw-r--r--libbb/login.c2
-rw-r--r--libbb/trim.c8
-rw-r--r--miscutils/makedevs.c2
-rw-r--r--modutils/insmod.c8
-rw-r--r--modutils/rmmod.c6
-rw-r--r--networking/nc_bloaty.c8
-rw-r--r--networking/nslookup.c2
-rw-r--r--networking/route.c4
-rw-r--r--procps/sysctl.c8
-rw-r--r--procps/uptime.c2
-rw-r--r--scripts/basic/docproc.c4
-rw-r--r--selinux/matchpathcon.c2
-rw-r--r--shell/bbsh.c12
-rw-r--r--shell/msh.c24
-rw-r--r--util-linux/mount.c2
-rw-r--r--util-linux/switch_root.c22
30 files changed, 84 insertions, 82 deletions
diff --git a/applets/applets.c b/applets/applets.c
index 958defe75..bbb545a84 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -124,7 +124,7 @@ static const unsigned short mode_mask[] = {
124 0, S_IXOTH, S_IXOTH, 0 /* other */ 124 0, S_IXOTH, S_IXOTH, 0 /* other */
125}; 125};
126 126
127#define parse_error(x) do { errmsg = x; goto pe_label; } while(0) 127#define parse_error(x) do { errmsg = x; goto pe_label; } while (0)
128 128
129static void parse_config_file(void) 129static void parse_config_file(void)
130{ 130{
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 4dba498b8..00cece4ad 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -217,7 +217,7 @@ char* make_new_name_gunzip(char *filename)
217#endif 217#endif
218 ) { 218 ) {
219 extension[-1] = '\0'; 219 extension[-1] = '\0';
220 } else if(strcmp(extension, "tgz") == 0) { 220 } else if (strcmp(extension, "tgz") == 0) {
221 filename = xstrdup(filename); 221 filename = xstrdup(filename);
222 extension = strrchr(filename, '.'); 222 extension = strrchr(filename, '.');
223 extension[2] = 'a'; 223 extension[2] = 'a';
diff --git a/archival/gzip.c b/archival/gzip.c
index 561f1088c..03b6b9117 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -47,7 +47,7 @@ aa: 85.1% -- replaced with aa.gz
47//#define DEBUG 1 47//#define DEBUG 1
48/* Diagnostic functions */ 48/* Diagnostic functions */
49#ifdef DEBUG 49#ifdef DEBUG
50# define Assert(cond,msg) {if(!(cond)) bb_error_msg(msg);} 50# define Assert(cond,msg) { if (!(cond)) bb_error_msg(msg); }
51# define Trace(x) fprintf x 51# define Trace(x) fprintf x
52# define Tracev(x) {if (verbose) fprintf x ;} 52# define Tracev(x) {if (verbose) fprintf x ;}
53# define Tracevv(x) {if (verbose > 1) fprintf x ;} 53# define Tracevv(x) {if (verbose > 1) fprintf x ;}
diff --git a/archival/tar.c b/archival/tar.c
index 11a74dfe9..79979b05f 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -676,7 +676,7 @@ static void handle_SIGCHLD(int status)
676 /* child exited with 0 */ 676 /* child exited with 0 */
677 return; 677 return;
678 /* Cannot happen? 678 /* Cannot happen?
679 if(!WIFSIGNALED(status) && !WIFEXITED(status)) return; */ 679 if (!WIFSIGNALED(status) && !WIFEXITED(status)) return; */
680 child_error = 1; 680 child_error = 1;
681} 681}
682#endif 682#endif
diff --git a/coreutils/rm.c b/coreutils/rm.c
index 6f32e7dc5..61e3e7010 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -29,11 +29,11 @@ int rm_main(int argc, char **argv)
29 opt_complementary = "f-i:i-f"; 29 opt_complementary = "f-i:i-f";
30 opt = getopt32(argc, argv, "fiRr"); 30 opt = getopt32(argc, argv, "fiRr");
31 argv += optind; 31 argv += optind;
32 if(opt & 1) 32 if (opt & 1)
33 flags |= FILEUTILS_FORCE; 33 flags |= FILEUTILS_FORCE;
34 if(opt & 2) 34 if (opt & 2)
35 flags |= FILEUTILS_INTERACTIVE; 35 flags |= FILEUTILS_INTERACTIVE;
36 if(opt & 12) 36 if (opt & 12)
37 flags |= FILEUTILS_RECUR; 37 flags |= FILEUTILS_RECUR;
38 38
39 if (*argv != NULL) { 39 if (*argv != NULL) {
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 60a78793e..1154794fd 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -183,7 +183,7 @@ static int do_stop(void)
183 if (!quiet && killed) { 183 if (!quiet && killed) {
184 printf("stopped %s (pid", what); 184 printf("stopped %s (pid", what);
185 for (p = found; p; p = p->next) 185 for (p = found; p; p = p->next)
186 if(p->pid < 0) 186 if (p->pid < 0)
187 printf(" %d", -p->pid); 187 printf(" %d", -p->pid);
188 puts(")"); 188 puts(")");
189 } 189 }
diff --git a/editors/awk.c b/editors/awk.c
index 1bdb9b924..5a504d034 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2145,7 +2145,8 @@ static var *evaluate(node *op, var *res)
2145 X.rsm = newfile(R.s); 2145 X.rsm = newfile(R.s);
2146 if (! X.rsm->F) { 2146 if (! X.rsm->F) {
2147 if (opn == '|') { 2147 if (opn == '|') {
2148 if((X.rsm->F = popen(R.s, "w")) == NULL) 2148 X.rsm->F = popen(R.s, "w");
2149 if (X.rsm->F == NULL)
2149 bb_perror_msg_and_die("popen"); 2150 bb_perror_msg_and_die("popen");
2150 X.rsm->is_pipe = 1; 2151 X.rsm->is_pipe = 1;
2151 } else { 2152 } else {
diff --git a/editors/patch.c b/editors/patch.c
index 4d1425edc..11b2f2587 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -62,7 +62,9 @@ static char *extract_filename(char *line, int patch_level)
62 62
63 /* skip over (patch_level) number of leading directories */ 63 /* skip over (patch_level) number of leading directories */
64 for (i = 0; i < patch_level; i++) { 64 for (i = 0; i < patch_level; i++) {
65 if(!(temp = strchr(filename_start_ptr, '/'))) break; 65 temp = strchr(filename_start_ptr, '/');
66 if (!temp)
67 break;
66 filename_start_ptr = temp + 1; 68 filename_start_ptr = temp + 1;
67 } 69 }
68 70
diff --git a/editors/vi.c b/editors/vi.c
index 5bce4272f..a103776d2 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -447,7 +447,7 @@ static void edit_file(char * fn)
447 q = p; 447 q = p;
448 p = strchr(q,'\n'); 448 p = strchr(q,'\n');
449 if (p) 449 if (p)
450 while(*p == '\n') 450 while (*p == '\n')
451 *p++ = '\0'; 451 *p++ = '\0';
452 if (*q) 452 if (*q)
453 colon(q); 453 colon(q);
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 695091a04..a430e5f3d 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -141,7 +141,7 @@ static xlist_t *process_stdin(xlist_t *list_arg,
141 } else { 141 } else {
142 goto set; 142 goto set;
143 } 143 }
144 } else { /* if(state == NORM) */ 144 } else { /* if (state == NORM) */
145 if (ISSPACE(c)) { 145 if (ISSPACE(c)) {
146 if (s) { 146 if (s) {
147unexpected_eof: 147unexpected_eof:
diff --git a/init/init.c b/init/init.c
index 8c32b7791..342e0a6b8 100644
--- a/init/init.c
+++ b/init/init.c
@@ -843,7 +843,7 @@ static void parse_inittab(void)
843 for (a = actions; a->name != 0; a++) { 843 for (a = actions; a->name != 0; a++) {
844 if (strcmp(a->name, action) == 0) { 844 if (strcmp(a->name, action) == 0) {
845 if (*id != '\0') { 845 if (*id != '\0') {
846 if(strncmp(id, "/dev/", 5) == 0) 846 if (strncmp(id, "/dev/", 5) == 0)
847 id += 5; 847 id += 5;
848 strcpy(tmpConsole, "/dev/"); 848 strcpy(tmpConsole, "/dev/");
849 safe_strncpy(tmpConsole + 5, id, 849 safe_strncpy(tmpConsole + 5, id,
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 700564212..a6cfe122d 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -254,7 +254,7 @@ int copy_file(const char *source, const char *dest, int flags)
254 return -1; 254 return -1;
255 } 255 }
256 if (con) { 256 if (con) {
257 if(setfilecon(dest, con) == -1) { 257 if (setfilecon(dest, con) == -1) {
258 bb_perror_msg("setfilecon:%s,%s", dest, con); 258 bb_perror_msg("setfilecon:%s,%s", dest, con);
259 freecon(con); 259 freecon(con);
260 return -1; 260 return -1;
diff --git a/libbb/get_console.c b/libbb/get_console.c
index 42ee137b9..9797ad6f0 100644
--- a/libbb/get_console.c
+++ b/libbb/get_console.c
@@ -50,17 +50,17 @@ int get_console_fd(void)
50 50
51 for (fd = 2; fd >= 0; fd--) { 51 for (fd = 2; fd >= 0; fd--) {
52 int fd4name; 52 int fd4name;
53 int choise_fd; 53 int choice_fd;
54 char arg; 54 char arg;
55 55
56 fd4name = open_a_console(console_names[fd]); 56 fd4name = open_a_console(console_names[fd]);
57 chk_std: 57 chk_std:
58 choise_fd = (fd4name >= 0 ? fd4name : fd); 58 choice_fd = (fd4name >= 0 ? fd4name : fd);
59 59
60 arg = 0; 60 arg = 0;
61 if (ioctl(choise_fd, KDGKBTYPE, &arg) == 0) 61 if (ioctl(choice_fd, KDGKBTYPE, &arg) == 0)
62 return choise_fd; 62 return choice_fd;
63 if(fd4name >= 0) { 63 if (fd4name >= 0) {
64 close(fd4name); 64 close(fd4name);
65 fd4name = -1; 65 fd4name = -1;
66 goto chk_std; 66 goto chk_std;
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c
index 2c9608e9e..1eb4af13c 100644
--- a/libbb/get_line_from_file.c
+++ b/libbb/get_line_from_file.c
@@ -17,7 +17,7 @@
17 * end of line. If end isn't NULL, length of the chunk read is stored in it. 17 * end of line. If end isn't NULL, length of the chunk read is stored in it.
18 * Return NULL if EOF/error */ 18 * Return NULL if EOF/error */
19 19
20char *bb_get_chunk_from_file(FILE * file, int *end) 20char *bb_get_chunk_from_file(FILE *file, int *end)
21{ 21{
22 int ch; 22 int ch;
23 int idx = 0; 23 int idx = 0;
@@ -27,7 +27,8 @@ char *bb_get_chunk_from_file(FILE * file, int *end)
27 while ((ch = getc(file)) != EOF) { 27 while ((ch = getc(file)) != EOF) {
28 /* grow the line buffer as necessary */ 28 /* grow the line buffer as necessary */
29 if (idx >= linebufsz) { 29 if (idx >= linebufsz) {
30 linebuf = xrealloc(linebuf, linebufsz += 80); 30 linebufsz += 80;
31 linebuf = xrealloc(linebuf, linebufsz);
31 } 32 }
32 linebuf[idx++] = (char) ch; 33 linebuf[idx++] = (char) ch;
33 if (!ch || (end && ch == '\n')) 34 if (!ch || (end && ch == '\n'))
@@ -49,7 +50,7 @@ char *bb_get_chunk_from_file(FILE * file, int *end)
49} 50}
50 51
51/* Get line, including trailing \n if any */ 52/* Get line, including trailing \n if any */
52char *xmalloc_fgets(FILE * file) 53char *xmalloc_fgets(FILE *file)
53{ 54{
54 int i; 55 int i;
55 56
@@ -57,7 +58,7 @@ char *xmalloc_fgets(FILE * file)
57} 58}
58 59
59/* Get line. Remove trailing \n */ 60/* Get line. Remove trailing \n */
60char *xmalloc_getline(FILE * file) 61char *xmalloc_getline(FILE *file)
61{ 62{
62 int i; 63 int i;
63 char *c = bb_get_chunk_from_file(file, &i); 64 char *c = bb_get_chunk_from_file(file, &i);
diff --git a/libbb/login.c b/libbb/login.c
index 6ebb9a6a0..f3a3357bc 100644
--- a/libbb/login.c
+++ b/libbb/login.c
@@ -43,7 +43,7 @@ void print_login_issue(const char *issue_file, const char *tty)
43 outbuf = buf; 43 outbuf = buf;
44 buf[0] = c; 44 buf[0] = c;
45 buf[1] = '\0'; 45 buf[1] = '\0';
46 if(c == '\n') { 46 if (c == '\n') {
47 buf[1] = '\r'; 47 buf[1] = '\r';
48 buf[2] = '\0'; 48 buf[2] = '\0';
49 } 49 }
diff --git a/libbb/trim.c b/libbb/trim.c
index d36391540..4957d7276 100644
--- a/libbb/trim.c
+++ b/libbb/trim.c
@@ -8,12 +8,8 @@
8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9 */ 9 */
10 10
11#include <stdio.h>
12#include <string.h>
13#include <ctype.h>
14#include "libbb.h" 11#include "libbb.h"
15 12
16
17void trim(char *s) 13void trim(char *s)
18{ 14{
19 size_t len = strlen(s); 15 size_t len = strlen(s);
@@ -23,9 +19,9 @@ void trim(char *s)
23 while (len && isspace(s[len-1])) --len; 19 while (len && isspace(s[len-1])) --len;
24 20
25 /* trim leading whitespace */ 21 /* trim leading whitespace */
26 if(len) { 22 if (len) {
27 lws = strspn(s, " \n\r\t\v"); 23 lws = strspn(s, " \n\r\t\v");
28 memmove(s, s + lws, len -= lws); 24 memmove(s, s + lws, len -= lws);
29 } 25 }
30 s[len] = 0; 26 s[len] = '\0';
31} 27}
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index aa000a7ab..fce7ea43d 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -48,7 +48,7 @@ int makedevs_main(int argc, char **argv)
48 int sz; 48 int sz;
49 49
50 sz = snprintf(buf, sizeof(buf), "%s%d", basedev, S); 50 sz = snprintf(buf, sizeof(buf), "%s%d", basedev, S);
51 if(sz<0 || sz>=sizeof(buf)) /* libc different */ 51 if (sz < 0 || sz >= sizeof(buf)) /* libc different */
52 bb_error_msg_and_die("%s too large", basedev); 52 bb_error_msg_and_die("%s too large", basedev);
53 53
54 /* if mode != S_IFCHR and != S_IFBLK third param in mknod() ignored */ 54 /* if mode != S_IFCHR and != S_IFBLK third param in mknod() ignored */
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 50b5dd18e..adfbd33fe 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -3410,7 +3410,7 @@ static struct obj_file *obj_load(FILE * fp, int loadprogbits)
3410 sec->header = section_headers[i]; 3410 sec->header = section_headers[i];
3411 sec->idx = i; 3411 sec->idx = i;
3412 3412
3413 if(sec->header.sh_size) { 3413 if (sec->header.sh_size) {
3414 switch (sec->header.sh_type) { 3414 switch (sec->header.sh_type) {
3415 case SHT_NULL: 3415 case SHT_NULL:
3416 case SHT_NOTE: 3416 case SHT_NOTE:
@@ -4219,17 +4219,17 @@ int insmod_main( int argc, char **argv)
4219 goto out; 4219 goto out;
4220 } 4220 }
4221 4221
4222 if(flag_print_load_map) 4222 if (flag_print_load_map)
4223 print_load_map(f); 4223 print_load_map(f);
4224 4224
4225 exit_status = EXIT_SUCCESS; 4225 exit_status = EXIT_SUCCESS;
4226 4226
4227out: 4227out:
4228#if ENABLE_FEATURE_CLEAN_UP 4228#if ENABLE_FEATURE_CLEAN_UP
4229 if(fp) 4229 if (fp)
4230 fclose(fp); 4230 fclose(fp);
4231 free(tmp1); 4231 free(tmp1);
4232 if(!tmp1) 4232 if (!tmp1)
4233 free(m_name); 4233 free(m_name);
4234 free(m_filename); 4234 free(m_filename);
4235#endif 4235#endif
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index 0a67b8965..67cf58c3b 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -46,11 +46,11 @@ int rmmod_main(int argc, char **argv)
46 46
47 /* Parse command line. */ 47 /* Parse command line. */
48 n = getopt32(argc, argv, "wfa"); 48 n = getopt32(argc, argv, "wfa");
49 if((n & 1)) // --wait 49 if (n & 1) // --wait
50 flags &= ~O_NONBLOCK; 50 flags &= ~O_NONBLOCK;
51 if((n & 2)) // --force 51 if (n & 2) // --force
52 flags |= O_TRUNC; 52 flags |= O_TRUNC;
53 if((n & 4)) { 53 if (n & 4) {
54 /* Unload _all_ unused modules via NULL delete_module() call */ 54 /* Unload _all_ unused modules via NULL delete_module() call */
55 /* until the number of modules does not change */ 55 /* until the number of modules does not change */
56 size_t nmod = 0; /* number of modules */ 56 size_t nmod = 0; /* number of modules */
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c
index 173f5a867..57af7ebe5 100644
--- a/networking/nc_bloaty.c
+++ b/networking/nc_bloaty.c
@@ -149,13 +149,13 @@ enum {
149/* Debug: squirt whatever message and sleep a bit so we can see it go by. */ 149/* Debug: squirt whatever message and sleep a bit so we can see it go by. */
150/* Beware: writes to stdOUT... */ 150/* Beware: writes to stdOUT... */
151#if 0 151#if 0
152#define Debug(...) do { printf(__VA_ARGS__); printf("\n"); fflush(stdout); sleep(1); } while(0) 152#define Debug(...) do { printf(__VA_ARGS__); printf("\n"); fflush(stdout); sleep(1); } while (0)
153#else 153#else
154#define Debug(...) do { } while(0) 154#define Debug(...) do { } while (0)
155#endif 155#endif
156 156
157#define holler_error(...) do { if (o_verbose) bb_error_msg(__VA_ARGS__); } while(0) 157#define holler_error(...) do { if (o_verbose) bb_error_msg(__VA_ARGS__); } while (0)
158#define holler_perror(...) do { if (o_verbose) bb_perror_msg(__VA_ARGS__); } while(0) 158#define holler_perror(...) do { if (o_verbose) bb_perror_msg(__VA_ARGS__); } while (0)
159 159
160/* catch: no-brainer interrupt handler */ 160/* catch: no-brainer interrupt handler */
161static void catch(int sig) 161static void catch(int sig)
diff --git a/networking/nslookup.c b/networking/nslookup.c
index 8076aff98..424a0e4b9 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -147,7 +147,7 @@ int nslookup_main(int argc, char **argv)
147 /* (but it also says "may be enabled in /etc/resolv.conf|) */ 147 /* (but it also says "may be enabled in /etc/resolv.conf|) */
148 /*_res.options |= RES_USE_INET6;*/ 148 /*_res.options |= RES_USE_INET6;*/
149 149
150 if(argc == 3) 150 if (argc == 3)
151 set_default_dns(argv[2]); 151 set_default_dns(argv[2]);
152 152
153 server_print(); 153 server_print();
diff --git a/networking/route.c b/networking/route.c
index 5b3e68b4c..dfb8ee56f 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -174,7 +174,7 @@ static void INET_setroute(int action, char **args)
174 174
175 /* recognize x.x.x.x/mask format. */ 175 /* recognize x.x.x.x/mask format. */
176 prefix = strchr(target, '/'); 176 prefix = strchr(target, '/');
177 if(prefix) { 177 if (prefix) {
178 int prefix_len; 178 int prefix_len;
179 179
180 prefix_len = xatoul_range(prefix+1, 0, 32); 180 prefix_len = xatoul_range(prefix+1, 0, 32);
@@ -193,7 +193,7 @@ static void INET_setroute(int action, char **args)
193 if (isnet < 0) { 193 if (isnet < 0) {
194 bb_error_msg_and_die("resolving %s", target); 194 bb_error_msg_and_die("resolving %s", target);
195 } 195 }
196 if(prefix) { 196 if (prefix) {
197 /* do not destroy prefix for process args */ 197 /* do not destroy prefix for process args */
198 *prefix = '/'; 198 *prefix = '/';
199 } 199 }
diff --git a/procps/sysctl.c b/procps/sysctl.c
index 7c72ac933..2c3fda5fe 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -301,14 +301,16 @@ int sysctl_display_all(const char *path, int output, int show_table)
301 char *tmpdir; 301 char *tmpdir;
302 struct stat ts; 302 struct stat ts;
303 303
304 if (!(dp = opendir(path))) { 304 dp = opendir(path);
305 if (!dp) {
305 retval = -1; 306 retval = -1;
306 } else { 307 } else {
307 while ((de = readdir(dp)) != NULL) { 308 while ((de = readdir(dp)) != NULL) {
308 tmpdir = concat_subpath_file(path, de->d_name); 309 tmpdir = concat_subpath_file(path, de->d_name);
309 if(tmpdir == NULL) 310 if (tmpdir == NULL)
310 continue; 311 continue;
311 if ((retval2 = stat(tmpdir, &ts)) != 0) 312 retval2 = stat(tmpdir, &ts);
313 if (retval2 != 0)
312 bb_perror_msg(tmpdir); 314 bb_perror_msg(tmpdir);
313 else { 315 else {
314 if (S_ISDIR(ts.st_mode)) { 316 if (S_ISDIR(ts.st_mode)) {
diff --git a/procps/uptime.c b/procps/uptime.c
index 3573ffe73..c2b5d3966 100644
--- a/procps/uptime.c
+++ b/procps/uptime.c
@@ -46,7 +46,7 @@ int uptime_main(int argc, char **argv)
46 upminutes = (int) info.uptime / 60; 46 upminutes = (int) info.uptime / 60;
47 uphours = (upminutes / 60) % 24; 47 uphours = (upminutes / 60) % 24;
48 upminutes %= 60; 48 upminutes %= 60;
49 if(uphours) 49 if (uphours)
50 printf("%2d:%02d, ", uphours, upminutes); 50 printf("%2d:%02d, ", uphours, upminutes);
51 else 51 else
52 printf("%d min, ", upminutes); 52 printf("%d min, ", upminutes);
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index d9db84ac5..a1b761bbd 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -178,7 +178,7 @@ void find_export_symbols(char * filename)
178 fprintf(stderr, "docproc: "); 178 fprintf(stderr, "docproc: ");
179 perror(real_filename); 179 perror(real_filename);
180 } 180 }
181 while(fgets(line, MAXLINESZ, fp)) { 181 while (fgets(line, MAXLINESZ, fp)) {
182 char *p; 182 char *p;
183 char *e; 183 char *e;
184 if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != 0) || 184 if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != 0) ||
@@ -291,7 +291,7 @@ void parse_file(FILE *infile)
291{ 291{
292 char line[MAXLINESZ]; 292 char line[MAXLINESZ];
293 char * s; 293 char * s;
294 while(fgets(line, MAXLINESZ, infile)) { 294 while (fgets(line, MAXLINESZ, infile)) {
295 if (line[0] == '!') { 295 if (line[0] == '!') {
296 s = line + 2; 296 s = line + 2;
297 switch (line[1]) { 297 switch (line[1]) {
diff --git a/selinux/matchpathcon.c b/selinux/matchpathcon.c
index 83ea75d47..4e33c99f1 100644
--- a/selinux/matchpathcon.c
+++ b/selinux/matchpathcon.c
@@ -53,7 +53,7 @@ int matchpathcon_main(int argc, char **argv)
53 bb_perror_msg_and_die("error while processing %s", prefix); 53 bb_perror_msg_and_die("error while processing %s", prefix);
54 } 54 }
55 55
56 while((path = *argv++) != NULL) { 56 while ((path = *argv++) != NULL) {
57 security_context_t con; 57 security_context_t con;
58 int rc; 58 int rc;
59 59
diff --git a/shell/bbsh.c b/shell/bbsh.c
index 6bef3685a..8f0fb0511 100644
--- a/shell/bbsh.c
+++ b/shell/bbsh.c
@@ -68,7 +68,7 @@ struct pipeline {
68 68
69static void free_list(void *list, void (*freeit)(void *data)) 69static void free_list(void *list, void (*freeit)(void *data))
70{ 70{
71 while(list) { 71 while (list) {
72 void **next = (void **)list; 72 void **next = (void **)list;
73 void *list_next = *next; 73 void *list_next = *next;
74 freeit(list); 74 freeit(list);
@@ -159,12 +159,12 @@ static int run_pipeline(struct pipeline *line)
159 // Handle local commands. This is totally fake and plastic. 159 // Handle local commands. This is totally fake and plastic.
160 if (cmd->argc==2 && !strcmp(cmd->argv[0],"cd")) 160 if (cmd->argc==2 && !strcmp(cmd->argv[0],"cd"))
161 chdir(cmd->argv[1]); 161 chdir(cmd->argv[1]);
162 else if(!strcmp(cmd->argv[0],"exit")) 162 else if (!strcmp(cmd->argv[0],"exit"))
163 exit(cmd->argc>1 ? atoi(cmd->argv[1]) : 0); 163 exit(cmd->argc>1 ? atoi(cmd->argv[1]) : 0);
164 else { 164 else {
165 int status; 165 int status;
166 pid_t pid=fork(); 166 pid_t pid=fork();
167 if(!pid) { 167 if (!pid) {
168 run_applet_and_exit(cmd->argv[0],cmd->argc,cmd->argv); 168 run_applet_and_exit(cmd->argv[0],cmd->argc,cmd->argv);
169 execvp(cmd->argv[0],cmd->argv); 169 execvp(cmd->argv[0],cmd->argv);
170 printf("No %s",cmd->argv[0]); 170 printf("No %s",cmd->argv[0]);
@@ -179,7 +179,7 @@ static void free_cmd(void *data)
179{ 179{
180 struct command *cmd=(struct command *)data; 180 struct command *cmd=(struct command *)data;
181 181
182 while(cmd->argc) free(cmd->argv[--cmd->argc]); 182 while (cmd->argc) free(cmd->argv[--cmd->argc]);
183} 183}
184 184
185 185
@@ -211,8 +211,8 @@ int bbsh_main(int argc, char **argv)
211 else { 211 else {
212 unsigned cmdlen=0; 212 unsigned cmdlen=0;
213 for (;;) { 213 for (;;) {
214 if(!f) putchar('$'); 214 if (!f) putchar('$');
215 if(1 > getline(&command, &cmdlen,f ? : stdin)) break; 215 if (1 > getline(&command, &cmdlen,f ? : stdin)) break;
216 216
217 handle(command); 217 handle(command);
218 } 218 }
diff --git a/shell/msh.c b/shell/msh.c
index 963e59446..4d1e84cf0 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -92,21 +92,21 @@ extern char **environ;
92#ifdef MSHDEBUG 92#ifdef MSHDEBUG
93int mshdbg = MSHDEBUG; 93int mshdbg = MSHDEBUG;
94 94
95#define DBGPRINTF(x) if(mshdbg>0)printf x 95#define DBGPRINTF(x) if (mshdbg>0) printf x
96#define DBGPRINTF0(x) if(mshdbg>0)printf x 96#define DBGPRINTF0(x) if (mshdbg>0) printf x
97#define DBGPRINTF1(x) if(mshdbg>1)printf x 97#define DBGPRINTF1(x) if (mshdbg>1) printf x
98#define DBGPRINTF2(x) if(mshdbg>2)printf x 98#define DBGPRINTF2(x) if (mshdbg>2) printf x
99#define DBGPRINTF3(x) if(mshdbg>3)printf x 99#define DBGPRINTF3(x) if (mshdbg>3) printf x
100#define DBGPRINTF4(x) if(mshdbg>4)printf x 100#define DBGPRINTF4(x) if (mshdbg>4) printf x
101#define DBGPRINTF5(x) if(mshdbg>5)printf x 101#define DBGPRINTF5(x) if (mshdbg>5) printf x
102#define DBGPRINTF6(x) if(mshdbg>6)printf x 102#define DBGPRINTF6(x) if (mshdbg>6) printf x
103#define DBGPRINTF7(x) if(mshdbg>7)printf x 103#define DBGPRINTF7(x) if (mshdbg>7) printf x
104#define DBGPRINTF8(x) if(mshdbg>8)printf x 104#define DBGPRINTF8(x) if (mshdbg>8) printf x
105#define DBGPRINTF9(x) if(mshdbg>9)printf x 105#define DBGPRINTF9(x) if (mshdbg>9) printf x
106 106
107int mshdbg_rc = 0; 107int mshdbg_rc = 0;
108 108
109#define RCPRINTF(x) if(mshdbg_rc)printf x 109#define RCPRINTF(x) if (mshdbg_rc) printf x
110 110
111#else 111#else
112 112
diff --git a/util-linux/mount.c b/util-linux/mount.c
index bc1c0d4a9..e4a7c81c6 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -138,7 +138,7 @@ static void append_mount_options(char **oldopts, const char *newopts)
138 && (p[len]==',' || p[len]==0)) 138 && (p[len]==',' || p[len]==0))
139 goto skip; 139 goto skip;
140 p = strchr(p,','); 140 p = strchr(p,',');
141 if(!p) break; 141 if (!p) break;
142 p++; 142 p++;
143 } 143 }
144 p = xasprintf("%s,%.*s", *oldopts, len, newopts); 144 p = xasprintf("%s,%.*s", *oldopts, len, newopts);
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index 43377e16e..6dba9f05f 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -24,7 +24,7 @@
24#define MS_MOVE 8192 24#define MS_MOVE 8192
25#endif 25#endif
26 26
27dev_t rootdev; 27static dev_t rootdev;
28 28
29// Recursively delete contents of rootfs. 29// Recursively delete contents of rootfs.
30 30
@@ -39,12 +39,13 @@ static void delete_contents(const char *directory)
39 39
40 // Recursively delete the contents of directories. 40 // Recursively delete the contents of directories.
41 if (S_ISDIR(st.st_mode)) { 41 if (S_ISDIR(st.st_mode)) {
42 if((dir = opendir(directory))) { 42 dir = opendir(directory);
43 if (dir) {
43 while ((d = readdir(dir))) { 44 while ((d = readdir(dir))) {
44 char *newdir=d->d_name; 45 char *newdir = d->d_name;
45 46
46 // Skip . and .. 47 // Skip . and ..
47 if(*newdir=='.' && (!newdir[1] || (newdir[1]=='.' && !newdir[2]))) 48 if (*newdir=='.' && (!newdir[1] || (newdir[1]=='.' && !newdir[2])))
48 continue; 49 continue;
49 50
50 // Recurse to delete contents 51 // Recurse to delete contents
@@ -66,7 +67,7 @@ static void delete_contents(const char *directory)
66int switch_root_main(int argc, char **argv); 67int switch_root_main(int argc, char **argv);
67int switch_root_main(int argc, char **argv) 68int switch_root_main(int argc, char **argv)
68{ 69{
69 char *newroot, *console=NULL; 70 char *newroot, *console = NULL;
70 struct stat st1, st2; 71 struct stat st1, st2;
71 struct statfs stfs; 72 struct statfs stfs;
72 73
@@ -77,18 +78,18 @@ int switch_root_main(int argc, char **argv)
77 78
78 // Change to new root directory and verify it's a different fs. 79 // Change to new root directory and verify it's a different fs.
79 80
80 newroot=argv[optind++]; 81 newroot = argv[optind++];
81 82
82 if (chdir(newroot) || lstat(".", &st1) || lstat("/", &st2) || 83 if (chdir(newroot) || lstat(".", &st1) || lstat("/", &st2) ||
83 st1.st_dev == st2.st_dev) 84 st1.st_dev == st2.st_dev)
84 { 85 {
85 bb_error_msg_and_die("bad newroot %s", newroot); 86 bb_error_msg_and_die("bad newroot %s", newroot);
86 } 87 }
87 rootdev=st2.st_dev; 88 rootdev = st2.st_dev;
88 89
89 // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE 90 // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE
90 // we mean it. (I could make this a CONFIG option, but I would get email 91 // we mean it. (I could make this a CONFIG option, but I would get email
91 // from all the people who WILL eat their filesystemss.) 92 // from all the people who WILL eat their filesystems.)
92 93
93 if (lstat("/init", &st1) || !S_ISREG(st1.st_mode) || statfs("/", &stfs) || 94 if (lstat("/init", &st1) || !S_ISREG(st1.st_mode) || statfs("/", &stfs) ||
94 (stfs.f_type != RAMFS_MAGIC && stfs.f_type != TMPFS_MAGIC) || 95 (stfs.f_type != RAMFS_MAGIC && stfs.f_type != TMPFS_MAGIC) ||
@@ -105,14 +106,13 @@ int switch_root_main(int argc, char **argv)
105 // recalculate "." and ".." links. 106 // recalculate "." and ".." links.
106 107
107 if (mount(".", "/", NULL, MS_MOVE, NULL) || chroot(".") || chdir("/")) 108 if (mount(".", "/", NULL, MS_MOVE, NULL) || chroot(".") || chdir("/"))
108 bb_error_msg_and_die("moving root"); 109 bb_error_msg_and_die("error moving root");
109 110
110 // If a new console specified, redirect stdin/stdout/stderr to that. 111 // If a new console specified, redirect stdin/stdout/stderr to that.
111 112
112 if (console) { 113 if (console) {
113 close(0); 114 close(0);
114 if (open(console, O_RDWR) < 0) 115 xopen(console, O_RDWR);
115 bb_error_msg_and_die("bad console '%s'", console);
116 dup2(0, 1); 116 dup2(0, 1);
117 dup2(0, 2); 117 dup2(0, 2);
118 } 118 }