fix inet warnings

Change-Id: Ia6e761d2c649f03a49b2646387f859d6c2a646cb
This commit is contained in:
Ben Gras 2013-05-31 14:30:13 +00:00
parent d8b7bfdfe8
commit 924eb29565
9 changed files with 43 additions and 32 deletions

View File

@ -134,14 +134,14 @@ timer_t *timer;
static void set_timer() static void set_timer()
{ {
time_t new_time; time_t new_time;
time_t curr_time; time_t now;
if (!timer_chain) if (!timer_chain)
return; return;
curr_time= get_time(); now= get_time();
new_time= timer_chain->tim_time; new_time= timer_chain->tim_time;
if (new_time <= curr_time) if (new_time <= now)
{ {
clck_call_expire= 1; clck_call_expire= 1;
return; return;
@ -150,7 +150,7 @@ static void set_timer()
if (next_timeout == 0 || new_time < next_timeout) if (next_timeout == 0 || new_time < next_timeout)
{ {
next_timeout= new_time; next_timeout= new_time;
new_time -= curr_time; new_time -= now;
if (sys_setalarm(new_time, 0) != OK) if (sys_setalarm(new_time, 0) != OK)
ip_panic(("can't set timer")); ip_panic(("can't set timer"));
@ -166,7 +166,7 @@ timer_t *timer;
void clck_expire_timers() void clck_expire_timers()
{ {
time_t curr_time; time_t now;
timer_t *timer_index; timer_t *timer_index;
clck_call_expire= 0; clck_call_expire= 0;
@ -174,8 +174,8 @@ void clck_expire_timers()
if (timer_chain == NULL) if (timer_chain == NULL)
return; return;
curr_time= get_time(); now= get_time();
while (timer_chain && timer_chain->tim_time<=curr_time) while (timer_chain && timer_chain->tim_time<=now)
{ {
assert(timer_chain->tim_active); assert(timer_chain->tim_active);
timer_chain->tim_active= 0; timer_chain->tim_active= 0;

View File

@ -1,3 +1,6 @@
#include <assert.h>
/* /*
assert.h assert.h
@ -11,14 +14,10 @@ Copyright 1995 Philip Homburg
void bad_assertion(char *file, int line, char *what) _NORETURN; void bad_assertion(char *file, int line, char *what) _NORETURN;
void bad_compare(char *file, int line, int lhs, char *what, int rhs) _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__, \ #define compare(a,t,b) assert((a) t (b))
#x),0 : 0))
#define compare(a,t,b) (!((a) t (b)) ? bad_compare(this_file, __LINE__, \
(a), #a " " #t " " #b, (b)) : (void) 0)
#else /* NDEBUG */ #else /* NDEBUG */
#define assert(x) 0
#define compare(a,t,b) 0 #define compare(a,t,b) 0
#endif /* NDEBUG */ #endif /* NDEBUG */

View File

@ -482,6 +482,7 @@ static void ip_bufcheck()
} }
#endif /* BUF_CONSISTENCY_CHECK */ #endif /* BUF_CONSISTENCY_CHECK */
__dead
static void ip_bad_callback(ip_port) static void ip_bad_callback(ip_port)
struct ip_port *ip_port; struct ip_port *ip_port;
{ {

View File

@ -331,7 +331,7 @@ static void nw_init()
static void ds_event() static void ds_event()
{ {
char key[DS_MAX_KEYLEN]; char key[DS_MAX_KEYLEN];
char *driver_prefix = "drv.net."; char *driver_prefix = (char *) "drv.net.";
char *label; char *label;
u32_t value; u32_t value;
int type; int type;
@ -375,7 +375,8 @@ int line;
printf("panic at %s, %d: ", file, line); printf("panic at %s, %d: ", file, line);
} }
void inet_panic() __dead
void inet_panic(void)
{ {
printf("\ninet stacktrace: "); printf("\ninet stacktrace: ");
util_stacktrace(); util_stacktrace();
@ -384,6 +385,7 @@ void inet_panic()
} }
#if !NDEBUG #if !NDEBUG
__dead
void bad_assertion(file, line, what) void bad_assertion(file, line, what)
char *file; char *file;
int line; int line;
@ -391,10 +393,11 @@ char *what;
{ {
panic0(file, line); panic0(file, line);
printf("assertion \"%s\" failed", what); printf("assertion \"%s\" failed", what);
panic(); panic("help");
} }
__dead
void bad_compare(file, line, lhs, what, rhs) void bad_compare(file, line, lhs, what, rhs)
char *file; char *file;
int line; int line;
@ -404,7 +407,7 @@ int rhs;
{ {
panic0(file, line); panic0(file, line);
printf("compare (%d) %s (%d) failed", lhs, what, rhs); printf("compare (%d) %s (%d) failed", lhs, what, rhs);
panic(); panic("help");
} }
#endif /* !NDEBUG */ #endif /* !NDEBUG */

View File

@ -63,14 +63,19 @@ typedef int ioreq_t;
#define PRIVATE static #define PRIVATE static
#define FORWARD 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 panic0(char *file, int line);
void inet_panic(void) _NORETURN; void inet_panic(void) _NORETURN;
#if 0
#define ip_panic(print_list) \ #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() #define panic() inet_panic()
#else
#define ip_panic(print_list) do { panic print_list; } while(0)
#endif
#if DEBUG #if DEBUG
#define ip_warning(print_list) \ #define ip_warning(print_list) \

View File

@ -16,6 +16,7 @@ Copyright 1995 Philip Homburg
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/cdefs.h>
#include <minix/type.h> #include <minix/type.h>
#include <minix/sysutil.h> #include <minix/sysutil.h>
#include <minix/syslib.h> #include <minix/syslib.h>
@ -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 u8_t iftype[IP_PORT_MAX]; /* Interface in use as? */
static int ifdefault= -1; /* Default network interface. */ 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)); printf("init: %s: %s\n", label, strerror(errno));
exit(1); exit(1);
@ -108,11 +110,11 @@ static void check_dev(int type, int ifno)
mode_t mode; mode_t mode;
u8_t minor_off; u8_t minor_off;
} devlist[] = { } devlist[] = {
{ "/dev/eth", 0600, ETH_DEV_OFF }, { (char *) "/dev/eth", 0600, ETH_DEV_OFF },
{ "/dev/psip", 0600, PSIP_DEV_OFF }, { (char *) "/dev/psip", 0600, PSIP_DEV_OFF },
{ "/dev/ip", 0600, IP_DEV_OFF }, { (char *) "/dev/ip", 0600, IP_DEV_OFF },
{ "/dev/tcp", 0666, TCP_DEV_OFF }, { (char *) "/dev/tcp", 0666, TCP_DEV_OFF },
{ "/dev/udp", 0666, UDP_DEV_OFF }, { (char *) "/dev/udp", 0666, UDP_DEV_OFF },
}; };
struct devlist *dvp; struct devlist *dvp;
int i; int i;
@ -147,6 +149,7 @@ static char word[16];
static unsigned char line[256], *lineptr; static unsigned char line[256], *lineptr;
static unsigned linenr; static unsigned linenr;
__dead
static void error(void) static void error(void)
{ {
printf("inet: error on line %u\n", linenr); 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 /* 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. * 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; ip_dev= st.st_rdev;
for (i= 0; i < IP_PORT_MAX; i++) { for (i= 0; i < IP_PORT_MAX; i++) {

View File

@ -13,7 +13,7 @@ Copyright 1995 Philip Homburg
#define INET__INET_CONFIG_H #define INET__INET_CONFIG_H
/* Inet configuration file. */ /* 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 */ #define IP_PORT_MAX 32 /* Up to this many network devices */
extern int eth_conf_nr; /* Number of ethernets */ 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. */ /* To compute the minor device number for a device on an interface. */
#define if2minor(ifno, dev) (1 + (ifno) * 8 + (dev)) #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_MODE 0666 /* Is this right? What about just setuid apps */
#define IPSTAT_MINOR 0 /* Minor number of /dev/ipstat */ #define IPSTAT_MINOR 0 /* Minor number of /dev/ipstat */

View File

@ -73,7 +73,7 @@ int queryparam(int qgetc(void), void **poffset, size_t *psize)
epl= ep->list; epl= ep->list;
while (c != 0 && c != ',') { while (c != 0 && c != ',') {
prefix= "x"; prefix= (char *) "x";
n= 0; n= 0;
for (;;) { for (;;) {

View File

@ -19,16 +19,16 @@ struct export_params {
}; };
#ifdef __STDC__ #ifdef __STDC__
#define qp_stringize(var) #var #define qp_stringize(var) (char *) #var
#define qp_dotstringize(var) "." #var #define qp_dotstringize(var) "." (char *) #var
#else #else
#define qp_stringize(var) "var" #define qp_stringize(var) "var"
#define qp_dotstringize(var) ".var" #define qp_dotstringize(var) ".var"
#endif #endif
#define QP_VARIABLE(var) { qp_stringize(var), &(var), sizeof(var) } #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 },\ #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), \ #define QP_FIELD(field, type) { qp_dotstringize(field), \
(void *)offsetof(type, field), \ (void *)offsetof(type, field), \
sizeof(((type *)0)->field) } sizeof(((type *)0)->field) }