[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] pthread tests: fix missing-declarations warning.
From: |
Bruno Haible |
Subject: |
Re: [PATCH] pthread tests: fix missing-declarations warning. |
Date: |
Mon, 22 Jul 2019 12:39:41 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-154-generic; KDE/5.18.0; x86_64; ; ) |
Hi Berny,
> +2019-07-22 Bernhard Voelker <address@hidden>
> +
> + pthread tests: fix missing-declarations warning.
> + Running tests on GCC-9.1.1 with -Werror stops at:
> + test-pthread-cond.c:87:1: error: no previous declaration for \
> + 'test_pthread_cond_wait' [-Werror=missing-declarations]
> + 87 | test_pthread_cond_wait ()
> + | ^~~~~~~~~~~~~~~~~~~~~~
> + * tests/test-pthread-cond.c (test_pthread_cond_wait): Declare static.
Thanks. Applied, but
- without the mention of -Werror. In gnulib, we don't support the use of
-Werror. We do try, however, to avoid warnings on a case-by-case basis.
-Wmissing-declarations is a generally useful warning option, so your
patch is welcome.
- with a shorter ChangeLog entry. The ChangeLog entry does not need to
go into that much detail. Just mentioning that there was a
missing-declarations warning is enough. The rest of the justification
is for the mailing-list only.
Following your patch, I did the same thing in a couple of other files:
2019-07-22 Bruno Haible <address@hidden>
Avoid missing-declarations warning in various tests.
* tests/test-argp.c (fail, test1, test2, test_file, test3, test4, test5,
test6, test_optional, test7, test8, test9, test10, test11, test12,
test13, test14, test15, test_fun): Declare static.
* tests/test-cnd.c (test_cnd_wait): Likewise.
* tests/test-cond.c (test_cond): Likewise.
diff --git a/tests/test-argp.c b/tests/test-argp.c
index 0713d7f..86ddbf3 100644
--- a/tests/test-argp.c
+++ b/tests/test-argp.c
@@ -279,14 +279,14 @@ struct argp test_argp = {
int test_number;
unsigned failure_count = 0;
-void
+static void
fail (const char *msg)
{
fprintf (stderr, "Test %d: %s\n", test_number, msg);
failure_count++;
}
-void
+static void
test1 (struct argp *argp)
{
INIT_TEST1 (1, "--test");
@@ -296,7 +296,7 @@ test1 (struct argp *argp)
fail ("option not processed");
}
-void
+static void
test2 (struct argp *argp)
{
INIT_TEST1 (2, "-t");
@@ -306,7 +306,7 @@ test2 (struct argp *argp)
fail ("option not processed");
}
-void
+static void
test_file (struct argp *argp, int argc, char **argv, struct test_args *args)
{
if (argp_parse (argp, argc, argv, 0, NULL, args))
@@ -317,35 +317,35 @@ test_file (struct argp *argp, int argc, char **argv,
struct test_args *args)
fail ("option processed incorrectly");
}
-void
+static void
test3 (struct argp *argp)
{
INIT_TEST1 (3, "--file=FILE");
test_file (argp, argc, argv, &test_args);
}
-void
+static void
test4 (struct argp *argp)
{
INIT_TEST2 (4, "--file", "FILE");
test_file (argp, argc, argv, &test_args);
}
-void
+static void
test5 (struct argp *argp)
{
INIT_TEST1 (5, "--input=FILE");
test_file (argp, argc, argv, &test_args);
}
-void
+static void
test6 (struct argp *argp)
{
INIT_TEST2 (6, "--input", "FILE");
test_file (argp, argc, argv, &test_args);
}
-void
+static void
test_optional (struct argp *argp, int argc, char **argv,
struct test_args *args, const char *val, const char *a)
{
@@ -372,49 +372,49 @@ test_optional (struct argp *argp, int argc, char **argv,
}
}
-void
+static void
test7 (struct argp *argp)
{
INIT_TEST1 (7, "-oARG");
test_optional (argp, argc, argv, &test_args, "ARG", NULL);
}
-void
+static void
test8 (struct argp *argp)
{
INIT_TEST2 (8, "-o", "ARG");
test_optional (argp, argc, argv, &test_args, NULL, "ARG");
}
-void
+static void
test9 (struct argp *argp)
{
INIT_TEST1 (9, "--optional=ARG");
test_optional (argp, argc, argv, &test_args, "ARG", NULL);
}
-void
+static void
test10 (struct argp *argp)
{
INIT_TEST2 (10, "--optional", "ARG");
test_optional (argp, argc, argv, &test_args, NULL, "ARG");
}
-void
+static void
test11 (struct argp *argp)
{
INIT_TEST1 (11, "--optiona=ARG");
test_optional (argp, argc, argv, &test_args, "ARG", NULL);
}
-void
+static void
test12 (struct argp *argp)
{
INIT_TEST3 (12, "--option", "--optional=OPT", "FILE");
test_optional (argp, argc, argv, &test_args, "OPT", "FILE");
}
-void
+static void
test13 (struct argp *argp)
{
INIT_TEST1 (1, "--cantiga");
@@ -424,7 +424,7 @@ test13 (struct argp *argp)
fail ("option not processed");
}
-void
+static void
test14 (struct argp *argp)
{
INIT_TEST1 (1, "--limerick");
@@ -434,7 +434,7 @@ test14 (struct argp *argp)
fail ("option not processed");
}
-void
+static void
test15 (struct argp *argp)
{
INIT_TEST2 (1, "-r", "FILE");
@@ -446,7 +446,7 @@ test15 (struct argp *argp)
typedef void (*test_fp) (struct argp *argp);
-test_fp test_fun[] = {
+static test_fp test_fun[] = {
test1, test2, test3, test4,
test5, test6, test7, test8,
test9, test10, test11, test12,
diff --git a/tests/test-cnd.c b/tests/test-cnd.c
index bd8d4f2..074c2c7 100644
--- a/tests/test-cnd.c
+++ b/tests/test-cnd.c
@@ -78,7 +78,7 @@ cnd_wait_routine (void *arg)
return 0;
}
-void
+static void
test_cnd_wait ()
{
struct timespec remain;
diff --git a/tests/test-cond.c b/tests/test-cond.c
index e8bd472..794fb2d 100644
--- a/tests/test-cond.c
+++ b/tests/test-cond.c
@@ -78,7 +78,7 @@ cond_routine (void *arg)
return NULL;
}
-void
+static void
test_cond ()
{
int remain = 2;