*: add most of the required setup_common_bufsiz() calls

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2016-04-21 18:18:48 +02:00
parent e6a2f4cc5a
commit 47cfbf32fd
53 changed files with 63 additions and 19 deletions

View File

@ -174,6 +174,7 @@ struct globals {
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
void BUG_cpio_globals_too_big(void); void BUG_cpio_globals_too_big(void);
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
G.owner_ugid.uid = -1L; \ G.owner_ugid.uid = -1L; \
G.owner_ugid.gid = -1L; \ G.owner_ugid.gid = -1L; \
} while (0) } while (0)

View File

@ -445,7 +445,7 @@ struct globals {
chksum_t chksum_out; chksum_t chksum_out;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
//#define G (*ptr_to_globals) //#define G (*ptr_to_globals)
//#define INIT_G() do { //#define INIT_G() do {
// SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); // SET_PTR_TO_GLOBALS(xzalloc(sizeof(G)));

View File

@ -95,7 +95,7 @@ struct globals {
int tagcount; int tagcount;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
static void extract_cpio(int fd, const char *source_rpm) static void extract_cpio(int fd, const char *source_rpm)
{ {

View File

@ -19,6 +19,7 @@
#define ESC "\033" #define ESC "\033"
#define old_termios_p ((struct termios*)bb_common_bufsiz1) #define old_termios_p ((struct termios*)bb_common_bufsiz1)
#define INIT_G() do { setup_common_bufsiz(); } while (0)
static void static void
onintr(int sig UNUSED_PARAM) onintr(int sig UNUSED_PARAM)
@ -34,6 +35,8 @@ int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
struct winsize w = { 0, 0, 0, 0 }; struct winsize w = { 0, 0, 0, 0 };
int ret; int ret;
INIT_G();
/* We use _stderr_ in order to make resize usable /* We use _stderr_ in order to make resize usable
* in shell backticks (those redirect stdout away from tty). * in shell backticks (those redirect stdout away from tty).
* NB: other versions of resize open "/dev/tty" * NB: other versions of resize open "/dev/tty"

View File

@ -111,6 +111,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
/* we have to zero it out because of NOEXEC */ \ /* we have to zero it out because of NOEXEC */ \
memset(&G, 0, sizeof(G)); \ memset(&G, 0, sizeof(G)); \
} while (0) } while (0)

View File

@ -87,7 +87,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) #define INIT_G() do { setup_common_bufsiz(); } while (0)
static void print(unsigned long long size, const char *filename) static void print(unsigned long long size, const char *filename)

View File

@ -101,7 +101,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) #define INIT_G() do { setup_common_bufsiz(); } while (0)
/* forward declarations */ /* forward declarations */
static VALUE *eval(void); static VALUE *eval(void);

View File

@ -368,6 +368,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
/* we have to zero it out because of NOEXEC */ \ /* we have to zero it out because of NOEXEC */ \
memset(&G, 0, sizeof(G)); \ memset(&G, 0, sizeof(G)); \
IF_FEATURE_AUTOWIDTH(G_terminal_width = TERMINAL_WIDTH;) \ IF_FEATURE_AUTOWIDTH(G_terminal_width = TERMINAL_WIDTH;) \

View File

@ -217,6 +217,7 @@ enum { G_pseudo_offset = 0 };
#endif #endif
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
G.bytes_per_block = 32; \ G.bytes_per_block = 32; \
} while (0) } while (0)

View File

@ -56,7 +56,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) #define INIT_G() do { setup_common_bufsiz(); } while (0)
static void tail_xprint_header(const char *fmt, const char *filename) static void tail_xprint_header(const char *fmt, const char *filename)
{ {

View File

@ -100,7 +100,7 @@ struct globals {
#define names (G.names) #define names (G.names)
#define cur (G.cur ) #define cur (G.cur )
#define cmd (G.cmd ) #define cmd (G.cmd )
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 }; enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };

View File

@ -200,6 +200,7 @@ struct globals {
#define user_id (G.user_id ) #define user_id (G.user_id )
#define signal_nr (G.signal_nr ) #define signal_nr (G.signal_nr )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
user_id = -1; \ user_id = -1; \
signal_nr = 15; \ signal_nr = 15; \
} while (0) } while (0)

View File

@ -172,6 +172,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0) } while (0)

View File

@ -164,6 +164,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
G.sed_cmd_tail = &G.sed_cmd_head; \ G.sed_cmd_tail = &G.sed_cmd_head; \
} while (0) } while (0)

