aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-30 02:39:57 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-30 02:39:57 +0200
commit1b34d4f0b1d634eb8219d52c693fa80b99ed1bfa (patch)
tree1fa51b9580409d4fa8de86bf8c9b2ab083caf10d
parentc34c033c4256f88e759c5f7a59526b4397852a82 (diff)
downloadbusybox-w32-1b34d4f0b1d634eb8219d52c693fa80b99ed1bfa.tar.gz
busybox-w32-1b34d4f0b1d634eb8219d52c693fa80b99ed1bfa.tar.bz2
busybox-w32-1b34d4f0b1d634eb8219d52c693fa80b99ed1bfa.zip
find: add zeroing of G.xxx; ftpd - remove extraneous zeroing of G.xxx
Brought "G trick" to the same shape in a few more places. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/dd.c6
-rw-r--r--coreutils/ls.c12
-rw-r--r--findutils/find.c2
-rw-r--r--networking/ftpd.c4
-rw-r--r--networking/telnet.c7
5 files changed, 17 insertions, 14 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 627e7e7b5..c5c9476af 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -36,8 +36,10 @@ struct globals {
36 off_t out_full, out_part, in_full, in_part; 36 off_t out_full, out_part, in_full, in_part;
37}; 37};
38#define G (*(struct globals*)&bb_common_bufsiz1) 38#define G (*(struct globals*)&bb_common_bufsiz1)
39/* We have to zero it out because of NOEXEC */ 39#define INIT_G() do { \
40#define INIT_G() memset(&G, 0, sizeof(G)) 40 /* we have to zero it out because of NOEXEC */ \
41 memset(&G, 0, sizeof(G)); \
42} while (0)
41 43
42 44
43static void dd_output_status(int UNUSED_PARAM cur_signal) 45static void dd_output_status(int UNUSED_PARAM cur_signal)
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 827b35089..19d38049c 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -264,15 +264,15 @@ struct globals {
264}; 264};
265#define G (*(struct globals*)&bb_common_bufsiz1) 265#define G (*(struct globals*)&bb_common_bufsiz1)
266#if ENABLE_FEATURE_LS_COLOR 266#if ENABLE_FEATURE_LS_COLOR
267#define show_color (G.show_color ) 267# define show_color (G.show_color )
268#else 268#else
269enum { show_color = 0 }; 269enum { show_color = 0 };
270#endif 270#endif
271#define exit_code (G.exit_code ) 271#define exit_code (G.exit_code )
272#define all_fmt (G.all_fmt ) 272#define all_fmt (G.all_fmt )
273#if ENABLE_FEATURE_AUTOWIDTH 273#if ENABLE_FEATURE_AUTOWIDTH
274#define tabstops (G.tabstops ) 274# define tabstops (G.tabstops )
275#define terminal_width (G.terminal_width) 275# define terminal_width (G.terminal_width)
276#else 276#else
277enum { 277enum {
278 tabstops = COLUMN_GAP, 278 tabstops = COLUMN_GAP,
@@ -280,8 +280,8 @@ enum {
280}; 280};
281#endif 281#endif
282#define current_time_t (G.current_time_t) 282#define current_time_t (G.current_time_t)
283/* memset: we have to zero it out because of NOEXEC */
284#define INIT_G() do { \ 283#define INIT_G() do { \
284 /* we have to zero it out because of NOEXEC */ \
285 memset(&G, 0, sizeof(G)); \ 285 memset(&G, 0, sizeof(G)); \
286 IF_FEATURE_AUTOWIDTH(tabstops = COLUMN_GAP;) \ 286 IF_FEATURE_AUTOWIDTH(tabstops = COLUMN_GAP;) \
287 IF_FEATURE_AUTOWIDTH(terminal_width = TERMINAL_WIDTH;) \ 287 IF_FEATURE_AUTOWIDTH(terminal_width = TERMINAL_WIDTH;) \
diff --git a/findutils/find.c b/findutils/find.c
index 6f7be4fc2..76cd18c1a 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -109,6 +109,8 @@ struct globals {
109 struct G_sizecheck { \ 109 struct G_sizecheck { \
110 char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \ 110 char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \
111 }; \ 111 }; \
112 /* we have to zero it out because of NOEXEC */ \
113 memset(&G, 0, offsetof(struct globals, need_print)); \
112 G.need_print = 1; \ 114 G.need_print = 1; \
113 G.recurse_flags = ACTION_RECURSE; \ 115 G.recurse_flags = ACTION_RECURSE; \
114} while (0) 116} while (0)
diff --git a/networking/ftpd.c b/networking/ftpd.c
index a8687fbda..70a353312 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -662,7 +662,7 @@ popen_ls(const char *opt)
662 execv(bb_busybox_exec_path + 1, (char**) argv); 662 execv(bb_busybox_exec_path + 1, (char**) argv);
663 _exit(127); 663 _exit(127);
664#else 664#else
665 memset(&G, 0, sizeof(G)); 665 /* memset(&G, 0, sizeof(G)); - ls_main does it */
666 exit(ls_main(ARRAY_SIZE(argv) - 1, (char**) argv)); 666 exit(ls_main(ARRAY_SIZE(argv) - 1, (char**) argv));
667#endif 667#endif
668 } 668 }
@@ -1114,7 +1114,7 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
1114/* --group-directories-first would be nice, but ls don't do that yet */ 1114/* --group-directories-first would be nice, but ls don't do that yet */
1115 xchdir(argv[2]); 1115 xchdir(argv[2]);
1116 argv[2] = (char*)"--"; 1116 argv[2] = (char*)"--";
1117 memset(&G, 0, sizeof(G)); 1117 /* memset(&G, 0, sizeof(G)); - ls_main does it */
1118 return ls_main(argc, argv); 1118 return ls_main(argc, argv);
1119 } 1119 }
1120#endif 1120#endif
diff --git a/networking/telnet.c b/networking/telnet.c
index cc994250c..77e17479d 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -77,11 +77,10 @@ struct globals {
77 struct termios termios_raw; 77 struct termios termios_raw;
78}; 78};
79#define G (*(struct globals*)&bb_common_bufsiz1) 79#define G (*(struct globals*)&bb_common_bufsiz1)
80void BUG_telnet_globals_too_big(void);
81#define INIT_G() do { \ 80#define INIT_G() do { \
82 if (sizeof(G) > COMMON_BUFSIZE) \ 81 struct G_sizecheck { \
83 BUG_telnet_globals_too_big(); \ 82 char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \
84 /* memset(&G, 0, sizeof G); - already is */ \ 83 }; \
85} while (0) 84} while (0)
86 85
87/* Function prototypes */ 86/* Function prototypes */