diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-09-21 01:59:15 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-09-21 01:59:15 +0200 |
commit | 16714245f9a16ce3725aab079aea7b0d28c6b32f (patch) | |
tree | 41edbcd1c279b2baae2d5e5751639076e0a3bfad | |
parent | 5c6ba6c56f9653488e1d805e727bb06c39ed23fa (diff) | |
download | busybox-w32-16714245f9a16ce3725aab079aea7b0d28c6b32f.tar.gz busybox-w32-16714245f9a16ce3725aab079aea7b0d28c6b32f.tar.bz2 busybox-w32-16714245f9a16ce3725aab079aea7b0d28c6b32f.zip |
add INIT_G()'s. No code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/du.c | 3 | ||||
-rw-r--r-- | coreutils/expr.c | 3 | ||||
-rw-r--r-- | coreutils/tail.c | 3 | ||||
-rw-r--r-- | include/libbb.h | 9 | ||||
-rw-r--r-- | miscutils/hdparm.c | 3 | ||||
-rw-r--r-- | networking/zcip.c | 2 | ||||
-rw-r--r-- | procps/top.c | 2 | ||||
-rw-r--r-- | runit/runsvdir.c | 3 | ||||
-rw-r--r-- | util-linux/mdev.c | 5 | ||||
-rw-r--r-- | util-linux/mount.c | 3 | ||||
-rw-r--r-- | util-linux/swaponoff.c | 3 |
11 files changed, 33 insertions, 6 deletions
diff --git a/coreutils/du.c b/coreutils/du.c index b8bbe3d9e..34a549f02 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
@@ -88,6 +88,7 @@ struct globals { | |||
88 | dev_t dir_dev; | 88 | dev_t dir_dev; |
89 | } FIX_ALIASING; | 89 | } FIX_ALIASING; |
90 | #define G (*(struct globals*)&bb_common_bufsiz1) | 90 | #define G (*(struct globals*)&bb_common_bufsiz1) |
91 | #define INIT_G() do { } while (0) | ||
91 | 92 | ||
92 | 93 | ||
93 | static void print(unsigned long size, const char *filename) | 94 | static void print(unsigned long size, const char *filename) |
@@ -193,6 +194,8 @@ int du_main(int argc UNUSED_PARAM, char **argv) | |||
193 | int slink_depth_save; | 194 | int slink_depth_save; |
194 | unsigned opt; | 195 | unsigned opt; |
195 | 196 | ||
197 | INIT_G(); | ||
198 | |||
196 | #if ENABLE_FEATURE_HUMAN_READABLE | 199 | #if ENABLE_FEATURE_HUMAN_READABLE |
197 | IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;) | 200 | IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;) |
198 | IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;) | 201 | IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;) |
diff --git a/coreutils/expr.c b/coreutils/expr.c index 24e75b556..c986f9327 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
@@ -100,6 +100,7 @@ struct globals { | |||
100 | char **args; | 100 | char **args; |
101 | } FIX_ALIASING; | 101 | } FIX_ALIASING; |
102 | #define G (*(struct globals*)&bb_common_bufsiz1) | 102 | #define G (*(struct globals*)&bb_common_bufsiz1) |
103 | #define INIT_G() do { } while (0) | ||
103 | 104 | ||
104 | /* forward declarations */ | 105 | /* forward declarations */ |
105 | static VALUE *eval(void); | 106 | static VALUE *eval(void); |
@@ -519,6 +520,8 @@ int expr_main(int argc UNUSED_PARAM, char **argv) | |||
519 | { | 520 | { |
520 | VALUE *v; | 521 | VALUE *v; |
521 | 522 | ||
523 | INIT_G(); | ||
524 | |||
522 | xfunc_error_retval = 2; /* coreutils compat */ | 525 | xfunc_error_retval = 2; /* coreutils compat */ |
523 | G.args = argv + 1; | 526 | G.args = argv + 1; |
524 | if (*G.args == NULL) { | 527 | if (*G.args == NULL) { |
diff --git a/coreutils/tail.c b/coreutils/tail.c index 43cecbd97..b376ec863 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -62,6 +62,7 @@ struct globals { | |||
62 | bool exitcode; | 62 | bool exitcode; |
63 | } FIX_ALIASING; | 63 | } FIX_ALIASING; |
64 | #define G (*(struct globals*)&bb_common_bufsiz1) | 64 | #define G (*(struct globals*)&bb_common_bufsiz1) |
65 | #define INIT_G() do { } while (0) | ||
65 | 66 | ||
66 | static void tail_xprint_header(const char *fmt, const char *filename) | 67 | static void tail_xprint_header(const char *fmt, const char *filename) |
67 | { | 68 | { |
@@ -120,6 +121,8 @@ int tail_main(int argc, char **argv) | |||
120 | int *fds; | 121 | int *fds; |
121 | const char *fmt; | 122 | const char *fmt; |
122 | 123 | ||
124 | INIT_G(); | ||
125 | |||
123 | #if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL | 126 | #if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL |
124 | /* Allow legacy syntax of an initial numeric option without -n. */ | 127 | /* Allow legacy syntax of an initial numeric option without -n. */ |
125 | if (argv[1] && (argv[1][0] == '+' || argv[1][0] == '-') | 128 | if (argv[1] && (argv[1][0] == '+' || argv[1][0] == '-') |
diff --git a/include/libbb.h b/include/libbb.h index feae85259..f79b69365 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -684,10 +684,13 @@ void *malloc_or_warn(size_t size) FAST_FUNC RETURNS_MALLOC; | |||
684 | void *xmalloc(size_t size) FAST_FUNC RETURNS_MALLOC; | 684 | void *xmalloc(size_t size) FAST_FUNC RETURNS_MALLOC; |
685 | void *xzalloc(size_t size) FAST_FUNC RETURNS_MALLOC; | 685 | void *xzalloc(size_t size) FAST_FUNC RETURNS_MALLOC; |
686 | void *xrealloc(void *old, size_t size) FAST_FUNC; | 686 | void *xrealloc(void *old, size_t size) FAST_FUNC; |
687 | /* After xrealloc_vector(v, 4, idx) it's ok to use | 687 | /* After v = xrealloc_vector(v, SHIFT, idx) it's ok to use |
688 | * at least v[idx] and v[idx+1], for all idx values. | 688 | * at least v[idx] and v[idx+1], for all idx values. |
689 | * shift specifies how many new elements are added (1: 2, 2: 4... 8: 256...) | 689 | * SHIFT specifies how many new elements are added (1:2, 2:4, ..., 8:256...) |
690 | * when all elements are used up. New elements are zeroed out. */ | 690 | * when all elements are used up. New elements are zeroed out. |
691 | * xrealloc_vector(v, SHIFT, idx) *MUST* be called with consecutive IDXs - | ||
692 | * skipping an index is a bad bug - it may miss a realloc! | ||
693 | */ | ||
691 | #define xrealloc_vector(vector, shift, idx) \ | 694 | #define xrealloc_vector(vector, shift, idx) \ |
692 | xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx)) | 695 | xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx)) |
693 | void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC; | 696 | void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC; |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index f30e7dec6..a97f3e7b5 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -433,6 +433,7 @@ struct BUG_G_too_big { | |||
433 | #define hwif_data (G.hwif_data ) | 433 | #define hwif_data (G.hwif_data ) |
434 | #define hwif_ctrl (G.hwif_ctrl ) | 434 | #define hwif_ctrl (G.hwif_ctrl ) |
435 | #define hwif_irq (G.hwif_irq ) | 435 | #define hwif_irq (G.hwif_irq ) |
436 | #define INIT_G() do { } while (0) | ||
436 | 437 | ||
437 | 438 | ||
438 | /* Busybox messages and functions */ | 439 | /* Busybox messages and functions */ |
@@ -2059,6 +2060,8 @@ int hdparm_main(int argc, char **argv) | |||
2059 | int c; | 2060 | int c; |
2060 | int flagcount = 0; | 2061 | int flagcount = 0; |
2061 | 2062 | ||
2063 | INIT_G(); | ||
2064 | |||
2062 | while ((c = getopt(argc, argv, hdparm_options)) >= 0) { | 2065 | while ((c = getopt(argc, argv, hdparm_options)) >= 0) { |
2063 | flagcount++; | 2066 | flagcount++; |
2064 | IF_FEATURE_HDPARM_GET_IDENTITY(get_IDentity |= (c == 'I')); | 2067 | IF_FEATURE_HDPARM_GET_IDENTITY(get_IDentity |= (c == 'I')); |
diff --git a/networking/zcip.c b/networking/zcip.c index 8a35eca5d..7314ff8db 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
@@ -91,6 +91,7 @@ struct globals { | |||
91 | #define G (*(struct globals*)&bb_common_bufsiz1) | 91 | #define G (*(struct globals*)&bb_common_bufsiz1) |
92 | #define saddr (G.saddr ) | 92 | #define saddr (G.saddr ) |
93 | #define eth_addr (G.eth_addr) | 93 | #define eth_addr (G.eth_addr) |
94 | #define INIT_G() do { } while (0) | ||
94 | 95 | ||
95 | 96 | ||
96 | /** | 97 | /** |
@@ -223,6 +224,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) | |||
223 | #define verbose (L.verbose ) | 224 | #define verbose (L.verbose ) |
224 | 225 | ||
225 | memset(&L, 0, sizeof(L)); | 226 | memset(&L, 0, sizeof(L)); |
227 | INIT_G(); | ||
226 | 228 | ||
227 | #define FOREGROUND (opts & 1) | 229 | #define FOREGROUND (opts & 1) |
228 | #define QUIT (opts & 2) | 230 | #define QUIT (opts & 2) |
diff --git a/procps/top.c b/procps/top.c index 011bbf183..15eb624cc 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -126,7 +126,6 @@ struct BUG_bad_size { | |||
126 | char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; | 126 | char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; |
127 | char BUG_line_buf_too_small[LINE_BUF_SIZE > 80 ? 1 : -1]; | 127 | char BUG_line_buf_too_small[LINE_BUF_SIZE > 80 ? 1 : -1]; |
128 | }; | 128 | }; |
129 | #define INIT_G() do { } while (0) | ||
130 | #define top (G.top ) | 129 | #define top (G.top ) |
131 | #define ntop (G.ntop ) | 130 | #define ntop (G.ntop ) |
132 | #define sort_field (G.sort_field ) | 131 | #define sort_field (G.sort_field ) |
@@ -143,6 +142,7 @@ struct BUG_bad_size { | |||
143 | #define num_cpus (G.num_cpus ) | 142 | #define num_cpus (G.num_cpus ) |
144 | #define total_pcpu (G.total_pcpu ) | 143 | #define total_pcpu (G.total_pcpu ) |
145 | #define line_buf (G.line_buf ) | 144 | #define line_buf (G.line_buf ) |
145 | #define INIT_G() do { } while (0) | ||
146 | 146 | ||
147 | enum { | 147 | enum { |
148 | OPT_d = (1 << 0), | 148 | OPT_d = (1 << 0), |
diff --git a/runit/runsvdir.c b/runit/runsvdir.c index 9495a2a4f..32526cf4c 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c | |||
@@ -75,8 +75,7 @@ struct globals { | |||
75 | #define logpipe (G.logpipe ) | 75 | #define logpipe (G.logpipe ) |
76 | #define pfd (G.pfd ) | 76 | #define pfd (G.pfd ) |
77 | #define stamplog (G.stamplog ) | 77 | #define stamplog (G.stamplog ) |
78 | #define INIT_G() do { \ | 78 | #define INIT_G() do { } while (0) |
79 | } while (0) | ||
80 | 79 | ||
81 | static void fatal2_cannot(const char *m1, const char *m2) | 80 | static void fatal2_cannot(const char *m1, const char *m2) |
82 | { | 81 | { |
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 27b35572d..c56741b08 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
@@ -173,6 +173,8 @@ struct globals { | |||
173 | char *subsystem; | 173 | char *subsystem; |
174 | } FIX_ALIASING; | 174 | } FIX_ALIASING; |
175 | #define G (*(struct globals*)&bb_common_bufsiz1) | 175 | #define G (*(struct globals*)&bb_common_bufsiz1) |
176 | #define INIT_G() do { } while (0) | ||
177 | |||
176 | 178 | ||
177 | /* Prevent infinite loops in /sys symlinks */ | 179 | /* Prevent infinite loops in /sys symlinks */ |
178 | #define MAX_SYSFS_DEPTH 3 | 180 | #define MAX_SYSFS_DEPTH 3 |
@@ -180,6 +182,7 @@ struct globals { | |||
180 | /* We use additional 64+ bytes in make_device() */ | 182 | /* We use additional 64+ bytes in make_device() */ |
181 | #define SCRATCH_SIZE 80 | 183 | #define SCRATCH_SIZE 80 |
182 | 184 | ||
185 | |||
183 | /* Builds an alias path. | 186 | /* Builds an alias path. |
184 | * This function potentionally reallocates the alias parameter. | 187 | * This function potentionally reallocates the alias parameter. |
185 | * Only used for ENABLE_FEATURE_MDEV_RENAME | 188 | * Only used for ENABLE_FEATURE_MDEV_RENAME |
@@ -613,6 +616,8 @@ int mdev_main(int argc UNUSED_PARAM, char **argv) | |||
613 | { | 616 | { |
614 | RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE); | 617 | RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE); |
615 | 618 | ||
619 | INIT_G(); | ||
620 | |||
616 | /* We can be called as hotplug helper */ | 621 | /* We can be called as hotplug helper */ |
617 | /* Kernel cannot provide suitable stdio fds for us, do it ourself */ | 622 | /* Kernel cannot provide suitable stdio fds for us, do it ourself */ |
618 | bb_sanitize_stdio(); | 623 | bb_sanitize_stdio(); |
diff --git a/util-linux/mount.c b/util-linux/mount.c index b51ab1782..56276ef01 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -339,6 +339,7 @@ enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_b | |||
339 | #endif | 339 | #endif |
340 | #define fslist (G.fslist ) | 340 | #define fslist (G.fslist ) |
341 | #define getmntent_buf (G.getmntent_buf ) | 341 | #define getmntent_buf (G.getmntent_buf ) |
342 | #define INIT_G() do { } while (0) | ||
342 | 343 | ||
343 | #if ENABLE_FEATURE_MTAB_SUPPORT | 344 | #if ENABLE_FEATURE_MTAB_SUPPORT |
344 | /* | 345 | /* |
@@ -1944,6 +1945,8 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
1944 | 1945 | ||
1945 | IF_DESKTOP(int nonroot = ) sanitize_env_if_suid(); | 1946 | IF_DESKTOP(int nonroot = ) sanitize_env_if_suid(); |
1946 | 1947 | ||
1948 | INIT_G(); | ||
1949 | |||
1947 | // Parse long options, like --bind and --move. Note that -o option | 1950 | // Parse long options, like --bind and --move. Note that -o option |
1948 | // and --option are synonymous. Yes, this means --remount,rw works. | 1951 | // and --option are synonymous. Yes, this means --remount,rw works. |
1949 | for (i = j = 1; argv[i]; i++) { | 1952 | for (i = j = 1; argv[i]; i++) { |
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index e53e24c71..b3057b309 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c | |||
@@ -48,6 +48,7 @@ struct globals { | |||
48 | #else | 48 | #else |
49 | #define g_flags 0 | 49 | #define g_flags 0 |
50 | #endif | 50 | #endif |
51 | #define INIT_G() do { } while (0) | ||
51 | 52 | ||
52 | static int swap_enable_disable(char *device) | 53 | static int swap_enable_disable(char *device) |
53 | { | 54 | { |
@@ -111,6 +112,8 @@ int swap_on_off_main(int argc UNUSED_PARAM, char **argv) | |||
111 | { | 112 | { |
112 | int ret; | 113 | int ret; |
113 | 114 | ||
115 | INIT_G(); | ||
116 | |||
114 | #if !ENABLE_FEATURE_SWAPON_PRI | 117 | #if !ENABLE_FEATURE_SWAPON_PRI |
115 | ret = getopt32(argv, "a"); | 118 | ret = getopt32(argv, "a"); |
116 | #else | 119 | #else |