View File

@ -424,6 +424,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
/* we have to zero it out because of NOEXEC */ \ /* we have to zero it out because of NOEXEC */ \
memset(&G, 0, sizeof(G)); \ memset(&G, 0, sizeof(G)); \

View File

@ -204,6 +204,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0) } while (0)
#define max_matches (G.max_matches ) #define max_matches (G.max_matches )

View File

@ -103,6 +103,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
G.eof_str = NULL; /* need to clear by hand because we are NOEXEC applet */ \ G.eof_str = NULL; /* need to clear by hand because we are NOEXEC applet */ \
IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.repl_str = "{}";) \ IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.repl_str = "{}";) \
IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.eol_ch = '\n';) \ IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.eol_ch = '\n';) \

View File

@ -117,7 +117,7 @@ struct globals {
char jiffy_line[COMMON_BUFSIZE]; char jiffy_line[COMMON_BUFSIZE];
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
static void dump_file(FILE *fp, const char *filename) static void dump_file(FILE *fp, const char *filename)
{ {

View File

@ -140,7 +140,7 @@ struct globals {
struct termios tty_attrs; struct termios tty_attrs;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
#if ENABLE_FEATURE_NOLOGIN #if ENABLE_FEATURE_NOLOGIN

View File

@ -143,6 +143,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
G.log_level = 8; \ G.log_level = 8; \
G.crontab_dir_name = CRONTABS; \ G.crontab_dir_name = CRONTABS; \
} while (0) } while (0)

View File

@ -53,6 +53,7 @@ enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(
#define base (G.base ) #define base (G.base )
#define stack (G.stack ) #define stack (G.stack )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
base = 10; \ base = 10; \
} while (0) } while (0)

View File

@ -432,6 +432,7 @@ struct globals {
#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 { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0) } while (0)

View File

@ -76,6 +76,7 @@ struct globals {
#define device (G.device ) #define device (G.device )
#define hw_set (G.hw_set ) #define hw_set (G.hw_set )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
device = ""; \ device = ""; \
} while (0) } while (0)

View File

@ -77,6 +77,7 @@ struct globals {
#define brd_recv (G.brd_recv ) #define brd_recv (G.brd_recv )
#define req_recv (G.req_recv ) #define req_recv (G.req_recv )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
count = -1; \ count = -1; \
} while (0) } while (0)

View File

@ -126,6 +126,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
/* Moved to main */ \ /* Moved to main */ \
/*strcpy(G.msg_ok + 4, MSG_OK );*/ \ /*strcpy(G.msg_ok + 4, MSG_OK );*/ \
/*strcpy(G.msg_err + 4, MSG_ERR);*/ \ /*strcpy(G.msg_err + 4, MSG_ERR);*/ \

View File

@ -71,6 +71,7 @@ enum { BUFSZ = COMMON_BUFSIZE - offsetof(struct globals, buf) };
#define do_continue (G.do_continue ) #define do_continue (G.do_continue )
#define buf (G.buf ) #define buf (G.buf )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0) } while (0)

View File

@ -131,7 +131,7 @@ struct globals {
char *shell; char *shell;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
static const char keywords_up_down[] ALIGN1 = static const char keywords_up_down[] ALIGN1 =

View File

@ -350,6 +350,7 @@ enum { LINE_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line) };
#define allsock (G.allsock ) #define allsock (G.allsock )
#define line (G.line ) #define line (G.line )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
rlim_ofile_cur = OPEN_MAX; \ rlim_ofile_cur = OPEN_MAX; \
global_queuelen = 128; \ global_queuelen = 128; \

View File

