aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-13 14:50:20 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-13 14:50:20 +0200
commitab3964db4e75e34f6f9347406c5fd2bced04f2dd (patch)
tree92113e4a008338ed8534858db97d3a5e09dc210b /networking
parentf7ad927c2059ef9cd1cd6befeb43f26b92f6369f (diff)
downloadbusybox-ab3964db4e75e34f6f9347406c5fd2bced04f2dd.tar.gz
libbb: introduce kernel-style BUILD_BUG_ON()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/ftpgetput.c7
-rw-r--r--networking/isrv.c4
-rw-r--r--networking/ping.c8
-rw-r--r--networking/tc.c7
-rw-r--r--networking/tftp.c7
5 files changed, 12 insertions, 21 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 8283366cc..b398bc874 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -62,9 +62,6 @@ struct globals {
} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
enum { BUFSZ = COMMON_BUFSIZE - offsetof(struct globals, buf) };
-struct BUG_G_too_big {
- char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1];
-};
#define user (G.user )
#define password (G.password )
#define lsa (G.lsa )
@@ -72,7 +69,9 @@ struct BUG_G_too_big {
#define verbose_flag (G.verbose_flag )
#define do_continue (G.do_continue )
#define buf (G.buf )
-#define INIT_G() do { } while (0)
+#define INIT_G() do { \
+ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
+} while (0)
static void ftp_die(const char *msg) NORETURN;
diff --git a/networking/isrv.c b/networking/isrv.c
index 1c6491edd..3673db715 100644
--- a/networking/isrv.c
+++ b/networking/isrv.c
@@ -194,7 +194,6 @@ static void handle_accept(isrv_state_t *state, int fd)
remove_peer(state, n); /* unsuccesful peer start */
}
-void BUG_sizeof_fd_set_is_strange(void);
static void handle_fd_set(isrv_state_t *state, fd_set *fds, int (*h)(int, void **))
{
enum { LONG_CNT = sizeof(fd_set) / sizeof(long) };
@@ -203,8 +202,7 @@ static void handle_fd_set(isrv_state_t *state, fd_set *fds, int (*h)(int, void *
/* need to know value at _the beginning_ of this routine */
int fd_cnt = FD_COUNT;
- if (LONG_CNT * sizeof(long) != sizeof(fd_set))
- BUG_sizeof_fd_set_is_strange();
+ BUILD_BUG_ON(LONG_CNT * sizeof(long) != sizeof(fd_set));
fds_pos = 0;
while (1) {
diff --git a/networking/ping.c b/networking/ping.c
index dcbf19682..0eb1ae799 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -396,10 +396,8 @@ struct globals {
#define dotted (G.dotted )
#define pingaddr (G.pingaddr )
#define rcvd_tbl (G.rcvd_tbl )
-void BUG_ping_globals_too_big(void);
#define INIT_G() do { \
- if (sizeof(G) > COMMON_BUFSIZE) \
- BUG_ping_globals_too_big(); \
+ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
datalen = DEFDATALEN; \
timeout = MAXWAIT; \
tmin = UINT_MAX; \
@@ -732,7 +730,6 @@ static void ping4(len_and_sockaddr *lsa)
}
}
#if ENABLE_PING6
-extern int BUG_bad_offsetof_icmp6_cksum(void);
static void ping6(len_and_sockaddr *lsa)
{
int sockopt;
@@ -769,8 +766,7 @@ static void ping6(len_and_sockaddr *lsa)
setsockopt_SOL_SOCKET_int(pingsock, SO_RCVBUF, sockopt);
sockopt = offsetof(struct icmp6_hdr, icmp6_cksum);
- if (offsetof(struct icmp6_hdr, icmp6_cksum) != 2)
- BUG_bad_offsetof_icmp6_cksum();
+ BUILD_BUG_ON(offsetof(struct icmp6_hdr, icmp6_cksum) != 2);
setsockopt_int(pingsock, SOL_RAW, IPV6_CHECKSUM, sockopt);
/* request ttl info to be returned in ancillary data */
diff --git a/networking/tc.c b/networking/tc.c
index 76e2e8359..6d1fef993 100644
--- a/networking/tc.c
+++ b/networking/tc.c
@@ -64,15 +64,14 @@ struct globals {
uint32_t filter_proto;
} 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 filter_ifindex (G.filter_ifindex)
#define filter_qdisc (G.filter_qdisc)
#define filter_parent (G.filter_parent)
#define filter_prio (G.filter_prio)
#define filter_proto (G.filter_proto)
-#define INIT_G() do { } while (0)
+#define INIT_G() do { \
+ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
+} while (0)
/* Allocates a buffer containing the name of a class id.
* The caller must free the returned memory. */
diff --git a/networking/tftp.c b/networking/tftp.c
index 8ecd7bb6f..ad9308e52 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -129,10 +129,9 @@ 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 INIT_G() do { } while (0)
+#define INIT_G() do { \
+ BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
+} while (0)
#define G_error_pkt_reason (G.error_pkt[3])
#define G_error_pkt_str ((char*)(G.error_pkt + 4))