From 885a2e57e7963e7bc3b1859029c70f7ba12bd1ee Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 3 Oct 2022 18:16:43 -0400 Subject: [PATCH 1/5] rbldnsd_util.c: fix two comment typos. --- rbldnsd_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rbldnsd_util.c b/rbldnsd_util.c index eeafd07..68ffbe5 100644 --- a/rbldnsd_util.c +++ b/rbldnsd_util.c @@ -50,10 +50,10 @@ char *parse_time(char *s, unsigned *tp) { case 'w': case 'W': m *= 7; /* week */ case 'd': case 'D': m *= 24; /* day */ case 'h': case 'H': m *= 60; /* hours */ - case 'm': case 'M': m *= 60; /* minues */ + case 'm': case 'M': m *= 60; /* minutes */ if (0xffffffffu / m < *tp) return NULL; *tp *= m; - case 's': case 'S': /* secounds */ + case 's': case 'S': /* seconds */ ++s; break; } From 5a32b4aebd8e1a85d513e67f6918298790066dc9 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 3 Oct 2022 18:18:00 -0400 Subject: [PATCH 2/5] configure.lib: fix main() signature in test program. One of the "does the compiler work?" test programs uses int main(){ ... } which disagrees with the usual definition of main(int, char**). To ensure future compatibility with pedantic compilers, we correct the test program. --- configure.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.lib b/configure.lib index 39cf423..6b7245f 100644 --- a/configure.lib +++ b/configure.lib @@ -178,7 +178,7 @@ EOF if ac_yesno "whether the C compiler ($ccld) can produce executables" \ ac_compile_run < Date: Mon, 3 Oct 2022 18:23:29 -0400 Subject: [PATCH 3/5] configure: fix main() signatures in test programs. Several of the ./configure test programs use int main(){ ... } which disagrees with the usual definition of main(int, char**). To ensure future compatibility with pedantic compilers, we correct the test programs. --- configure | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 3462b9a..c2ea71b 100755 --- a/configure +++ b/configure @@ -89,7 +89,7 @@ else if ac_yesno "sizes of standard integer types" \ ac_compile_run < -int main() { +int main(int argc, char **argv) { printf("#define SIZEOF_SHORT %d\n", sizeof(short)); printf("#define SIZEOF_INT %d\n", sizeof(int)); printf("#define SIZEOF_LONG %d\n", sizeof(long)); @@ -104,7 +104,7 @@ EOF if ac_yesno "for long long" \ ac_compile_run < -int main() { +int main(int argc, char **argv) { long long x; printf("#define SIZEOF_LONG_LONG %d\n", sizeof(long long)); return 0; @@ -119,7 +119,7 @@ fi if ac_compile_run_v "whether C compiler defines __SIZEOF_POINTER__" < -int main() { +int main(int argc, char **argv) { #ifdef __SIZEOF_POINTER__ return 0; #else @@ -135,7 +135,7 @@ fi if ac_verbose "byte order" "big-endian" "little-endian" \ ac_compile_run < #include #include -int main() { +int main(int argc, char **argv) { char h[200]; char s[200]; struct sockaddr_in6 sa; @@ -210,7 +210,7 @@ if ac_link_v "for mallinfo()" < #include #include -int main() { +int main(int argc, char **argv) { struct mallinfo mi = mallinfo(); return 0; } @@ -223,7 +223,7 @@ fi if ac_link_v "for poll()" < #include -int main() { +int main(int argc, char **argv) { struct pollfd pfd[2]; return poll(pfd, 2, 10); } @@ -250,7 +250,7 @@ int test(char *fmt, ...) { vsnprintf(buf, sizeof(buf), fmt, ap); return 0; } -int main() { +int main(int argc, char **argv) { test("test%d", 40); return 0; } @@ -264,7 +264,7 @@ if ac_link_v "for writev()/readv()" < #include #include -int main() { +int main(int argc, char **argv) { struct iovec iov; return writev(1, &iov, 1) && readv(1, &iov, 1); } @@ -277,7 +277,7 @@ fi if ac_link_v "for setitimer()" < #include -int main() { +int main(int argc, char **argv) { struct itimerval itv; itv.it_interval.tv_sec = itv.it_value.tv_sec = 10; itv.it_interval.tv_usec = itv.it_value.tv_usec = 20; @@ -295,7 +295,7 @@ elif ac_link_v "for zlib support" -lz < #include #include -int main() { +int main(int argc, char **argv) { z_stream z; int r; r = inflateInit2(&z, 0); @@ -318,7 +318,7 @@ elif [ n = "$enable_dso" ]; then echo "#define NO_DSO 1 /* option disabled */" >>confdef.h elif ac_link_v "for dlopen() in -dl with -rdynamic" -ldl -rdynamic < -int main() { +int main(int argc, char **argv) { void *handle, *func; handle = dlopen("testfile", RTLD_NOW); func = dlsym(handle, "function"); From cbdf653fd89e486490270a1d6c82c9972573f74e Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 3 Oct 2022 18:30:33 -0400 Subject: [PATCH 4/5] configure: improve standards-compliance of two test programs. Two ./configure test programs declare and define int foo() { ... } simultaneously. A strict reading of the C standard, however, requires that we use int foo(void) { ... } so that the definition agrees with what its prototype would be. This can be detected by the "strict-prototypes" warning in gcc or clang. --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index c2ea71b..d9a27de 100755 --- a/configure +++ b/configure @@ -149,7 +149,7 @@ fi has_inline= for c in inline __inline; do if ac_compile_v "for $c" < #include -int foo() { socklen_t len; len = 0; return len; } +int foo(void) { socklen_t len; len = 0; return len; } EOF then : else From 4cdc03ad6625695d3fbc1bb91080b0e019528702 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 3 Oct 2022 18:38:33 -0400 Subject: [PATCH 5/5] configure: use a valid program for the connect() library test. To test if connect() is available (and in what library, if any, it lives), the ./configure script was compiling and linking int main(int argc, char **argv) { gethostbyname(); connect(); return 0; } This program, however, is invalid and fails to build with pedantic compilers. The functions gethostbyname() and connect() are undefined; and once we include the necessary headers to define them, they're called incorrectly, with the wrong number/type of arguments. The program is never actually *run*, so we fix this by including the headers that define gethostbyname() and connect(), and then by changing those two calls to pass correctly-typed junk arguments to the functions. This can be detected by the "implicit-function-declaration" warning in gcc or clang. --- configure | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configure b/configure index d9a27de..c9d7fa7 100755 --- a/configure +++ b/configure @@ -172,7 +172,13 @@ else fi if ac_library_find_v 'connect()' "" "-lsocket -lnsl" < +#include +int main(int argc, char **argv) { + gethostbyname(""); + connect(0, (const struct sockaddr *)0, (socklen_t)0); + return 0; +} EOF then : else