add INIT_G()'s. No code changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-09-21 01:59:15 +02:00
parent 5c6ba6c56f
commit 16714245f9
11 changed files with 33 additions and 6 deletions

View File

@ -88,6 +88,7 @@ struct globals {
dev_t dir_dev; dev_t dir_dev;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1) #define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { } while (0)
static void print(unsigned long size, const char *filename) 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; int slink_depth_save;
unsigned opt; unsigned opt;
INIT_G();
#if ENABLE_FEATURE_HUMAN_READABLE #if ENABLE_FEATURE_HUMAN_READABLE
IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;) IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;)
IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;) IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;)

View File

@ -100,6 +100,7 @@ struct globals {
char **args; char **args;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1) #define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { } while (0)
/* forward declarations */ /* forward declarations */
static VALUE *eval(void); static VALUE *eval(void);
@ -519,6 +520,8 @@ int expr_main(int argc UNUSED_PARAM, char **argv)
{ {
VALUE *v; VALUE *v;
INIT_G();
xfunc_error_retval = 2; /* coreutils compat */ xfunc_error_retval = 2; /* coreutils compat */
G.args = argv + 1; G.args = argv + 1;
if (*G.args == NULL) { if (*G.args == NULL) {

View File

@ -62,6 +62,7 @@ struct globals {
bool exitcode; bool exitcode;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1) #define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { } while (0)
static void tail_xprint_header(const char *fmt, const char *filename) static void tail_xprint_header(const char *fmt, const char *filename)
{ {
@ -120,6 +121,8 @@ int tail_main(int argc, char **argv)
int *fds; int *fds;
const char *fmt; const char *fmt;
INIT_G();
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL #if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
/* Allow legacy syntax of an initial numeric option without -n. */ /* Allow legacy syntax of an initial numeric option without -n. */
if (argv[1] && (argv[1][0] == '+' || argv[1][0] == '-') if (argv[1] && (argv[1][0] == '+' || argv[1][0] == '-')

View 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 *xmalloc(size_t size) FAST_FUNC RETURNS_MALLOC;
void *xzalloc(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; 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. * 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...) * 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. */ * 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) \ #define xrealloc_vector(vector, shift, idx) \
xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (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; void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC;

View File

@ -433,6 +433,7 @@ struct BUG_G_too_big {
#define hwif_data (G.hwif_data ) #define hwif_data (G.hwif_data )
#define hwif_ctrl (G.hwif_ctrl ) #define hwif_ctrl (G.hwif_ctrl )
#define hwif_irq (G.hwif_irq ) #define hwif_irq (G.hwif_irq )
#define INIT_G() do { } while (0)
/* Busybox messages and functions */ /* Busybox messages and functions */
@ -2059,6 +2060,8 @@ int hdparm_main(int argc, char **argv)
int c; int c;
int flagcount = 0; int flagcount = 0;
INIT_G();
while ((c = getopt(argc, argv, hdparm_options)) >= 0) { while ((c = getopt(argc, argv, hdparm_options)) >= 0) {
flagcount++; flagcount++;
IF_FEATURE_HDPARM_GET_IDENTITY(get_IDentity |= (c == 'I')); IF_FEATURE_HDPARM_GET_IDENTITY(get_IDentity |= (c == 'I'));

View File

@ -91,6 +91,7 @@ struct globals {
#define G (*(struct globals*)&bb_common_bufsiz1) #define G (*(struct globals*)&bb_common_bufsiz1)
#define saddr (G.saddr ) #define saddr (G.saddr )
#define eth_addr (G.eth_addr) #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 ) #define verbose (L.verbose )
memset(&L, 0, sizeof(L)); memset(&L, 0, sizeof(L));
INIT_G();
#define FOREGROUND (opts & 1) #define FOREGROUND (opts & 1)
#define QUIT (opts & 2) #define QUIT (opts & 2)

View File

@ -126,7 +126,6 @@ struct BUG_bad_size {
char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1];
char BUG_line_buf_too_small[LINE_BUF_SIZE > 80 ? 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 top (G.top )
#define ntop (G.ntop ) #define ntop (G.ntop )
#define sort_field (G.sort_field ) #define sort_field (G.sort_field )
@ -143,6 +142,7 @@ struct BUG_bad_size {
#define num_cpus (G.num_cpus ) #define num_cpus (G.num_cpus )
#define total_pcpu (G.total_pcpu ) #define total_pcpu (G.total_pcpu )
#define line_buf (G.line_buf ) #define line_buf (G.line_buf )
#define INIT_G() do { } while (0)
enum { enum {
OPT_d = (1 << 0), OPT_d = (1 << 0),

View File

@ -75,8 +75,7 @@ struct globals {
#define logpipe (G.logpipe ) #define logpipe (G.logpipe )
#define pfd (G.pfd ) #define pfd (G.pfd )
#define stamplog (G.stamplog ) #define stamplog (G.stamplog )
#define INIT_G() do { \ #define INIT_G() do { } while (0)
} while (0)
static void fatal2_cannot(const char *m1, const char *m2) static void fatal2_cannot(const char *m1, const char *m2)
{ {

View File

@ -173,6 +173,8 @@ struct globals {
char *subsystem; char *subsystem;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1) #define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() do { } while (0)
/* Prevent infinite loops in /sys symlinks */ /* Prevent infinite loops in /sys symlinks */
#define MAX_SYSFS_DEPTH 3 #define MAX_SYSFS_DEPTH 3
@ -180,6 +182,7 @@ struct globals {
/* We use additional 64+ bytes in make_device() */ /* We use additional 64+ bytes in make_device() */
#define SCRATCH_SIZE 80 #define SCRATCH_SIZE 80
/* Builds an alias path. /* Builds an alias path.
* This function potentionally reallocates the alias parameter. * This function potentionally reallocates the alias parameter.
* Only used for ENABLE_FEATURE_MDEV_RENAME * 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); RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE);
INIT_G();
/* We can be called as hotplug helper */ /* We can be called as hotplug helper */
/* Kernel cannot provide suitable stdio fds for us, do it ourself */ /* Kernel cannot provide suitable stdio fds for us, do it ourself */
bb_sanitize_stdio(); bb_sanitize_stdio();

View File

@ -339,6 +339,7 @@ enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_b
#endif #endif
#define fslist (G.fslist ) #define fslist (G.fslist )
#define getmntent_buf (G.getmntent_buf ) #define getmntent_buf (G.getmntent_buf )
#define INIT_G() do { } while (0)
#if ENABLE_FEATURE_MTAB_SUPPORT #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(); IF_DESKTOP(int nonroot = ) sanitize_env_if_suid();
INIT_G();
// Parse long options, like --bind and --move. Note that -o option // Parse long options, like --bind and --move. Note that -o option
// and --option are synonymous. Yes, this means --remount,rw works. // and --option are synonymous. Yes, this means --remount,rw works.
for (i = j = 1; argv[i]; i++) { for (i = j = 1; argv[i]; i++) {

View File

@ -48,6 +48,7 @@ struct globals {
#else #else
#define g_flags 0 #define g_flags 0
#endif #endif
#define INIT_G() do { } while (0)
static int swap_enable_disable(char *device) static int swap_enable_disable(char *device)
{ {
@ -111,6 +112,8 @@ int swap_on_off_main(int argc UNUSED_PARAM, char **argv)
{ {
int ret; int ret;
INIT_G();
#if !ENABLE_FEATURE_SWAPON_PRI #if !ENABLE_FEATURE_SWAPON_PRI
ret = getopt32(argv, "a"); ret = getopt32(argv, "a");
#else #else