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).
This commit is contained in:
Aaron Jones 2016-06-01 19:50:09 +00:00
parent 1a938496eb
commit 92706fd551
No known key found for this signature in database
GPG key ID: 6E854C0FAAD4CEA4
8 changed files with 7 additions and 23 deletions

View file

@ -58,5 +58,5 @@ void rb_helper_write_flush(rb_helper *helper);
void rb_helper_run(rb_helper *helper); void rb_helper_run(rb_helper *helper);
void rb_helper_close(rb_helper *helper); void rb_helper_close(rb_helper *helper);
int rb_helper_read(rb_helper *helper, void *buf, size_t bufsize); 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 #endif

View file

@ -215,14 +215,14 @@ typedef void die_cb(const char *buffer);
char *rb_ctime(const time_t, char *, size_t); char *rb_ctime(const time_t, char *, size_t);
char *rb_date(const time_t, char *, size_t); char *rb_date(const time_t, char *, size_t);
void rb_lib_log(const char *, ...); 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_lib_die(const char *, ...);
void rb_set_time(void); void rb_set_time(void);
const char *rb_lib_version(void); const char *rb_lib_version(void);
void rb_lib_init(log_cb * xilog, restart_cb * irestart, die_cb * idie, int closeall, int maxfds, 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); 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); time_t rb_current_time(void);
const struct timeval *rb_current_time_tv(void); const struct timeval *rb_current_time_tv(void);

View file

@ -33,7 +33,7 @@
#include <stdlib.h> #include <stdlib.h>
void rb_outofmemory(void); void rb_outofmemory(void) __attribute__((noreturn));
static inline void * static inline void *
rb_malloc(size_t size) rb_malloc(size_t size)

View file

@ -58,6 +58,8 @@
#include <librb_config.h> #include <librb_config.h>
#include <rb_lib.h> #include <rb_lib.h>
static void _rb_bh_fail(const char *reason, const char *file, int line) __attribute__((noreturn));
static uintptr_t offset_pad; static uintptr_t offset_pad;
/* status information for an allocated block in heap */ /* status information for an allocated block in heap */

View file

@ -1345,16 +1345,13 @@ rb_inet_ntop_sock(struct sockaddr *src, char *dst, unsigned int size)
{ {
case AF_INET: case AF_INET:
return (rb_inet_ntop(AF_INET, &((struct sockaddr_in *)src)->sin_addr, dst, size)); return (rb_inet_ntop(AF_INET, &((struct sockaddr_in *)src)->sin_addr, dst, size));
break;
#ifdef RB_IPV6 #ifdef RB_IPV6
case AF_INET6: case AF_INET6:
return (rb_inet_ntop return (rb_inet_ntop
(AF_INET6, &((struct sockaddr_in6 *)src)->sin6_addr, dst, size)); (AF_INET6, &((struct sockaddr_in6 *)src)->sin6_addr, dst, size));
break;
#endif #endif
default: default:
return NULL; return NULL;
break;
} }
} }

View file

@ -46,16 +46,12 @@ rb_crypt(const char *key, const char *salt)
{ {
case '1': case '1':
return rb_md5_crypt(key, salt); return rb_md5_crypt(key, salt);
break;
case '5': case '5':
return rb_sha256_crypt(key, salt); return rb_sha256_crypt(key, salt);
break;
case '6': case '6':
return rb_sha512_crypt(key, salt); return rb_sha512_crypt(key, salt);
break;
default: default:
return NULL; return NULL;
break;
}; };
} }
else 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. * 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 l, r, *kl, *kr, *kl1, *kr1;
uint32_t f, r48l, r48r; uint32_t f = 0, r48l, r48r;
int round; int round;
if(count == 0) if(count == 0)
@ -748,9 +744,6 @@ rb_des_crypt(const char *key, const char *setting)
* edited for clarity and style only. * 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 #define MD5_SIZE 16
static void static void

View file

@ -31,10 +31,6 @@ static rb_bh *rb_linebuf_heap;
static int bufline_count = 0; static int bufline_count = 0;
#ifndef LINEBUF_HEAP_SIZE
#define LINEBUF_HEAP_SIZE 2048
#endif
/* /*
* rb_linebuf_init * rb_linebuf_init
* *

View file

@ -27,10 +27,6 @@
* #define PATRICIA_DEBUG 1 * #define PATRICIA_DEBUG 1
*/ */
#define PREFIX_HEAP_COUNT 1024
#define NODE_HEAP_COUNT 1024
#define PATRICIA_HEAP_COUNT 128
void void
rb_init_patricia(void) rb_init_patricia(void)
{ {