@ -188,7 +188,7 @@ struct globals {
char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN]; char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
static void noresp(int ign UNUSED_PARAM) static void noresp(int ign UNUSED_PARAM)
{ {
@ -398,6 +398,7 @@ struct globals {
#define pingaddr (G.pingaddr ) #define pingaddr (G.pingaddr )
#define rcvd_tbl (G.rcvd_tbl ) #define rcvd_tbl (G.rcvd_tbl )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
datalen = DEFDATALEN; \ datalen = DEFDATALEN; \
timeout = MAXWAIT; \ timeout = MAXWAIT; \

View File

@ -39,7 +39,7 @@ struct globals {
#define handle (G.handle ) #define handle (G.handle )
#define saved_disc (G.saved_disc ) #define saved_disc (G.saved_disc )
#define saved_state (G.saved_state ) #define saved_state (G.saved_state )
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
/* /*

View File

@ -71,6 +71,7 @@ struct globals {
#define filter_prio (G.filter_prio) #define filter_prio (G.filter_prio)
#define filter_proto (G.filter_proto) #define filter_proto (G.filter_proto)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0) } while (0)

View File

@ -101,6 +101,7 @@ struct globals {
#define env_cur (G.env_cur ) #define env_cur (G.env_cur )
#define env_var (G.env_var ) #define env_var (G.env_var )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
cmax = 30; \ cmax = 30; \
env_cur = &env_var[0]; \ env_cur = &env_var[0]; \
} while (0) } while (0)

View File

@ -111,6 +111,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0) } while (0)

View File

@ -85,6 +85,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
G.loginpath = "/bin/login"; \ G.loginpath = "/bin/login"; \
G.issuefile = "/etc/issue.net"; \ G.issuefile = "/etc/issue.net"; \
} while (0) } while (0)

View File

@ -131,6 +131,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0) } while (0)

View File

@ -34,6 +34,7 @@ struct xid_item {
} FIX_ALIASING; } FIX_ALIASING;
#define dhcprelay_xid_list (*(struct xid_item*)bb_common_bufsiz1) #define dhcprelay_xid_list (*(struct xid_item*)bb_common_bufsiz1)
#define INIT_G() do { setup_common_bufsiz(); } while (0)
static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client) static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client)
{ {
@ -257,6 +258,8 @@ int dhcprelay_main(int argc, char **argv)
int num_sockets, max_socket; int num_sockets, max_socket;
uint32_t our_nip; uint32_t our_nip;
INIT_G();
server_addr.sin_family = AF_INET; server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST); server_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
server_addr.sin_port = htons(SERVER_PORT); server_addr.sin_port = htons(SERVER_PORT);

View File

@ -92,7 +92,7 @@ struct globals {
uint32_t localnet_ip; uint32_t localnet_ip;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
/** /**

View File

@ -37,7 +37,7 @@ struct globals {
#endif #endif
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
static unsigned long long scale(unsigned long d) static unsigned long long scale(unsigned long d)

View File

@ -46,6 +46,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
G.mypid = getpid(); \ G.mypid = getpid(); \
G.killsig = SIGKILL; \ G.killsig = SIGKILL; \
} while (0) } while (0)

View File

@ -153,7 +153,7 @@ struct globals {
#define buffer (G.buffer ) #define buffer (G.buffer )
#define terminal_width (G.terminal_width ) #define terminal_width (G.terminal_width )
#define kernel_HZ (G.kernel_HZ ) #define kernel_HZ (G.kernel_HZ )
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
#if ENABLE_FEATURE_PS_TIME #if ENABLE_FEATURE_PS_TIME
/* for ELF executables, notes are pushed before environment and args */ /* for ELF executables, notes are pushed before environment and args */

View File

@ -202,6 +202,7 @@ enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) };
#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 { \ #define INIT_G() do { \
setup_common_bufsiz(); \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
BUILD_BUG_ON(LINE_BUF_SIZE <= 80); \ BUILD_BUG_ON(LINE_BUF_SIZE <= 80); \
} while (0) } while (0)

View File

@ -115,6 +115,7 @@ struct globals {
#define dir (G.dir ) #define dir (G.dir )
#define svd (G.svd ) #define svd (G.svd )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
pidchanged = 1; \ pidchanged = 1; \
} while (0) } while (0)

View File

