Commit ad2ce76c authored by Rusty Russell's avatar Rusty Russell

Mark unused arguments in many modules.

Either with UNNEEDED (if the module already used ccan/compiler) or
with (void) casting.

The only other change is in ccan/list/test/run-CCAN_LIST_DEBUG.c, because
the linenumbers change and thus it needs updating.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 58774026
......@@ -2,6 +2,8 @@
int main(int argc, char *argv[8])
{
(void)argc;
(void)argv;
char array[100];
#ifdef FAIL
return ARRAY_SIZE(argv) + ARRAY_SIZE(array);
......
#include <ccan/asort/asort.h>
#include <ccan/asort/asort.c>
static int cmp(char *const *a, char *const *b, int *flag)
static int cmp(char *const *a UNNEEDED, char *const *b UNNEEDED, int *flag UNNEEDED)
{
return 0;
}
......
......@@ -11,7 +11,7 @@ void *autodata_get_section(void *start, void *stop, size_t *nump)
return start;
}
void autodata_free(void *table)
void autodata_free(void *table UNNEEDED)
{
}
#else
......
......@@ -6,5 +6,6 @@ static char *p = cast_const(char *, (const char *)"hello");
int main(int argc, char *argv[])
{
(void)argc;
return p[0] == argv[0][0];
}
......@@ -2,6 +2,8 @@
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
#ifdef FAIL
check_type(argc, char);
#endif
......
......@@ -2,6 +2,8 @@
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
#ifdef FAIL
#if HAVE_TYPEOF
check_type(argc, unsigned int);
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
unsigned char x = argc;
(void)argv;
#ifdef FAIL
check_types_match(argc, x);
#endif
......
......@@ -5,6 +5,7 @@ int main(int argc, char *argv[])
{
int x = 0, y = 0;
(void)argv;
plan_tests(9);
ok1(check_type(argc, int) == 0);
......
......@@ -41,7 +41,7 @@
* va_end(ap);
* }
*
* int main(int argc, char *argv[])
* int main(int argc, char *argv[] UNNEEDED)
* {
* if (argc != 1) {
* logger(3, "Don't want %i arguments!\n", argc-1);
......
......@@ -2,9 +2,11 @@
static void PRINTF_FMT(2,3) my_printf(int x, const char *fmt, ...)
{
(void)x;
(void)fmt;
}
int main(int argc, char *argv[])
int main(void)
{
unsigned int i = 0;
......
......@@ -3,6 +3,8 @@
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
plan_tests(2);
ok1(!IS_COMPILE_CONSTANT(argc));
......
......@@ -45,6 +45,7 @@ static void check_siphash24(struct siphash24_ctx *ctx)
static bool alignment_ok(const void *p, size_t n)
{
#if HAVE_UNALIGNED_ACCESS
(void)p; (void)n;
return true;
#else
return ((size_t)p % n == 0);
......
......@@ -15,6 +15,7 @@ int main(int argc, char *argv[])
int pfd[2];
const char *base;
(void)argc;
plan_tests(24);
err_set_progname(argv[0]);
......
......@@ -36,6 +36,7 @@
* // Wrapper for rehash function pointer.
* static size_t rehash(const void *e, void *unused)
* {
* (void)unused;
* return hash_string(((struct name_to_digit *)e)->name);
* }
*
......
......@@ -35,6 +35,7 @@ struct htable {
* // For simplicity's sake, say hash value is contents of elem.
* static size_t rehash(const void *elem, void *unused)
* {
* (void)unused;
* return *(size_t *)elem;
* }
* static struct htable ht = HTABLE_INITIALIZER(ht, rehash, NULL);
......
......@@ -6,7 +6,7 @@
#define NUM_VALS 512
static size_t hash(const void *elem, void *unused)
static size_t hash(const void *elem, void *unused UNNEEDED)
{
size_t h = *(uint64_t *)elem / 2;
return h;
......
......@@ -8,7 +8,7 @@
/* We use the number divided by two as the hash (for lots of
collisions). */
static size_t hash(const void *elem, void *unused)
static size_t hash(const void *elem, void *unused UNNEEDED)
{
size_t h = *(uint64_t *)elem / 2;
return h;
......
......@@ -88,7 +88,7 @@ static void del_vals(struct htable_obj *ht,
}
static void del_vals_bykey(struct htable_obj *ht,
const struct obj val[], unsigned int num)
const struct obj val[] UNNEEDED, unsigned int num)
{
unsigned int i;
......
......@@ -8,7 +8,7 @@ struct data {
};
/* Hash is simply key itself. */
static size_t hash(const void *e, void *unused)
static size_t hash(const void *e, void *unused UNNEEDED)
{
struct data *d = (struct data *)e;
......
......@@ -10,7 +10,7 @@
/* We use the number divided by two as the hash (for lots of
collisions), plus set all the higher bits so we can detect if they
don't get masked out. */
static size_t hash(const void *elem, void *unused)
static size_t hash(const void *elem, void *unused UNNEEDED)
{
size_t h = *(uint64_t *)elem / 2;
h |= -1UL << NUM_BITS;
......
......@@ -17,6 +17,7 @@ static int my_fprintf(FILE *stream, const char *format, ...)
{
va_list ap;
int ret;
(void)stream;
va_start(ap, format);
ret = vsprintf(printf_buffer, format, ap);
va_end(ap);
......@@ -44,7 +45,7 @@ int main(void)
list.n.prev = &n1;
/* Aborting version. */
sprintf(expect, "run-CCAN_LIST_DEBUG.c:50: prev corrupt in node %p (0) of %p\n",
sprintf(expect, "run-CCAN_LIST_DEBUG.c:51: prev corrupt in node %p (0) of %p\n",
&list, &list);
if (setjmp(aborted) == 0) {
assert(list_empty(&list));
......
......@@ -16,6 +16,7 @@ static int my_fprintf(FILE *stream, const char *format, ...)
{
va_list ap;
int ret;
(void)stream;
va_start(ap, format);
ret = vsprintf(printf_buffer, format, ap);
va_end(ap);
......
......@@ -250,6 +250,7 @@ static inline void *memcheck_(const void *data, size_t len)
#else
static inline void *memcheck_(const void *data, size_t len)
{
(void)len;
return (void *)data;
}
#endif
......
......@@ -185,7 +185,7 @@ void opt_register_table(const struct opt_table *table, const char *desc);
* string (or see opt_set_alloc) and return false.
*
* Example:
* static char *explode(const char *optarg, void *unused)
* static char *explode(const char *optarg, void *unused UNNEEDED)
* {
* errx(1, "BOOM! %s", optarg);
* }
......
......@@ -4,13 +4,13 @@
#include <ccan/opt/helpers.c>
#include <ccan/opt/parse.c>
static void show_10(char buf[OPT_SHOW_LEN], const void *arg)
static void show_10(char buf[OPT_SHOW_LEN], const void *arg UNNEEDED)
{
memset(buf, 'X', 10);
buf[10] = '\0';
}
static void show_max(char buf[OPT_SHOW_LEN], const void *arg)
static void show_max(char buf[OPT_SHOW_LEN], const void *arg UNNEEDED)
{
memset(buf, 'X', OPT_SHOW_LEN);
}
......
......@@ -52,7 +52,7 @@ static int saved_printf(const char *fmt, ...)
return ret;
}
static int saved_fprintf(FILE *ignored, const char *fmt, ...)
static int saved_fprintf(FILE *ignored UNNEEDED, const char *fmt, ...)
{
va_list ap;
int ret;
......
......@@ -2,15 +2,15 @@
#include <stdlib.h>
/* Make sure we override these! */
static void *no_malloc(size_t size)
static void *no_malloc(size_t size UNNEEDED)
{
abort();
}
static void *no_realloc(void *p, size_t size)
static void *no_realloc(void *p UNNEEDED, size_t size UNNEEDED)
{
abort();
}
static void no_free(void *p)
static void no_free(void *p UNNEEDED)
{
abort();
}
......
......@@ -6,7 +6,7 @@
#include "utils.h"
/* Ensure width is sane. */
static const char *getenv_override(const char *name)
static const char *getenv_override(const char *name UNNEEDED)
{
return "100";
}
......@@ -18,13 +18,13 @@ static const char *getenv_override(const char *name)
#include <ccan/opt/helpers.c>
#include <ccan/opt/parse.c>
static char *my_cb(void *p)
static char *my_cb(void *p UNNEEDED)
{
return NULL;
}
/* Test helpers. */
int main(int argc, char *argv[])
int main(void)
{
char *output;
char *longname = strdup("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
......
......@@ -8,7 +8,7 @@
#include "utils.h"
unsigned int test_cb_called;
char *test_noarg(void *arg)
char *test_noarg(void *arg UNNEEDED)
{
test_cb_called++;
return NULL;
......
......@@ -24,7 +24,7 @@
const _type *b, \
void *ctx) \
{ \
return _order_##_oname(a, b, int2ptr(0)); \
(void)ctx; return _order_##_oname(a, b, int2ptr(0)); \
} \
int _order_##_oname##_reverse(const void *a, \
const void *b, \
......@@ -36,6 +36,7 @@
const _type *b, \
void *ctx) \
{ \
(void)ctx; \
return _order_##_oname##_reverse(a, b, int2ptr(0)); \
} \
int order_##_oname##_noctx(const void *a, \
......
......@@ -17,6 +17,7 @@ static int p2c[2], c2p[2];
static void got_signal(int sig)
{
char c = 0;
(void)sig;
if (write(p2c[1], &c, 1) == 1)
sigcount++;
}
......
......@@ -19,6 +19,9 @@ static ssize_t write_return;
static ssize_t test_write(int fd, const void *buf, size_t count)
{
(void)fd;
(void)buf;
if (write_return == 0) {
errno = ENOSPC;
return 0;
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check isalnum.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check isalpha.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check isascii.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF || !HAVE_ISBLANK
#error We need typeof to check isblank.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check iscntrl.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check isdigit.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check islower.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check isprint.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check ispunct.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check isspace.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check isupper.
......
......@@ -3,6 +3,7 @@
int main(int argc, char *argv[])
{
(void)argc;
#ifdef FAIL
#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
#error We need typeof to check isxdigit.
......
......@@ -16,10 +16,11 @@
* license_depends_compat FAIL
*
* Example:
* #include <ccan/compiler/compiler.h>
* #include <ccan/strmap/strmap.h>
* #include <stdio.h>
*
* static bool dump(const char *member, size_t value, void *unused)
* static bool dump(const char *member, size_t value, void *unused UNNEEDED)
* {
* printf("%s at %zu. ", member, value);
* // true means keep going with iteration.
......
......@@ -5,7 +5,7 @@
static bool found = false;
/* Make sure const args work. */
static bool find_string(const char *str, char *member, const char *cmp)
static bool find_string(const char *str UNNEEDED, char *member, const char *cmp)
{
if (strcmp(member, cmp) == 0)
found = true;
......
......@@ -15,7 +15,7 @@ static bool in_order(const char *index, char *value, unsigned int *count)
return true;
}
static bool find_empty(const char *index, char *value, char *empty)
static bool find_empty(const char *index, char *value UNNEEDED, char *empty)
{
if (index == empty)
pass("Found empty entry!");
......
......@@ -15,7 +15,7 @@ static void *my_realloc(void *p, size_t len)
#include <ccan/tap/tap.h>
static int my_allocfail_called;
static void my_allocfail(const void *p)
static void my_allocfail(const void *p UNNEEDED)
{
my_allocfail_called++;
}
......
......@@ -15,7 +15,7 @@ struct link {
static void linkable_notifier(tal_t *linkable,
enum tal_notify_type type,
void *info)
void *info UNNEEDED)
{
struct linkable *l = tal_parent(linkable);
assert(type == TAL_NOTIFY_STEAL || type == TAL_NOTIFY_FREE);
......
......@@ -4,7 +4,7 @@
#include <err.h>
static unsigned int destroy_count = 0;
static void destroy_obj(void *obj)
static void destroy_obj(void *obj UNNEEDED)
{
destroy_count++;
}
......
......@@ -171,6 +171,7 @@ char *tal_strjoin(const void *ctx, char *strings[], const char *delim,
* {
* char *person, *input;
*
* (void)argc;
* // Join args and trim trailing space.
* input = tal_strjoin(NULL, argv+1, " ", STR_NO_TRAIL);
* if (tal_strreg(NULL, input,
......
......@@ -323,7 +323,7 @@ static struct name *add_name_property(struct tal_hdr *t, const char *name)
}
static struct children *add_child_property(struct tal_hdr *parent,
struct tal_hdr *child)
struct tal_hdr *child UNNEEDED)
{
struct children *prop = allocate(sizeof(*prop));
if (prop) {
......
......@@ -30,7 +30,7 @@ static void nofail_on_error(const char *msg)
err_count++;
}
static void destroy_p(void *p)
static void destroy_p(void *p UNNEEDED)
{
}
......
......@@ -24,7 +24,7 @@ static void destroy_child(char *p)
destroy_count++;
}
static void destroy_inc(char *p)
static void destroy_inc(char *p UNNEEDED)
{
destroy_count++;
}
......
......@@ -2,7 +2,7 @@
#include <ccan/tal/tal.c>
#include <ccan/tap/tap.h>
static void destroy_errno(char *p)
static void destroy_errno(char *p UNNEEDED)
{
errno = ENOENT;
}
......
......@@ -20,7 +20,7 @@ static void *my_realloc(void *old, size_t size)
return new;
}
static void notify1(char *p, enum tal_notify_type notify, void *info)
static void notify1(char *p UNNEEDED, enum tal_notify_type notify, void *info)
{
ok1(ctx == ctx);
ok1(notify == expect);
......@@ -31,7 +31,9 @@ static void notify1(char *p, enum tal_notify_type notify, void *info)
notified1++;
}
static void notify2(char *ctx, enum tal_notify_type notify, void *info)
static void notify2(char *ctx UNNEEDED,
enum tal_notify_type notify UNNEEDED,
void *info UNNEEDED)
{
notified2++;
}
......
......@@ -4,7 +4,7 @@
static int error_count;
static void my_error(const char *msg)
static void my_error(const char *msg UNNEEDED)
{
error_count++;
}
......
......@@ -31,7 +31,7 @@ static void *my_realloc(void *old, size_t new_size)
#define NUM_ALLOCS 1000
static void destroy_p(void *p)
static void destroy_p(void *p UNNEEDED)
{
}
......
......@@ -15,6 +15,7 @@ int main(int argc, char *argv[])
struct void_container vcon;
TCON_WRAP(struct container, void *canary) vconw;
(void)argc;
tcon_check(&vcon, canary, NULL)->raw.p = NULL;
tcon_check(&vcon, canary, argv[0])->raw.p = NULL;
tcon_check(&vcon, canary, main)->raw.p = NULL;
......
......@@ -23,6 +23,7 @@ int main(int argc, char *argv[])
TCON_WRAP(struct container, int tc) iconw;
TCON_WRAP(struct container, int tc1; char *tc2) ciconw;
(void)argc;
tcon_check(&icon, tc, 7)->raw.p = NULL;
tcon_check(&cicon, tc1, 7)->raw.p = argv[0];
tcon_check(&cicon, tc2, argv[0])->raw.p = argv[0];
......
......@@ -31,6 +31,7 @@
* struct timer *t;
* struct timed_string *s;
*
* (void)argc;
* timers_init(&timers, time_mono());
* list_head_init(&strings);
*
......
......@@ -114,7 +114,7 @@ void timer_addmono(struct timers *timers, struct timer *t, struct timemono when)
}
/* FIXME: inline */
void timer_del(struct timers *timers, struct timer *t)
void timer_del(struct timers *timers UNNEEDED, struct timer *t)
{
list_del_init(&t->list);
}
......
......@@ -3,6 +3,7 @@
static void _set_some_value(void *val)
{
(void)val;
}
#define set_some_value(expr) \
......
......@@ -15,6 +15,7 @@ void _callback(void (*fn)(void *arg), void *arg)
void my_callback(int something);
void my_callback(int something)
{
(void)something;
}
int main(void)
......
......@@ -3,6 +3,8 @@
static void _register_callback(void (*cb)(void *arg), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback(cb, arg) \
......@@ -10,6 +12,7 @@ static void _register_callback(void (*cb)(void *arg), void *arg)
static void my_callback(char *p)
{
(void)p;
}
int main(void)
......
......@@ -23,6 +23,7 @@ struct other {
static void take_any(struct any *any)
{
(void)any;
}
int main(void)
......
......@@ -4,6 +4,7 @@ void _set_some_value(void *val);
void _set_some_value(void *val)
{
(void)val;
}
#define set_some_value(expr) \
......
......@@ -3,12 +3,16 @@
static void _register_callback(void (*cb)(void *arg, int x), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback(cb, arg) \
_register_callback(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg))
static void my_callback(char *p, int x)
{
(void)p;
(void)x;
}
int main(void)
......
......@@ -3,6 +3,8 @@
static void _register_callback(void (*cb)(int x, void *arg), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback(cb, arg) \
......@@ -10,6 +12,8 @@ static void _register_callback(void (*cb)(int x, void *arg), void *arg)
static void my_callback(int x, char *p)
{
(void)p;
(void)x;
}
int main(void)
......
......@@ -5,6 +5,8 @@
static void _register_callback(void (*cb)(const void *arg), const void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback(cb, arg) \
......
......@@ -5,6 +5,8 @@
static void _register_callback(void (*cb)(void *arg), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback(cb, arg) \
......@@ -12,6 +14,8 @@ static void _register_callback(void (*cb)(void *arg), void *arg)
static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback_pre(cb, arg) \
......@@ -19,6 +23,8 @@ static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
static void _register_callback_post(void (*cb)(void *arg, int x), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback_post(cb, arg) \
......@@ -28,14 +34,19 @@ struct undefined;
static void my_callback(struct undefined *undef)
{
(void)undef;
}
static void my_callback_pre(int x, struct undefined *undef)
{
(void)x;
(void)undef;
}
static void my_callback_post(struct undefined *undef, int x)
{
(void)undef;
(void)x;
}
int main(void)
......
......@@ -5,6 +5,8 @@
static void _register_callback(void (*cb)(void *arg), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback(cb, arg) \
......@@ -12,6 +14,8 @@ static void _register_callback(void (*cb)(void *arg), void *arg)
static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback_pre(cb, arg) \
......@@ -19,6 +23,8 @@ static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
static void _register_callback_post(void (*cb)(void *arg, int x), void *arg)
{
(void)cb;
(void)arg;
}
#define register_callback_post(cb, arg) \
......@@ -28,14 +34,19 @@ struct undefined;
static void my_callback(struct undefined *undef)
{
(void)undef;
}
static void my_callback_pre(int x, struct undefined *undef)
{
(void)x;
(void)undef;
}
static void my_callback_post(struct undefined *undef, int x)
{
(void)x;
(void)undef;
}
int main(void)
......
......@@ -19,6 +19,7 @@ struct any {
static void take_any(struct any *any)
{
(void)any;
}
int main(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment