From afca2864dc6464201dfe32134ae20e0107297836 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 10 Jun 2013 15:22:17 +0200 Subject: [PATCH] tests: Fix warnings about unused parameters. --- src/compiler.h | 2 ++ tests/example.c | 6 ++++-- tests/example_error.c | 7 ++++++- tests/example_exec.c | 6 +++++- tests/example_vfork.c | 7 ++++++- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/compiler.h b/src/compiler.h index 4a69adf..5ede8b2 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -24,9 +24,11 @@ #ifdef HAVE___ATTRIBUTE__ # define noinline __attribute__((noinline)) # define always_inline __attribute__((always_inline)) +# define unused __attribute__((unused)) #else # define noinline # define always_inline +# define unused #endif /* Branch prediction information for the compiler. */ diff --git a/tests/example.c b/tests/example.c index 545f3cb..7f7d2ad 100644 --- a/tests/example.c +++ b/tests/example.c @@ -17,15 +17,17 @@ * along with this program. If not, see . */ +#include + #include #include #include #include +#include "../src/compiler.h" -int main(int argc, char **argv) { - (void)argv; +int main(int argc, char **argv unused) { fprintf(stderr, "write to stderr: %d\n", argc); printf("write to stdout\n"); fflush(stdout); diff --git a/tests/example_error.c b/tests/example_error.c index 04eca8d..e114049 100644 --- a/tests/example_error.c +++ b/tests/example_error.c @@ -17,12 +17,17 @@ * along with this program. If not, see . */ +#include + #define _GNU_SOURCE /* for program_invocation_name */ #include #include #include #include +#include "../src/compiler.h" + + void (*error_print_progname)(void); @@ -31,7 +36,7 @@ static void print_prognmae(void) { } -int main(int argc, char **argv) { +int main(int argc unused, char **argv unused) { program_invocation_name = "./example_error"; error(0, 0, ""); diff --git a/tests/example_exec.c b/tests/example_exec.c index 3a18567..bd12b5a 100644 --- a/tests/example_exec.c +++ b/tests/example_exec.c @@ -17,11 +17,15 @@ * along with this program. If not, see . */ +#include + #include #include #include #include +#include "../src/compiler.h" + #define MAGIC "@RUN_" #define MAGIC_LENGTH (strlen(MAGIC)) @@ -75,7 +79,7 @@ static void dump(char *argv[]) { } -int main(int argc, char **argv) { +int main(int argc unused, char **argv) { char argv0[strlen(argv[0]) + MAGIC_LENGTH + 3 + 1]; char *old_ldpreload = getenv("LD_PRELOAD"); diff --git a/tests/example_vfork.c b/tests/example_vfork.c index ed94e56..8c4aec9 100644 --- a/tests/example_vfork.c +++ b/tests/example_vfork.c @@ -17,12 +17,17 @@ * along with this program. If not, see . */ +#include + #include #include #include #include -int main(int argc, char **argv) { +#include "../src/compiler.h" + + +int main(int argc unused, char **argv unused) { pid_t pid; fprintf(stderr, "Before vfork().\n"); -- 2.43.2