[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: avoid some warnings in tests
From: |
Eric Blake |
Subject: |
Re: avoid some warnings in tests |
Date: |
Thu, 29 Oct 2009 19:45:21 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Simon Josefsson <simon <at> josefsson.org> writes:
> > In coreutils, I turned on gcc warnings for the gnulib unit tests. This
> > cleans up the modules that are mainly from Jim and myself, and mostly hits
> > places that used 'main ()' or did 'char *foo = "str"'. Simon and Bruno
> > had the most other tests that used 'main ()'; C89 says you should use
> > 'main (void)' or 'main (int, char**)', but I did not clean those up
> > without first getting some feedback to give me the okay.
>
> For me, that has been a cut'n'paste error. If you have time to fix it
> too for my modules, please do!
I will commit this after a bit more testing:
>From e4a6e988f7ff3a4054e513ad79370b153a9fb27b Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 29 Oct 2009 08:47:22 -0600
Subject: [PATCH 1/2] sockets: avoid compiler warning
* lib/sockets.c (gl_sockets_startup): Mark unused parameter.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 3 +++
lib/sockets.c | 10 +++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b0c83b8..899616f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2009-10-29 Eric Blake <address@hidden>
+ sockets: avoid compiler warning
+ * lib/sockets.c (gl_sockets_startup): Mark unused parameter.
+
maint: detect usage(1) and other suspicious exits
* top/maint.mk (sc_prohibit_magic_number_exit): New rule.
diff --git a/lib/sockets.c b/lib/sockets.c
index 7cb9981..cb169f8 100644
--- a/lib/sockets.c
+++ b/lib/sockets.c
@@ -25,12 +25,12 @@
#if WINDOWS_SOCKETS
/* This includes winsock2.h on MinGW. */
-#include <sys/socket.h>
+# include <sys/socket.h>
-#include "close-hook.h"
+# include "close-hook.h"
/* Get set_winsock_errno, FD_TO_SOCKET etc. */
-#include "w32sock.h"
+# include "w32sock.h"
static int
close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
@@ -71,10 +71,10 @@ static struct close_hook close_sockets_hook;
static int initialized_sockets_version /* = 0 */;
-#endif
+#endif /* WINDOWS_SOCKETS */
int
-gl_sockets_startup (int version)
+gl_sockets_startup (int version _UNUSED_PARAMETER_)
{
#if WINDOWS_SOCKETS
if (version > initialized_sockets_version)
--
1.6.4.2
>From bac1acc0e8f9d71e6051f8322302a4ee02db0af3 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 29 Oct 2009 09:15:06 -0600
Subject: [PATCH 2/2] tests: avoid some compiler warnings
* tests/test-getaddrinfo.c (simple): Mark static, and allow string
literals.
* tests/test-memchr.c (main): Avoid type mismatch.
* tests/test-arpa_inet.c (main): Avoid unused parameters.
* tests/test-base64.c (main): Likewise.
* tests/test-getdelim.c (main): Likewise.
* tests/test-gethostname.c (main): Likewise.
* tests/test-getline.c (main): Likewise.
* tests/test-netinet_in.c (main): Likewise.
* tests/test-select.c (open_server_socket, main): Likewise.
* tests/test-select-stdin.c (main): Likewise.
* tests/test-sockets.c (main): Likewise.
* tests/test-strsignal.c (main): Likewise.
* tests/test-sys_select.c (main): Likewise.
* tests/test-sys_socket.c (main): Likewise.
* tests/test-u64.c (main): Likewise.
* tests/test-xfprintf-posix.c (main): Likewise.
* tests/test-xvasprintf.c (test_xvasprintf, main): Likewise.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 20 ++++++++++++++++++++
tests/test-arpa_inet.c | 4 ++--
tests/test-base64.c | 4 ++--
tests/test-getaddrinfo.c | 3 ++-
tests/test-getdelim.c | 4 ++--
tests/test-gethostname.c | 2 +-
tests/test-getline.c | 4 ++--
tests/test-memchr.c | 2 +-
tests/test-netinet_in.c | 4 ++--
tests/test-select-stdin.c | 4 ++--
tests/test-select.c | 4 ++--
tests/test-sockets.c | 2 +-
tests/test-strsignal.c | 4 ++--
tests/test-sys_select.c | 2 +-
tests/test-sys_socket.c | 2 +-
tests/test-u64.c | 2 +-
tests/test-xfprintf-posix.c | 4 ++--
tests/test-xvasprintf.c | 6 +++---
18 files changed, 49 insertions(+), 28 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 899616f..bda6fbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
2009-10-29 Eric Blake <address@hidden>
+ tests: avoid some compiler warnings
+ * tests/test-getaddrinfo.c (simple): Mark static, and allow string
+ literals.
+ * tests/test-memchr.c (main): Avoid type mismatch.
+ * tests/test-arpa_inet.c (main): Avoid unused parameters.
+ * tests/test-base64.c (main): Likewise.
+ * tests/test-getdelim.c (main): Likewise.
+ * tests/test-gethostname.c (main): Likewise.
+ * tests/test-getline.c (main): Likewise.
+ * tests/test-netinet_in.c (main): Likewise.
+ * tests/test-select.c (open_server_socket, main): Likewise.
+ * tests/test-select-stdin.c (main): Likewise.
+ * tests/test-sockets.c (main): Likewise.
+ * tests/test-strsignal.c (main): Likewise.
+ * tests/test-sys_select.c (main): Likewise.
+ * tests/test-sys_socket.c (main): Likewise.
+ * tests/test-u64.c (main): Likewise.
+ * tests/test-xfprintf-posix.c (main): Likewise.
+ * tests/test-xvasprintf.c (test_xvasprintf, main): Likewise.
+
sockets: avoid compiler warning
* lib/sockets.c (gl_sockets_startup): Mark unused parameter.
diff --git a/tests/test-arpa_inet.c b/tests/test-arpa_inet.c
index fc2d8ba..1e2479f 100644
--- a/tests/test-arpa_inet.c
+++ b/tests/test-arpa_inet.c
@@ -1,5 +1,5 @@
/* Test of <arpa/inet.h> substitute.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
#include <arpa/inet.h>
int
-main ()
+main (void)
{
return 0;
}
diff --git a/tests/test-base64.c b/tests/test-base64.c
index f707a9e..7440e8c 100644
--- a/tests/test-base64.c
+++ b/tests/test-base64.c
@@ -1,5 +1,5 @@
/* Self tests for base64.
- Copyright (C) 2004, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software: you can redistribute it and/or modify
@@ -25,7 +25,7 @@
#include "base64.h"
int
-main (int argc, char *argv[])
+main (void)
{
const char *in = "abcdefghijklmnop";
const char *b64in = "YWJjZGVmZw==";
diff --git a/tests/test-getaddrinfo.c b/tests/test-getaddrinfo.c
index eeea3f7..384b98b 100644
--- a/tests/test-getaddrinfo.c
+++ b/tests/test-getaddrinfo.c
@@ -44,7 +44,8 @@
# define EAI_SERVICE 0
#endif
-int simple (char *host, char *service)
+static int
+simple (char const *host, char const *service)
{
char buf[BUFSIZ];
static int skip = 0;
diff --git a/tests/test-getdelim.c b/tests/test-getdelim.c
index 0c112f6..da4fe6b 100644
--- a/tests/test-getdelim.c
+++ b/tests/test-getdelim.c
@@ -1,5 +1,5 @@
/* Test of getdelim() function.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@
while (0)
int
-main (int argc, char **argv)
+main (void)
{
FILE *f;
char *line = NULL;
diff --git a/tests/test-gethostname.c b/tests/test-gethostname.c
index 3ab0b86..32723da 100644
--- a/tests/test-gethostname.c
+++ b/tests/test-gethostname.c
@@ -29,7 +29,7 @@
#define NOHOSTNAME "magic-gnulib-test-string"
int
-main (int argc, char *argv[])
+main (int argc, char *argv[] _UNUSED_PARAMETER_)
{
char buf[HOST_NAME_MAX];
int rc;
diff --git a/tests/test-getline.c b/tests/test-getline.c
index 51fc816..50722cd 100644
--- a/tests/test-getline.c
+++ b/tests/test-getline.c
@@ -1,5 +1,5 @@
/* Test of getline() function.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@
while (0)
int
-main (int argc, char **argv)
+main (void)
{
FILE *f;
char *line = NULL;
diff --git a/tests/test-memchr.c b/tests/test-memchr.c
index a8cfc9b..d5e53e0 100644
--- a/tests/test-memchr.c
+++ b/tests/test-memchr.c
@@ -109,7 +109,7 @@ main (void)
ASSERT (MEMCHR (mem, 'U', n) == NULL);
{
- int i;
+ size_t i;
for (i = 0; i < n; i++)
{
diff --git a/tests/test-netinet_in.c b/tests/test-netinet_in.c
index b195719..5a61557 100644
--- a/tests/test-netinet_in.c
+++ b/tests/test-netinet_in.c
@@ -1,5 +1,5 @@
/* Test of <netinet/in.h> substitute.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
#include <netinet/in.h>
int
-main ()
+main (void)
{
return 0;
}
diff --git a/tests/test-select-stdin.c b/tests/test-select-stdin.c
index e855f92..079dec5 100644
--- a/tests/test-select-stdin.c
+++ b/tests/test-select-stdin.c
@@ -1,5 +1,5 @@
/* Test of select() substitute, reading from stdin.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
#include <unistd.h>
int
-main ()
+main (void)
{
printf ("Applying select() from standard input. Press Ctrl-C to abort.\n");
for (;;)
diff --git a/tests/test-select.c b/tests/test-select.c
index ec82250..d6d6b06 100644
--- a/tests/test-select.c
+++ b/tests/test-select.c
@@ -84,7 +84,7 @@ test (void (*fn) (void), const char *msg)
/* Funny socket code. */
static int
-open_server_socket ()
+open_server_socket (void)
{
int s, x;
struct sockaddr_in ia;
@@ -355,7 +355,7 @@ test_pipe (void)
/* Do them all. */
int
-main ()
+main (void)
{
int result;
diff --git a/tests/test-sockets.c b/tests/test-sockets.c
index 3c85a43..2d25964 100644
--- a/tests/test-sockets.c
+++ b/tests/test-sockets.c
@@ -22,7 +22,7 @@
#include "sockets.h"
int
-main (int argc, char *argv[])
+main (void)
{
int err;
diff --git a/tests/test-strsignal.c b/tests/test-strsignal.c
index 8868346..a4be4b7 100644
--- a/tests/test-strsignal.c
+++ b/tests/test-strsignal.c
@@ -1,5 +1,5 @@
/* Test of strsignal() function.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
#endif
int
-main (int argc, char **argv)
+main (void)
{
/* Work around bug in cygwin 1.5.25 <string.h> by declaring str as
const char *, even though strsignal is supposed to return char *.
diff --git a/tests/test-sys_select.c b/tests/test-sys_select.c
index 6607952..aef8941 100644
--- a/tests/test-sys_select.c
+++ b/tests/test-sys_select.c
@@ -24,7 +24,7 @@
struct timeval t1;
int
-main ()
+main (void)
{
/* Check that FD_ZERO can be used. This should not yield a warning
such as "warning: implicit declaration of function 'memset'". */
diff --git a/tests/test-sys_socket.c b/tests/test-sys_socket.c
index 3d946a8..ddb491b 100644
--- a/tests/test-sys_socket.c
+++ b/tests/test-sys_socket.c
@@ -28,7 +28,7 @@ int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };
#endif
int
-main ()
+main (void)
{
struct sockaddr_storage x;
sa_family_t i;
diff --git a/tests/test-u64.c b/tests/test-u64.c
index 85e7247..aa0b5d1 100644
--- a/tests/test-u64.c
+++ b/tests/test-u64.c
@@ -21,7 +21,7 @@
#include <u64.h>
int
-main ()
+main (void)
{
u64 i = u64init (42, 4711);
u64 j, k, l;
diff --git a/tests/test-xfprintf-posix.c b/tests/test-xfprintf-posix.c
index adfa1fd..b001f04 100644
--- a/tests/test-xfprintf-posix.c
+++ b/tests/test-xfprintf-posix.c
@@ -1,5 +1,5 @@
/* Test of error-checking xfprintf() function with POSIX compatible formatting.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
#include "test-fprintf-posix.h"
int
-main (int argc, char *argv[])
+main (int argc _UNUSED_PARAMETER_, char *argv[])
{
set_program_name (argv[0]);
diff --git a/tests/test-xvasprintf.c b/tests/test-xvasprintf.c
index 234ec83..3760314 100644
--- a/tests/test-xvasprintf.c
+++ b/tests/test-xvasprintf.c
@@ -1,5 +1,5 @@
/* Test of xvasprintf() and xasprintf() functions.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -52,7 +52,7 @@ my_xasprintf (const char *format, ...)
}
static void
-test_xvasprintf ()
+test_xvasprintf (void)
{
int repeat;
@@ -80,7 +80,7 @@ test_xasprintf ()
}
int
-main (int argc, char *argv[])
+main (int argc _UNUSED_PARAMETER_, char *argv[])
{
set_program_name (argv[0]);
--
1.6.4.2