From 92706fd5515100c54e18016f91b7cc8a10686949 Mon Sep 17 00:00:00 2001 From: Aaron Jones Date: Wed, 1 Jun 2016 19:50:09 +0000 Subject: [PATCH] librb: silence some fairly harmless compiler warnings These include warnings about "break" statements that will never be executed (because they are after "return" statements), unused macros (lost to code refactoring or never even used in the first place), functions that call abort() or loop indefinitely but aren't marked with the "noreturn" attribute, and use of variables possibly uninitialised (a false positive). --- librb/include/rb_helper.h | 2 +- librb/include/rb_lib.h | 4 ++-- librb/include/rb_memory.h | 2 +- librb/src/balloc.c | 2 ++ librb/src/commio.c | 3 --- librb/src/crypt.c | 9 +-------- librb/src/linebuf.c | 4 ---- librb/src/patricia.c | 4 ---- 8 files changed, 7 insertions(+), 23 deletions(-) diff --git a/librb/include/rb_helper.h b/librb/include/rb_helper.h index 0b4a9086..01868b67 100644 --- a/librb/include/rb_helper.h +++ b/librb/include/rb_helper.h @@ -58,5 +58,5 @@ void rb_helper_write_flush(rb_helper *helper); void rb_helper_run(rb_helper *helper); void rb_helper_close(rb_helper *helper); int rb_helper_read(rb_helper *helper, void *buf, size_t bufsize); -void rb_helper_loop(rb_helper *helper, long delay); +void rb_helper_loop(rb_helper *helper, long delay) __attribute__((noreturn)); #endif diff --git a/librb/include/rb_lib.h b/librb/include/rb_lib.h index 7646718e..2a817408 100644 --- a/librb/include/rb_lib.h +++ b/librb/include/rb_lib.h @@ -215,14 +215,14 @@ typedef void die_cb(const char *buffer); char *rb_ctime(const time_t, char *, size_t); char *rb_date(const time_t, char *, size_t); void rb_lib_log(const char *, ...); -void rb_lib_restart(const char *, ...); +void rb_lib_restart(const char *, ...) __attribute__((noreturn)); void rb_lib_die(const char *, ...); void rb_set_time(void); const char *rb_lib_version(void); void rb_lib_init(log_cb * xilog, restart_cb * irestart, die_cb * idie, int closeall, int maxfds, size_t dh_size, size_t fd_heap_size); -void rb_lib_loop(long delay); +void rb_lib_loop(long delay) __attribute__((noreturn)); time_t rb_current_time(void); const struct timeval *rb_current_time_tv(void); diff --git a/librb/include/rb_memory.h b/librb/include/rb_memory.h index 1bc7af09..222b5c8d 100644 --- a/librb/include/rb_memory.h +++ b/librb/include/rb_memory.h @@ -33,7 +33,7 @@ #include -void rb_outofmemory(void); +void rb_outofmemory(void) __attribute__((noreturn)); static inline void * rb_malloc(size_t size) diff --git a/librb/src/balloc.c b/librb/src/balloc.c index 71b36cab..2cbe4350 100644 --- a/librb/src/balloc.c +++ b/librb/src/balloc.c @@ -58,6 +58,8 @@ #include #include +static void _rb_bh_fail(const char *reason, const char *file, int line) __attribute__((noreturn)); + static uintptr_t offset_pad; /* status information for an allocated block in heap */ diff --git a/librb/src/commio.c b/librb/src/commio.c index b40a5cc2..252e6e9d 100644 --- a/librb/src/commio.c +++ b/librb/src/commio.c @@ -1345,16 +1345,13 @@ rb_inet_ntop_sock(struct sockaddr *src, char *dst, unsigned int size) { case AF_INET: return (rb_inet_ntop(AF_INET, &((struct sockaddr_in *)src)->sin_addr, dst, size)); - break; #ifdef RB_IPV6 case AF_INET6: return (rb_inet_ntop (AF_INET6, &((struct sockaddr_in6 *)src)->sin6_addr, dst, size)); - break; #endif default: return NULL; - break; } } diff --git a/librb/src/crypt.c b/librb/src/crypt.c index 9344e988..b2e37240 100644 --- a/librb/src/crypt.c +++ b/librb/src/crypt.c @@ -46,16 +46,12 @@ rb_crypt(const char *key, const char *salt) { case '1': return rb_md5_crypt(key, salt); - break; case '5': return rb_sha256_crypt(key, salt); - break; case '6': return rb_sha512_crypt(key, salt); - break; default: return NULL; - break; }; } else @@ -536,7 +532,7 @@ rb_do_des(uint32_t l_in, uint32_t r_in, uint32_t *l_out, uint32_t *r_out, int co * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. */ uint32_t l, r, *kl, *kr, *kl1, *kr1; - uint32_t f, r48l, r48r; + uint32_t f = 0, r48l, r48r; int round; if(count == 0) @@ -748,9 +744,6 @@ rb_des_crypt(const char *key, const char *setting) * edited for clarity and style only. */ -#define MD5_BLOCK_LENGTH 64 -#define MD5_DIGEST_LENGTH 16 -#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1) #define MD5_SIZE 16 static void diff --git a/librb/src/linebuf.c b/librb/src/linebuf.c index 33977f80..77fe9b7d 100644 --- a/librb/src/linebuf.c +++ b/librb/src/linebuf.c @@ -31,10 +31,6 @@ static rb_bh *rb_linebuf_heap; static int bufline_count = 0; -#ifndef LINEBUF_HEAP_SIZE -#define LINEBUF_HEAP_SIZE 2048 -#endif - /* * rb_linebuf_init * diff --git a/librb/src/patricia.c b/librb/src/patricia.c index 9db07138..fe02c73c 100644 --- a/librb/src/patricia.c +++ b/librb/src/patricia.c @@ -27,10 +27,6 @@ * #define PATRICIA_DEBUG 1 */ -#define PREFIX_HEAP_COUNT 1024 -#define NODE_HEAP_COUNT 1024 -#define PATRICIA_HEAP_COUNT 128 - void rb_init_patricia(void) {