summaryrefslogtreecommitdiff
authorDenys Vlasenko <vda.linux@googlemail.com>2011-09-20 23:59:15 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2011-09-20 23:59:15 (GMT)
commit16714245f9a16ce3725aab079aea7b0d28c6b32f (patch)
tree41edbcd1c279b2baae2d5e5751639076e0a3bfad
parent5c6ba6c56f9653488e1d805e727bb06c39ed23fa (diff)
downloadbusybox-16714245f9a16ce3725aab079aea7b0d28c6b32f.zip
busybox-16714245f9a16ce3725aab079aea7b0d28c6b32f.tar.gz
busybox-16714245f9a16ce3725aab079aea7b0d28c6b32f.tar.bz2
add INIT_G()'s. No code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat
-rw-r--r--coreutils/du.c3
-rw-r--r--coreutils/expr.c3
-rw-r--r--coreutils/tail.c3
-rw-r--r--include/libbb.h9
-rw-r--r--miscutils/hdparm.c3
-rw-r--r--networking/zcip.c2
-rw-r--r--procps/top.c2
-rw-r--r--runit/runsvdir.c3
-rw-r--r--util-linux/mdev.c5
-rw-r--r--util-linux/mount.c3
-rw-r--r--util-linux/swaponoff.c3
11 files changed, 33 insertions, 6 deletions
diff --git a/coreutils/du.c b/coreutils/du.c
index b8bbe3d..34a549f 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -88,6 +88,7 @@ struct globals {
dev_t dir_dev;
} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
+#define INIT_G() do { } while (0)
static void print(unsigned long size, const char *filename)
@@ -193,6 +194,8 @@ int du_main(int argc UNUSED_PARAM, char **argv)
int slink_depth_save;
unsigned opt;
+ INIT_G();
+
#if ENABLE_FEATURE_HUMAN_READABLE
IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;)
IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;)
diff --git a/coreutils/expr.c b/coreutils/expr.c
index 24e75b5..c986f93 100644
--- a/coreutils/expr.c
+++ b/coreutils/expr.c
@@ -100,6 +100,7 @@ struct globals {
char **args;
} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
+#define INIT_G() do { } while (0)
/* forward declarations */
static VALUE *eval(void);
@@ -519,6 +520,8 @@ int expr_main(int argc UNUSED_PARAM, char **argv)
{
VALUE *v;
+ INIT_G();
+
xfunc_error_retval = 2; /* coreutils compat */
G.args = argv + 1;
if (*G.args == NULL) {
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 43cecbd..b376ec8 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -62,6 +62,7 @@ struct globals {
bool exitcode;
} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
+#define INIT_G() do { } while (0)
static void tail_xprint_header(const char *fmt, const char *filename)
{
@@ -120,6 +121,8 @@ int tail_main(int argc, char **argv)
int *fds;
const char *fmt;
+ INIT_G();
+
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
/* Allow legacy syntax of an initial numeric option without -n. */
if (argv[1] && (argv[1][0] == '+' || argv[1][0] == '-')
diff --git a/include/libbb.h b/include/libbb.h
index feae852..f79b693 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -684,10 +684,13 @@ void *malloc_or_warn(size_t size) FAST_FUNC RETURNS_MALLOC;
void *xmalloc(size_t size) FAST_FUNC RETURNS_MALLOC;
void *xzalloc(size_t size) FAST_FUNC RETURNS_MALLOC;
void *xrealloc(void *old, size_t size) FAST_FUNC;
-/* After xrealloc_vector(v, 4, idx) it's ok to use
+/* After v = xrealloc_vector(v, SHIFT, idx) it's ok to use
* at least v[idx] and v[idx+1], for all idx values.
- * shift specifies how many new elements are added (1: 2, 2: 4... 8: 256...)
- * when all elements are used up. New elements are zeroed out. */
+ * SHIFT specifies how many new elements are added (1:2, 2:4, ..., 8:256...)
+ * when all elements are used up. New elements are zeroed out.
+ * xrealloc_vector(v, SHIFT, idx) *MUST* be called with consecutive IDXs -
+ * skipping an index is a bad bug - it may miss a realloc!
+ */
#define xrealloc_vector(vector, shift, idx) \
xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx))
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 f30e7de..a97f3e7 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -433,6 +433,7 @@ struct BUG_G_too_big {
#define hwif_data (G.hwif_data )
#define hwif_ctrl (G.hwif_ctrl )
#define hwif_irq (G.hwif_irq )
+#define INIT_G() do { } while (0)
/* Busybox messages and functions */
@@ -2059,6 +2060,8 @@ int hdparm_main(int argc, char **argv)
int c;
int flagcount = 0;
+ INIT_G();
+
while ((c = getopt(argc, argv, hdparm_options)) >= 0) {
flagcount++;
IF_FEATURE_HDPARM_GET_IDENTITY(get_IDentity |= (c == 'I'));
diff --git a/networking/zcip.c b/networking/zcip.c
index 8a35eca..7314ff8 100644
--- a/networking/zcip.c
+++ b/networking/zcip.c
@@ -91,6 +91,7 @@ struct globals {
#define G (*(struct globals*)&bb_common_bufsiz1)
#define saddr (G.saddr )
#define eth_addr (G.eth_addr)
+#define INIT_G() do { } while (0)
/**
@@ -223,6 +224,7 @@ int zcip_main(int argc UNUSED_PARAM, char **argv)
#define verbose (L.verbose )
memset(&L, 0, sizeof(L));
+ INIT_G();
#define FOREGROUND (opts & 1)
#define QUIT (opts & 2)
diff --git a/procps/top.c b/procps/top.c
index 011bbf1..15eb624 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -126,7 +126,6 @@ struct BUG_bad_size {
char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1];
char BUG_line_buf_too_small[LINE_BUF_SIZE > 80 ? 1 : -1];
};
-#define INIT_G() do { } while (0)
#define top (G.top )
#define ntop (G.ntop )
#define sort_field (G.sort_field )
@@ -143,6 +142,7 @@ struct BUG_bad_size {
#define num_cpus (G.num_cpus )
#define total_pcpu (G.total_pcpu )
#define line_buf (G.line_buf )
+#define INIT_G() do { } while (0)
enum {
OPT_d = (1 << 0),
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index 9495a2a..32526cf 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -75,8 +75,7 @@ struct globals {
#define logpipe (G.logpipe )
#define pfd (G.pfd )
#define stamplog (G.stamplog )
-#define INIT_G() do { \
-} while (0)
+#define INIT_G() do { } while (0)
static void fatal2_cannot(const char *m1, const char *m2)
{
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 27b3557..c56741b 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -173,6 +173,8 @@ struct globals {
char *subsystem;
} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
+#define INIT_G() do { } while (0)
+
/* Prevent infinite loops in /sys symlinks */
#define MAX_SYSFS_DEPTH 3
@@ -180,6 +182,7 @@ struct globals {
/* We use additional 64+ bytes in make_device() */
#define SCRATCH_SIZE 80
+
/* Builds an alias path.
* This function potentionally reallocates the alias parameter.
* Only used for ENABLE_FEATURE_MDEV_RENAME
@@ -613,6 +616,8 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
{
RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE);
+ INIT_G();
+
/* We can be called as hotplug helper */
/* Kernel cannot provide suitable stdio fds for us, do it ourself */
bb_sanitize_stdio();
diff --git a/util-linux/mount.c b/util-linux/mount.c
index b51ab17..56276ef 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
#endif
#define fslist (G.fslist )
#define getmntent_buf (G.getmntent_buf )
+#define INIT_G() do { } while (0)
#if ENABLE_FEATURE_MTAB_SUPPORT
/*
@@ -1944,6 +1945,8 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
IF_DESKTOP(int nonroot = ) sanitize_env_if_suid();
+ INIT_G();
+
// Parse long options, like --bind and --move. Note that -o option
// and --option are synonymous. Yes, this means --remount,rw works.
for (i = j = 1; argv[i]; i++) {
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index e53e24c..b3057b3 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -48,6 +48,7 @@ struct globals {
#else
#define g_flags 0
#endif
+#define INIT_G() do { } while (0)
static int swap_enable_disable(char *device)
{
@@ -111,6 +112,8 @@ int swap_on_off_main(int argc UNUSED_PARAM, char **argv)
{
int ret;
+ INIT_G();
+
#if !ENABLE_FEATURE_SWAPON_PRI
ret = getopt32(argv, "a");
#else