From: Kees van Reeuwijk Date: Thu, 11 Mar 2010 14:23:33 +0000 (+0000) Subject: Add an UNUSED annotation, and use it in libsys. X-Git-Tag: v3.1.7~239 X-Git-Url: http://zhaoyanbai.com/repos/man.named.html?a=commitdiff_plain;h=23e97af1b4ca7facec20305adbd4288f80eea781;p=minix.git Add an UNUSED annotation, and use it in libsys. --- diff --git a/include/minix/const.h b/include/minix/const.h index 9ba211b19..1406adaf2 100644 --- a/include/minix/const.h +++ b/include/minix/const.h @@ -5,6 +5,33 @@ #error CHIP is not defined #endif +/* The UNUSED annotation tells the compiler or lint not to complain + * about an unused variable or function parameter. + * + * A number of different annotations are used, depending on the + * compiler or checker that is looking at the code. + * + * Note that some variants rename the parameter, so if you use + * the parameter after all, you'll get a complaint about a missing + * variable. + * + * You use it like this: + * + * void foo(int UNUSED(x)){} + */ + +#ifndef UNUSED +#if defined(__GNUC__) +# define UNUSED(v) UNUSED_ ## v __attribute((unused)) +#elif defined _lint +# define UNUSED(v) /*lint -e(715)*/ v +#elif defined __LCLINT__ +# define UNUSED(v) /*@unused@*/ v +#else +# define UNUSED(v) _UNUSED_ ## v +#endif +#endif + #define EXTERN extern /* used in *.h files */ #define PRIVATE static /* PRIVATE x limits the scope of x */ #define PUBLIC /* PUBLIC is the opposite of PRIVATE */ @@ -15,7 +42,7 @@ #define DEFAULT_HZ 60 /* clock freq (software settable on IBM-PC) */ -#define SUPER_USER (uid_t) 0 /* uid_t of superuser */ +#define SUPER_USER ((uid_t) 0) /* uid_t of superuser */ #define NULL ((void *)0) /* null pointer */ #define SCPVEC_NR 64 /* max # of entries in a SYS_VSAFECOPY* request */ diff --git a/lib/libsys/profile.c b/lib/libsys/profile.c index f814d78ac..48e063aa8 100644 --- a/lib/libsys/profile.c +++ b/lib/libsys/profile.c @@ -167,7 +167,7 @@ PUBLIC void procentry (char *name) } -PUBLIC void procexit (char *name) +PUBLIC void procexit (char *UNUSED(name)) { u64_t stop, spent; diff --git a/lib/libsys/sef_init.c b/lib/libsys/sef_init.c index a6d8e8de7..4b1671a02 100644 --- a/lib/libsys/sef_init.c +++ b/lib/libsys/sef_init.c @@ -106,7 +106,8 @@ PUBLIC void sef_setcb_init_restart(sef_cb_init_restart_t cb) /*===========================================================================* * sef_cb_init_fresh_null * *===========================================================================*/ -PUBLIC int sef_cb_init_fresh_null(int type, sef_init_info_t *info) +PUBLIC int sef_cb_init_fresh_null(int UNUSED(type), + sef_init_info_t *UNUSED(info)) { return(OK); } @@ -114,7 +115,7 @@ PUBLIC int sef_cb_init_fresh_null(int type, sef_init_info_t *info) /*===========================================================================* * sef_cb_init_lu_null * *===========================================================================*/ -PUBLIC int sef_cb_init_lu_null(int type, sef_init_info_t *info) +PUBLIC int sef_cb_init_lu_null(int UNUSED(type), sef_init_info_t *UNUSED(info)) { return(OK); } @@ -122,7 +123,8 @@ PUBLIC int sef_cb_init_lu_null(int type, sef_init_info_t *info) /*===========================================================================* * sef_cb_init_restart_null * *===========================================================================*/ -PUBLIC int sef_cb_init_restart_null(int type, sef_init_info_t *info) +PUBLIC int sef_cb_init_restart_null(int UNUSED(type), + sef_init_info_t *UNUSED(info)) { return(OK); } @@ -130,7 +132,8 @@ PUBLIC int sef_cb_init_restart_null(int type, sef_init_info_t *info) /*===========================================================================* * sef_cb_init_restart_fail * *===========================================================================*/ -PUBLIC int sef_cb_init_restart_fail(int type, sef_init_info_t *info) +PUBLIC int sef_cb_init_restart_fail(int UNUSED(type), + sef_init_info_t *UNUSED(info)) { return(ENOSYS); } diff --git a/lib/libsys/sef_liveupdate.c b/lib/libsys/sef_liveupdate.c index 8da36e590..4bf894492 100644 --- a/lib/libsys/sef_liveupdate.c +++ b/lib/libsys/sef_liveupdate.c @@ -192,14 +192,14 @@ PUBLIC void sef_setcb_lu_ready_pre(sef_cb_lu_ready_pre_t cb) /*===========================================================================* * sef_cb_lu_prepare_null * *===========================================================================*/ -PUBLIC void sef_cb_lu_prepare_null(int state) +PUBLIC void sef_cb_lu_prepare_null(int UNUSED(state)) { } /*===========================================================================* * sef_cb_lu_state_isvalid_null * *===========================================================================*/ -PUBLIC int sef_cb_lu_state_isvalid_null(int state) +PUBLIC int sef_cb_lu_state_isvalid_null(int UNUSED(state)) { return FALSE; } @@ -207,14 +207,15 @@ PUBLIC int sef_cb_lu_state_isvalid_null(int state) /*===========================================================================* * sef_cb_lu_state_changed_null * *===========================================================================*/ -PUBLIC void sef_cb_lu_state_changed_null(int old_state, int state) +PUBLIC void sef_cb_lu_state_changed_null(int UNUSED(old_state), + int UNUSED(state)) { } /*===========================================================================* * sef_cb_lu_state_dump_null * *===========================================================================*/ -PUBLIC void sef_cb_lu_state_dump_null(int state) +PUBLIC void sef_cb_lu_state_dump_null(int UNUSED(state)) { sef_lu_dprint("NULL\n"); } @@ -222,7 +223,7 @@ PUBLIC void sef_cb_lu_state_dump_null(int state) /*===========================================================================* * sef_cb_lu_ready_pre_null * *===========================================================================*/ -PUBLIC int sef_cb_lu_ready_pre_null(int result) +PUBLIC int sef_cb_lu_ready_pre_null(int UNUSED(result)) { return(OK); } @@ -230,7 +231,7 @@ PUBLIC int sef_cb_lu_ready_pre_null(int result) /*===========================================================================* * sef_cb_lu_prepare_always_ready * *===========================================================================*/ -PUBLIC void sef_cb_lu_prepare_always_ready(int state) +PUBLIC void sef_cb_lu_prepare_always_ready(int UNUSED(state)) { sef_lu_ready(OK); } diff --git a/lib/libsys/sef_ping.c b/lib/libsys/sef_ping.c index 60c6734d3..648ccb1c8 100644 --- a/lib/libsys/sef_ping.c +++ b/lib/libsys/sef_ping.c @@ -49,7 +49,7 @@ PUBLIC void sef_setcb_ping_reply(sef_cb_ping_reply_t cb) /*===========================================================================* * sef_cb_ping_reply_null * *===========================================================================*/ -PUBLIC void sef_cb_ping_reply_null(message *m_ptr) +PUBLIC void sef_cb_ping_reply_null(message *UNUSED(m_ptr)) { } diff --git a/lib/libsys/sys_hz.c b/lib/libsys/sys_hz.c index af6f0346a..33c9c6aad 100644 --- a/lib/libsys/sys_hz.c +++ b/lib/libsys/sys_hz.c @@ -18,7 +18,8 @@ sys_hz(void) /* Get HZ. */ if((r=sys_getinfo(GET_HZ, &Hz, sizeof(Hz), 0, 0)) != OK) { Hz = DEFAULT_HZ; - printf("sys_hz: %d: reverting to HZ = %d\n", r, Hz); + printf("sys_hz: can not get HZ: error %d.\nUsing default HZ = %u\n", + r, (unsigned int) Hz); } } @@ -36,4 +37,3 @@ micros_to_ticks(u32_t micros) return ticks; } -