From 924eb295652b85c25209f2461e3574cd6c433753 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 31 May 2013 14:30:13 +0000 Subject: [PATCH] fix inet warnings Change-Id: Ia6e761d2c649f03a49b2646387f859d6c2a646cb --- servers/inet/clock.c | 14 +++++++------- servers/inet/generic/assert.h | 9 ++++----- servers/inet/generic/ip.c | 1 + servers/inet/inet.c | 11 +++++++---- servers/inet/inet.h | 9 +++++++-- servers/inet/inet_config.c | 17 ++++++++++------- servers/inet/inet_config.h | 4 ++-- servers/inet/queryparam.c | 2 +- servers/inet/queryparam.h | 8 ++++---- 9 files changed, 43 insertions(+), 32 deletions(-) diff --git a/servers/inet/clock.c b/servers/inet/clock.c index 71517845e..42e5f6dfd 100644 --- a/servers/inet/clock.c +++ b/servers/inet/clock.c @@ -134,14 +134,14 @@ timer_t *timer; static void set_timer() { time_t new_time; - time_t curr_time; + time_t now; if (!timer_chain) return; - curr_time= get_time(); + now= get_time(); new_time= timer_chain->tim_time; - if (new_time <= curr_time) + if (new_time <= now) { clck_call_expire= 1; return; @@ -150,7 +150,7 @@ static void set_timer() if (next_timeout == 0 || new_time < next_timeout) { next_timeout= new_time; - new_time -= curr_time; + new_time -= now; if (sys_setalarm(new_time, 0) != OK) ip_panic(("can't set timer")); @@ -166,7 +166,7 @@ timer_t *timer; void clck_expire_timers() { - time_t curr_time; + time_t now; timer_t *timer_index; clck_call_expire= 0; @@ -174,8 +174,8 @@ void clck_expire_timers() if (timer_chain == NULL) return; - curr_time= get_time(); - while (timer_chain && timer_chain->tim_time<=curr_time) + now= get_time(); + while (timer_chain && timer_chain->tim_time<=now) { assert(timer_chain->tim_active); timer_chain->tim_active= 0; diff --git a/servers/inet/generic/assert.h b/servers/inet/generic/assert.h index e6d6492b0..7c5418d22 100644 --- a/servers/inet/generic/assert.h +++ b/servers/inet/generic/assert.h @@ -1,3 +1,6 @@ + +#include + /* assert.h @@ -11,14 +14,10 @@ Copyright 1995 Philip Homburg void bad_assertion(char *file, int line, char *what) _NORETURN; void bad_compare(char *file, int line, int lhs, char *what, int rhs) _NORETURN; -#define assert(x) ((void)(!(x) ? bad_assertion(this_file, __LINE__, \ - #x),0 : 0)) -#define compare(a,t,b) (!((a) t (b)) ? bad_compare(this_file, __LINE__, \ - (a), #a " " #t " " #b, (b)) : (void) 0) +#define compare(a,t,b) assert((a) t (b)) #else /* NDEBUG */ -#define assert(x) 0 #define compare(a,t,b) 0 #endif /* NDEBUG */ diff --git a/servers/inet/generic/ip.c b/servers/inet/generic/ip.c index 659e552d8..57b93c9f2 100644 --- a/servers/inet/generic/ip.c +++ b/servers/inet/generic/ip.c @@ -482,6 +482,7 @@ static void ip_bufcheck() } #endif /* BUF_CONSISTENCY_CHECK */ +__dead static void ip_bad_callback(ip_port) struct ip_port *ip_port; { diff --git a/servers/inet/inet.c b/servers/inet/inet.c index adecedf1b..24ffa0b9e 100644 --- a/servers/inet/inet.c +++ b/servers/inet/inet.c @@ -331,7 +331,7 @@ static void nw_init() static void ds_event() { char key[DS_MAX_KEYLEN]; - char *driver_prefix = "drv.net."; + char *driver_prefix = (char *) "drv.net."; char *label; u32_t value; int type; @@ -375,7 +375,8 @@ int line; printf("panic at %s, %d: ", file, line); } -void inet_panic() +__dead +void inet_panic(void) { printf("\ninet stacktrace: "); util_stacktrace(); @@ -384,6 +385,7 @@ void inet_panic() } #if !NDEBUG +__dead void bad_assertion(file, line, what) char *file; int line; @@ -391,10 +393,11 @@ char *what; { panic0(file, line); printf("assertion \"%s\" failed", what); - panic(); + panic("help"); } +__dead void bad_compare(file, line, lhs, what, rhs) char *file; int line; @@ -404,7 +407,7 @@ int rhs; { panic0(file, line); printf("compare (%d) %s (%d) failed", lhs, what, rhs); - panic(); + panic("help"); } #endif /* !NDEBUG */ diff --git a/servers/inet/inet.h b/servers/inet/inet.h index a7e2b8629..5999fa930 100644 --- a/servers/inet/inet.h +++ b/servers/inet/inet.h @@ -63,14 +63,19 @@ typedef int ioreq_t; #define PRIVATE static #define FORWARD static -#define THIS_FILE static char *this_file= __FILE__; +#define THIS_FILE +#define this_file __FILE__ void panic0(char *file, int line); void inet_panic(void) _NORETURN; +#if 0 #define ip_panic(print_list) \ - (panic0(this_file, __LINE__), printf print_list, panic()) + (panic0(this_file, __LINE__), printf print_list, panic()) #define panic() inet_panic() +#else +#define ip_panic(print_list) do { panic print_list; } while(0) +#endif #if DEBUG #define ip_warning(print_list) \ diff --git a/servers/inet/inet_config.c b/servers/inet/inet_config.c index 4854970b7..004074797 100644 --- a/servers/inet/inet_config.c +++ b/servers/inet/inet_config.c @@ -16,6 +16,7 @@ Copyright 1995 Philip Homburg #include #include #include +#include #include #include #include @@ -42,7 +43,8 @@ int ip_forward_directed_bcast= 0; /* Default is off */ static u8_t iftype[IP_PORT_MAX]; /* Interface in use as? */ static int ifdefault= -1; /* Default network interface. */ -static void fatal(char *label) +__dead +static void fatal(char *label) { printf("init: %s: %s\n", label, strerror(errno)); exit(1); @@ -108,11 +110,11 @@ static void check_dev(int type, int ifno) mode_t mode; u8_t minor_off; } devlist[] = { - { "/dev/eth", 0600, ETH_DEV_OFF }, - { "/dev/psip", 0600, PSIP_DEV_OFF }, - { "/dev/ip", 0600, IP_DEV_OFF }, - { "/dev/tcp", 0666, TCP_DEV_OFF }, - { "/dev/udp", 0666, UDP_DEV_OFF }, + { (char *) "/dev/eth", 0600, ETH_DEV_OFF }, + { (char *) "/dev/psip", 0600, PSIP_DEV_OFF }, + { (char *) "/dev/ip", 0600, IP_DEV_OFF }, + { (char *) "/dev/tcp", 0666, TCP_DEV_OFF }, + { (char *) "/dev/udp", 0666, UDP_DEV_OFF }, }; struct devlist *dvp; int i; @@ -147,6 +149,7 @@ static char word[16]; static unsigned char line[256], *lineptr; static unsigned linenr; +__dead static void error(void) { printf("inet: error on line %u\n", linenr); @@ -407,7 +410,7 @@ void read_conf(void) /* See what the device number of /dev/ip is. That's what we * used last time for the network devices, so we keep doing so. */ - if (stat("/dev/ip", &st) < 0) fatal("/dev/ip"); + if (stat("/dev/ip", &st) < 0) fatal((char *) "/dev/ip"); ip_dev= st.st_rdev; for (i= 0; i < IP_PORT_MAX; i++) { diff --git a/servers/inet/inet_config.h b/servers/inet/inet_config.h index 075f27ec7..164174465 100644 --- a/servers/inet/inet_config.h +++ b/servers/inet/inet_config.h @@ -13,7 +13,7 @@ Copyright 1995 Philip Homburg #define INET__INET_CONFIG_H /* Inet configuration file. */ -#define PATH_INET_CONF "/etc/inet.conf" +#define PATH_INET_CONF (char *) "/etc/inet.conf" #define IP_PORT_MAX 32 /* Up to this many network devices */ extern int eth_conf_nr; /* Number of ethernets */ @@ -62,7 +62,7 @@ struct udp_conf /* To compute the minor device number for a device on an interface. */ #define if2minor(ifno, dev) (1 + (ifno) * 8 + (dev)) -#define IPSTAT_DEV "/dev/ipstat" +#define IPSTAT_DEV (char *) "/dev/ipstat" #define IPSTAT_MODE 0666 /* Is this right? What about just setuid apps */ #define IPSTAT_MINOR 0 /* Minor number of /dev/ipstat */ diff --git a/servers/inet/queryparam.c b/servers/inet/queryparam.c index 26bf5d7f4..d505423ea 100644 --- a/servers/inet/queryparam.c +++ b/servers/inet/queryparam.c @@ -73,7 +73,7 @@ int queryparam(int qgetc(void), void **poffset, size_t *psize) epl= ep->list; while (c != 0 && c != ',') { - prefix= "x"; + prefix= (char *) "x"; n= 0; for (;;) { diff --git a/servers/inet/queryparam.h b/servers/inet/queryparam.h index e5cc8ad3e..8f3b4e9af 100644 --- a/servers/inet/queryparam.h +++ b/servers/inet/queryparam.h @@ -19,16 +19,16 @@ struct export_params { }; #ifdef __STDC__ -#define qp_stringize(var) #var -#define qp_dotstringize(var) "." #var +#define qp_stringize(var) (char *) #var +#define qp_dotstringize(var) "." (char *) #var #else #define qp_stringize(var) "var" #define qp_dotstringize(var) ".var" #endif #define QP_VARIABLE(var) { qp_stringize(var), &(var), sizeof(var) } -#define QP_ARRAY(var) { "[", 0, sizeof((var)[0]) } +#define QP_ARRAY(var) { (char *) "[", 0, sizeof((var)[0]) } #define QP_VECTOR(var,ptr,len) { qp_stringize(var), &(ptr), -1 },\ - { "[", &(len), sizeof(*(ptr)) } + { (char *) "[", &(len), sizeof(*(ptr)) } #define QP_FIELD(field, type) { qp_dotstringize(field), \ (void *)offsetof(type, field), \ sizeof(((type *)0)->field) } -- 2.44.0