diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-13 17:17:34 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-13 17:17:34 +0200 |
commit | 7b85ec30b5941f0b90c48a990f2f6840aca87bce (patch) | |
tree | 3565032bf3f34eeea195258d9d4edc9f01480e6e | |
parent | 4d0c1ea4784c9844f8468d97ca5c26d3c70f9921 (diff) | |
download | busybox-w32-7b85ec30b5941f0b90c48a990f2f6840aca87bce.tar.gz busybox-w32-7b85ec30b5941f0b90c48a990f2f6840aca87bce.tar.bz2 busybox-w32-7b85ec30b5941f0b90c48a990f2f6840aca87bce.zip |
*: more BUILD_BUG_ON conversions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/libarchive/decompress_gunzip.c | 5 | ||||
-rw-r--r-- | editors/sed.c | 10 | ||||
-rw-r--r-- | findutils/find.c | 4 | ||||
-rw-r--r-- | findutils/grep.c | 4 | ||||
-rw-r--r-- | miscutils/hdparm.c | 7 | ||||
-rw-r--r-- | miscutils/taskset.c | 6 | ||||
-rw-r--r-- | networking/inetd.c | 4 | ||||
-rw-r--r-- | networking/nbd-client.c | 5 | ||||
-rw-r--r-- | networking/telnet.c | 4 | ||||
-rw-r--r-- | procps/top.c | 9 |
10 files changed, 22 insertions, 36 deletions
diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c index 1360abef7..7b6f45934 100644 --- a/archival/libarchive/decompress_gunzip.c +++ b/archival/libarchive/decompress_gunzip.c | |||
@@ -1118,9 +1118,8 @@ static int check_header_gzip(STATE_PARAM transformer_state_t *xstate) | |||
1118 | uint8_t os_flags_UNUSED; | 1118 | uint8_t os_flags_UNUSED; |
1119 | } PACKED formatted; | 1119 | } PACKED formatted; |
1120 | } header; | 1120 | } header; |
1121 | struct BUG_header { | 1121 | |
1122 | char BUG_header[sizeof(header) == 8 ? 1 : -1]; | 1122 | BUILD_BUG_ON(sizeof(header) != 8); |
1123 | }; | ||
1124 | 1123 | ||
1125 | /* | 1124 | /* |
1126 | * Rewind bytebuffer. We use the beginning because the header has 8 | 1125 | * Rewind bytebuffer. We use the beginning because the header has 8 |
diff --git a/editors/sed.c b/editors/sed.c index 7bbf820d8..a8c35388b 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -162,10 +162,8 @@ struct globals { | |||
162 | } pipeline; | 162 | } pipeline; |
163 | } FIX_ALIASING; | 163 | } FIX_ALIASING; |
164 | #define G (*(struct globals*)&bb_common_bufsiz1) | 164 | #define G (*(struct globals*)&bb_common_bufsiz1) |
165 | struct BUG_G_too_big { | ||
166 | char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; | ||
167 | }; | ||
168 | #define INIT_G() do { \ | 165 | #define INIT_G() do { \ |
166 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | ||
169 | G.sed_cmd_tail = &G.sed_cmd_head; \ | 167 | G.sed_cmd_tail = &G.sed_cmd_head; \ |
170 | } while (0) | 168 | } while (0) |
171 | 169 | ||
@@ -501,9 +499,11 @@ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr) | |||
501 | IDX_rbrace, | 499 | IDX_rbrace, |
502 | IDX_nul | 500 | IDX_nul |
503 | }; | 501 | }; |
504 | struct chk { char chk[sizeof(cmd_letters)-1 == IDX_nul ? 1 : -1]; }; | 502 | unsigned idx; |
503 | |||
504 | BUILD_BUG_ON(sizeof(cmd_letters)-1 != IDX_nul); | ||
505 | 505 | ||
506 | unsigned idx = strchrnul(cmd_letters, sed_cmd->cmd) - cmd_letters; | 506 | idx = strchrnul(cmd_letters, sed_cmd->cmd) - cmd_letters; |
507 | 507 | ||
508 | /* handle (s)ubstitution command */ | 508 | /* handle (s)ubstitution command */ |
509 | if (idx == IDX_s) { | 509 | if (idx == IDX_s) { |
diff --git a/findutils/find.c b/findutils/find.c index bd7ccc323..5bd753536 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -423,9 +423,7 @@ struct globals { | |||
423 | } FIX_ALIASING; | 423 | } FIX_ALIASING; |
424 | #define G (*(struct globals*)&bb_common_bufsiz1) | 424 | #define G (*(struct globals*)&bb_common_bufsiz1) |
425 | #define INIT_G() do { \ | 425 | #define INIT_G() do { \ |
426 | struct G_sizecheck { \ | 426 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
427 | char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \ | ||
428 | }; \ | ||
429 | /* we have to zero it out because of NOEXEC */ \ | 427 | /* we have to zero it out because of NOEXEC */ \ |
430 | memset(&G, 0, sizeof(G)); \ | 428 | memset(&G, 0, sizeof(G)); \ |
431 | IF_FEATURE_FIND_MAXDEPTH(G.minmaxdepth[1] = INT_MAX;) \ | 429 | IF_FEATURE_FIND_MAXDEPTH(G.minmaxdepth[1] = INT_MAX;) \ |
diff --git a/findutils/grep.c b/findutils/grep.c index b9621384e..10b69275a 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -203,9 +203,7 @@ struct globals { | |||
203 | } FIX_ALIASING; | 203 | } FIX_ALIASING; |
204 | #define G (*(struct globals*)&bb_common_bufsiz1) | 204 | #define G (*(struct globals*)&bb_common_bufsiz1) |
205 | #define INIT_G() do { \ | 205 | #define INIT_G() do { \ |
206 | struct G_sizecheck { \ | 206 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
207 | char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \ | ||
208 | }; \ | ||
209 | } while (0) | 207 | } while (0) |
210 | #define max_matches (G.max_matches ) | 208 | #define max_matches (G.max_matches ) |
211 | #if !ENABLE_EXTRA_COMPAT | 209 | #if !ENABLE_EXTRA_COMPAT |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 9c486e7aa..8e201ac35 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -368,9 +368,6 @@ struct globals { | |||
368 | #endif | 368 | #endif |
369 | } FIX_ALIASING; | 369 | } FIX_ALIASING; |
370 | #define G (*(struct globals*)&bb_common_bufsiz1) | 370 | #define G (*(struct globals*)&bb_common_bufsiz1) |
371 | struct BUG_G_too_big { | ||
372 | char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; | ||
373 | }; | ||
374 | #define get_identity (G.get_identity ) | 371 | #define get_identity (G.get_identity ) |
375 | #define get_geom (G.get_geom ) | 372 | #define get_geom (G.get_geom ) |
376 | #define do_flush (G.do_flush ) | 373 | #define do_flush (G.do_flush ) |
@@ -433,7 +430,9 @@ struct BUG_G_too_big { | |||
433 | #define hwif_data (G.hwif_data ) | 430 | #define hwif_data (G.hwif_data ) |
434 | #define hwif_ctrl (G.hwif_ctrl ) | 431 | #define hwif_ctrl (G.hwif_ctrl ) |
435 | #define hwif_irq (G.hwif_irq ) | 432 | #define hwif_irq (G.hwif_irq ) |
436 | #define INIT_G() do { } while (0) | 433 | #define INIT_G() do { \ |
434 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | ||
435 | } while (0) | ||
437 | 436 | ||
438 | 437 | ||
439 | /* Busybox messages and functions */ | 438 | /* Busybox messages and functions */ |
diff --git a/miscutils/taskset.c b/miscutils/taskset.c index 2646e1dab..100b1d926 100644 --- a/miscutils/taskset.c +++ b/miscutils/taskset.c | |||
@@ -75,12 +75,10 @@ static char *from_cpuset(cpu_set_t *mask) | |||
75 | #define TASKSET_PRINTF_MASK "%llx" | 75 | #define TASKSET_PRINTF_MASK "%llx" |
76 | static unsigned long long from_cpuset(cpu_set_t *mask) | 76 | static unsigned long long from_cpuset(cpu_set_t *mask) |
77 | { | 77 | { |
78 | struct BUG_CPU_SETSIZE_is_too_small { | ||
79 | char BUG_CPU_SETSIZE_is_too_small[ | ||
80 | CPU_SETSIZE < sizeof(int) ? -1 : 1]; | ||
81 | }; | ||
82 | char *p = (void*)mask; | 78 | char *p = (void*)mask; |
83 | 79 | ||
80 | BUILD_BUG_ON(CPU_SETSIZE < sizeof(int)); | ||
81 | |||
84 | /* Take the least significant bits. Careful! | 82 | /* Take the least significant bits. Careful! |
85 | * Consider both CPU_SETSIZE=4 and CPU_SETSIZE=1024 cases | 83 | * Consider both CPU_SETSIZE=4 and CPU_SETSIZE=1024 cases |
86 | */ | 84 | */ |
diff --git a/networking/inetd.c b/networking/inetd.c index dce5a0885..243165a07 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -329,9 +329,6 @@ struct globals { | |||
329 | } FIX_ALIASING; | 329 | } FIX_ALIASING; |
330 | #define G (*(struct globals*)&bb_common_bufsiz1) | 330 | #define G (*(struct globals*)&bb_common_bufsiz1) |
331 | enum { LINE_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line) }; | 331 | enum { LINE_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line) }; |
332 | struct BUG_G_too_big { | ||
333 | char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; | ||
334 | }; | ||
335 | #define rlim_ofile_cur (G.rlim_ofile_cur ) | 332 | #define rlim_ofile_cur (G.rlim_ofile_cur ) |
336 | #define rlim_ofile (G.rlim_ofile ) | 333 | #define rlim_ofile (G.rlim_ofile ) |
337 | #define serv_list (G.serv_list ) | 334 | #define serv_list (G.serv_list ) |
@@ -352,6 +349,7 @@ struct BUG_G_too_big { | |||
352 | #define allsock (G.allsock ) | 349 | #define allsock (G.allsock ) |
353 | #define line (G.line ) | 350 | #define line (G.line ) |
354 | #define INIT_G() do { \ | 351 | #define INIT_G() do { \ |
352 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | ||
355 | rlim_ofile_cur = OPEN_MAX; \ | 353 | rlim_ofile_cur = OPEN_MAX; \ |
356 | global_queuelen = 128; \ | 354 | global_queuelen = 128; \ |
357 | config_filename = "/etc/inetd.conf"; \ | 355 | config_filename = "/etc/inetd.conf"; \ |
diff --git a/networking/nbd-client.c b/networking/nbd-client.c index a601430b6..70869d651 100644 --- a/networking/nbd-client.c +++ b/networking/nbd-client.c | |||
@@ -57,9 +57,8 @@ int nbdclient_main(int argc, char **argv) | |||
57 | uint32_t flags; | 57 | uint32_t flags; |
58 | char data[124]; | 58 | char data[124]; |
59 | } nbd_header; | 59 | } nbd_header; |
60 | struct bug_check { | 60 | |
61 | char c[offsetof(struct nbd_header_t, data) == 8+8+8+4 ? 1 : -1]; | 61 | BUILD_BUG_ON(offsetof(struct nbd_header_t, data) != 8+8+8+4); |
62 | }; | ||
63 | 62 | ||
64 | // Parse command line stuff (just a stub now) | 63 | // Parse command line stuff (just a stub now) |
65 | if (argc != 4) | 64 | if (argc != 4) |
diff --git a/networking/telnet.c b/networking/telnet.c index 3bb6fb1ba..944cf1bd6 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -110,9 +110,7 @@ struct globals { | |||
110 | } FIX_ALIASING; | 110 | } FIX_ALIASING; |
111 | #define G (*(struct globals*)&bb_common_bufsiz1) | 111 | #define G (*(struct globals*)&bb_common_bufsiz1) |
112 | #define INIT_G() do { \ | 112 | #define INIT_G() do { \ |
113 | struct G_sizecheck { \ | 113 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
114 | char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \ | ||
115 | }; \ | ||
116 | } while (0) | 114 | } while (0) |
117 | 115 | ||
118 | 116 | ||
diff --git a/procps/top.c b/procps/top.c index 3d67c3cfd..9a3f171ac 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -184,10 +184,6 @@ struct globals { | |||
184 | }; //FIX_ALIASING; - large code growth | 184 | }; //FIX_ALIASING; - large code growth |
185 | enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) }; | 185 | enum { LINE_BUF_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line_buf) }; |
186 | #define G (*(struct globals*)&bb_common_bufsiz1) | 186 | #define G (*(struct globals*)&bb_common_bufsiz1) |
187 | struct BUG_bad_size { | ||
188 | char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; | ||
189 | char BUG_line_buf_too_small[LINE_BUF_SIZE > 80 ? 1 : -1]; | ||
190 | }; | ||
191 | #define top (G.top ) | 187 | #define top (G.top ) |
192 | #define ntop (G.ntop ) | 188 | #define ntop (G.ntop ) |
193 | #define sort_field (G.sort_field ) | 189 | #define sort_field (G.sort_field ) |
@@ -204,7 +200,10 @@ struct BUG_bad_size { | |||
204 | #define num_cpus (G.num_cpus ) | 200 | #define num_cpus (G.num_cpus ) |
205 | #define total_pcpu (G.total_pcpu ) | 201 | #define total_pcpu (G.total_pcpu ) |
206 | #define line_buf (G.line_buf ) | 202 | #define line_buf (G.line_buf ) |
207 | #define INIT_G() do { } while (0) | 203 | #define INIT_G() do { \ |
204 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | ||
205 | BUILD_BUG_ON(LINE_BUF_SIZE <= 80); \ | ||
206 | } while (0) | ||
208 | 207 | ||
209 | enum { | 208 | enum { |
210 | OPT_d = (1 << 0), | 209 | OPT_d = (1 << 0), |