@ -93,7 +93,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 { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
static void fatal2_cannot(const char *m1, const char *m2) static void fatal2_cannot(const char *m1, const char *m2)
{ {

View File

@ -207,7 +207,7 @@ struct globals {
#define tstart (G.tstart ) #define tstart (G.tstart )
#define tnow (G.tnow ) #define tnow (G.tnow )
#define svstatus (G.svstatus ) #define svstatus (G.svstatus )
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
#define str_equal(s,t) (!strcmp((s), (t))) #define str_equal(s,t) (!strcmp((s), (t)))

View File

@ -111,4 +111,6 @@ fi
if test $OLD != $REM; then if test $OLD != $REM; then
echo "Space in _end[] is $REM bytes. Rerun make to use larger COMMON_BUFSIZE." echo "Space in _end[] is $REM bytes. Rerun make to use larger COMMON_BUFSIZE."
else
echo "COMMON_BUFSIZE = $REM bytes"
fi fi

View File

@ -80,6 +80,7 @@ struct globals {
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
void BUG_setfiles_globals_too_big(void); void BUG_setfiles_globals_too_big(void);
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
if (sizeof(G) > COMMON_BUFSIZE) \ if (sizeof(G) > COMMON_BUFSIZE) \
BUG_setfiles_globals_too_big(); \ BUG_setfiles_globals_too_big(); \
/* memset(&G, 0, sizeof(G)); - already is */ \ /* memset(&G, 0, sizeof(G)); - already is */ \

View File

@ -73,6 +73,7 @@ struct globals {
#define SMrdn (G.SMrdn) #define SMrdn (G.SMrdn)
#define shbuf (G.shbuf) #define shbuf (G.shbuf)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
memcpy(SMrup, init_sem, sizeof(init_sem)); \ memcpy(SMrup, init_sem, sizeof(init_sem)); \
} while (0) } while (0)

View File

@ -288,6 +288,7 @@ struct globals {
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.maj = -1;) \ IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.maj = -1;) \
IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.mode = 0660;) \ IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.mode = 0660;) \
} while (0) } while (0)

View File

@ -76,6 +76,7 @@ struct swap_header_v1 {
#define NWORDS 129 #define NWORDS 129
#define hdr ((struct swap_header_v1*)bb_common_bufsiz1) #define hdr ((struct swap_header_v1*)bb_common_bufsiz1)
#define INIT_G() do { setup_common_bufsiz(); } while (0)
struct BUG_sizes { struct BUG_sizes {
char swap_header_v1_wrong[sizeof(*hdr) != (NWORDS * 4) ? -1 : 1]; char swap_header_v1_wrong[sizeof(*hdr) != (NWORDS * 4) ? -1 : 1];
@ -93,6 +94,8 @@ int mkswap_main(int argc UNUSED_PARAM, char **argv)
off_t len; off_t len;
const char *label = ""; const char *label = "";
INIT_G();
opt_complementary = "-1"; /* at least one param */ opt_complementary = "-1"; /* at least one param */
/* TODO: -p PAGESZ, -U UUID */ /* TODO: -p PAGESZ, -U UUID */
getopt32(argv, "L:", &label); getopt32(argv, "L:", &label);

View File

@ -33,10 +33,10 @@ struct globals {
struct termios new_settings; struct termios new_settings;
} FIX_ALIASING; } FIX_ALIASING;
#define G (*(struct globals*)bb_common_bufsiz1) #define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() ((void)0)
#define initial_settings (G.initial_settings) #define initial_settings (G.initial_settings)
#define new_settings (G.new_settings ) #define new_settings (G.new_settings )
#define cin_fileno (G.cin_fileno ) #define cin_fileno (G.cin_fileno )
#define INIT_G() do { setup_common_bufsiz(); } while (0)
#define setTermSettings(fd, argp) \ #define setTermSettings(fd, argp) \
do { \ do { \

View File

@ -457,7 +457,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) #define INIT_G() do { setup_common_bufsiz(); } while (0)
#if ENABLE_FEATURE_MTAB_SUPPORT #if ENABLE_FEATURE_MTAB_SUPPORT
/* /*

View File

@ -72,7 +72,7 @@ struct globals {
#define save_g_flags() ((void)0) #define save_g_flags() ((void)0)
#define restore_g_flags() ((void)0) #define restore_g_flags() ((void)0)
#endif #endif
#define INIT_G() do { } while (0) #define INIT_G() do { setup_common_bufsiz(); } while (0)
#define do_swapoff (applet_name[5] == 'f') #define do_swapoff (applet_name[5] == 'f')

View File

@ -31,6 +31,7 @@
#define BUFFER_SIZE 16*1024 #define BUFFER_SIZE 16*1024
#define env ((char **)bb_common_bufsiz1) #define env ((char **)bb_common_bufsiz1)
#define INIT_G() do { setup_common_bufsiz(); } while (0)
enum { enum {
MAX_ENV = COMMON_BUFSIZE / sizeof(env[0]) - 1, MAX_ENV = COMMON_BUFSIZE / sizeof(env[0]) - 1,
}; };
@ -46,6 +47,8 @@ int uevent_main(int argc UNUSED_PARAM, char **argv)
struct sockaddr_nl sa; struct sockaddr_nl sa;
int fd; int fd;
INIT_G();
argv++; argv++;
// Subscribe for UEVENT kernel messages // Subscribe for UEVENT kernel messages