From 7b85ec30b5941f0b90c48a990f2f6840aca87bce Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 13 Oct 2015 17:17:34 +0200 Subject: *: more BUILD_BUG_ON conversions Signed-off-by: Denys Vlasenko --- miscutils/hdparm.c | 7 +++---- miscutils/taskset.c | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'miscutils') 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 { #endif } FIX_ALIASING; #define G (*(struct globals*)&bb_common_bufsiz1) -struct BUG_G_too_big { - char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1]; -}; #define get_identity (G.get_identity ) #define get_geom (G.get_geom ) #define do_flush (G.do_flush ) @@ -433,7 +430,9 @@ 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) +#define INIT_G() do { \ + BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ +} while (0) /* 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) #define TASKSET_PRINTF_MASK "%llx" static unsigned long long from_cpuset(cpu_set_t *mask) { - struct BUG_CPU_SETSIZE_is_too_small { - char BUG_CPU_SETSIZE_is_too_small[ - CPU_SETSIZE < sizeof(int) ? -1 : 1]; - }; char *p = (void*)mask; + BUILD_BUG_ON(CPU_SETSIZE < sizeof(int)); + /* Take the least significant bits. Careful! * Consider both CPU_SETSIZE=4 and CPU_SETSIZE=1024 cases */ -- cgit v1.2.3