add INIT_G()'s. No code changes.
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 20 Sep 2011 23:59:15 +0000 (01:59 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 20 Sep 2011 23:59:15 +0000 (01:59 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/du.c
coreutils/expr.c
coreutils/tail.c
include/libbb.h
miscutils/hdparm.c
networking/zcip.c
procps/top.c
runit/runsvdir.c
util-linux/mdev.c
util-linux/mount.c
util-linux/swaponoff.c

index b8bbe3d9ef10d0550d31fb349da01065e7718d15..34a549f029393d7759aa8eb7ed3e38fc699cd574 100644 (file)
@@ -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;)
index 24e75b5565a8f31985bb9233abd0a8072ebb8141..c986f93274f7e57e4070b135958c10e97df744ce 100644 (file)
@@ -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) {
index 43cecbd97ffd7c08dc7dd54fd137025e6b59350b..b376ec863f0cbfb9fc6d3405dde1e00be6f779fc 100644 (file)
@@ -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] == '-')
index feae85259b65ef60cd0bdac6e014456a677966fa..f79b693656b5d9a371f7e89f899236eb15fe8d46 100644 (file)
@@ -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;
index f30e7dec6b46a669f8b823f3ab5fc0aef5fd0a81..a97f3e7b596e154df1c84f00c9827f5d9810ed21 100644 (file)
@@ -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'));
index 8a35eca5d7202aab14493c60bbf1e6efb49d4972..7314ff8db7509b57f75eef48d50b2ade4cb911bb 100644 (file)
@@ -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)
index 011bbf183a2ee4658df5a839acf30fe05fe7b0fd..15eb624ccee5bbe09e9f62a0fa47cedab6217d0f 100644 (file)
@@ -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),
index 9495a2a4fb52388610d30585c7d197ba69503f80..32526cf4caecb8558fc1186d3638cbda42ada5f5 100644 (file)
@@ -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)
 {
index 27b35572d6765032323c2168f0de75b37ecdef20..c56741b0891eb24177348dfd56187a0782945269 100644 (file)
@@ -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();
index b51ab1782e44387003659ba19950be208c996f18..56276ef01c5244ae3497abfa402fdff5b172c78d 100644 (file)
@@ -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++) {
index e53e24c7103a28c8567c5d220164de5e20702072..b3057b3095b938575470ea3adb68d714a46cf5a6 100644 (file)
@@ -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