diff options
| author | NIIBE Yutaka <[email protected]> | 2026-02-27 08:08:59 +0100 |
|---|---|---|
| committer | NIIBE Yutaka <[email protected]> | 2026-02-27 08:08:59 +0100 |
| commit | e71eb3ec615e5c4a2dd8b5ecd068c3a9f6547a47 (patch) | |
| tree | c7269b3641cfabb327f16c722b65ee1adf7ac78c | |
| parent | build: Update build-aux and m4 from libgpg-error. (diff) | |
| download | libassuan-e71eb3ec615e5c4a2dd8b5ecd068c3a9f6547a47.tar.gz libassuan-e71eb3ec615e5c4a2dd8b5ecd068c3a9f6547a47.zip | |
Enable warnings for maintainer mode. Fix warnings.
* configure.ac: Apply GCC specific options for maintainer mode.
* src/assuan-handler.c, src/assuan-logging.c: Fix warnings.
* src/assuan-socket-connect.c, src/assuan-socket.c: Likewise.
* src/assuan-uds.c, src/debug.c, src/system-posix.c: Likewise.
* src/system-w32.c, src/system.c: Likewise.
* tests/socks5.c (main): Use int for the check of the value 65535.
--
The code in configure.ac is from libgpg-error master.
Signed-off-by: NIIBE Yutaka <[email protected]>
| -rw-r--r-- | configure.ac | 86 | ||||
| -rw-r--r-- | src/assuan-handler.c | 7 | ||||
| -rw-r--r-- | src/assuan-logging.c | 2 | ||||
| -rw-r--r-- | src/assuan-socket-connect.c | 2 | ||||
| -rw-r--r-- | src/assuan-socket.c | 8 | ||||
| -rw-r--r-- | src/assuan-uds.c | 2 | ||||
| -rw-r--r-- | src/debug.c | 4 | ||||
| -rw-r--r-- | src/system-posix.c | 18 | ||||
| -rw-r--r-- | src/system-w32.c | 15 | ||||
| -rw-r--r-- | src/system.c | 8 | ||||
| -rw-r--r-- | tests/socks5.c | 2 |
11 files changed, 133 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac index e434821..59c1db6 100644 --- a/configure.ac +++ b/configure.ac @@ -131,6 +131,77 @@ LT_PREREQ([2.2.6]) LT_INIT([win32-dll disable-static]) LT_LANG([Windows Resource]) +# +# Setup gcc specific options +# +AC_MSG_NOTICE([checking for cc features]) +if test "$GCC" = yes; then + # Check whether gcc does not emit a diagnostic for unknown -Wno-* + # options. This is the case for gcc >= 4.6 + AC_MSG_CHECKING([if gcc ignores unknown -Wno-* options]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6 ) +#kickerror +#endif]],[])],[_gcc_silent_wno=yes],[_gcc_silent_wno=no]) + AC_MSG_RESULT($_gcc_silent_wno) + + # Note that it is okay to use CFLAGS here because these are just + # warning options and the user should have a chance of overriding + # them. + if test "$USE_MAINTAINER_MODE" = "yes"; then + M_CFLAGS="-O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes" + M_CFLAGS="$M_CFLAGS -Wformat -Wno-format-y2k -Wformat-security" + if test x"$_gcc_silent_wno" = xyes ; then + _gcc_wopt=yes + else + AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers]) + _gcc_cflags_save=$CFLAGS + CFLAGS="-Wno-missing-field-initializers" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], + [_gcc_wopt=yes],[_gcc_wopt=no]) + AC_MSG_RESULT($_gcc_wopt) + CFLAGS=$_gcc_cflags_save; + fi + if test x"$_gcc_wopt" = xyes ; then + M_CFLAGS="$M_CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers" + fi + + AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement]) + _gcc_cflags_save=$CFLAGS + CFLAGS="-Wdeclaration-after-statement" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no) + AC_MSG_RESULT($_gcc_wopt) + CFLAGS=$_gcc_cflags_save; + if test x"$_gcc_wopt" = xyes ; then + M_CFLAGS="$M_CFLAGS -Wdeclaration-after-statement" + fi + + # Prepend the maintainer-cflags so that the user can override + # them, e.g. to override the optimization flags for debugging. + CFLAGS="$M_CFLAGS $CFLAGS" + else + CFLAGS="$CFLAGS -Wall" + fi + + AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) + _gcc_cflags_save=$CFLAGS + CFLAGS="-Wpointer-arith" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_psign=yes,_gcc_psign=no) + AC_MSG_RESULT($_gcc_psign) + CFLAGS=$_gcc_cflags_save; + if test x"$_gcc_psign" = xyes ; then + CFLAGS="$CFLAGS -Wpointer-arith" + fi + + # The undocumented option -Wno-psabi suppresses the annoying + # "the ABI of passing union with long double has changed in GCC 4.4" + # which is emitted in estream-printf.c but entirely irrelvant + # because that union is local to the file. + if test x"$_gcc_silent_wno" = xyes ; then + CFLAGS="$CFLAGS -Wno-psabi" + fi +fi + # For now we hardcode the use of version scripts. It would be better # to write a test for this or even implement this within libtool. have_ld_version_script=no @@ -225,21 +296,6 @@ AC_PROG_MAKE_SET # We need to compile and run a program on the build machine. AX_CC_FOR_BUILD -if test "$GCC" = yes; then - CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" - - AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) - _gcc_cflags_save=$CFLAGS - CFLAGS="-Wpointer-arith" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],_gcc_wopt=yes,_gcc_wopt=no) - AC_MSG_RESULT($_gcc_wopt) - CFLAGS=$_gcc_cflags_save; - if test x"$_gcc_wopt" = xyes ; then - CFLAGS="$CFLAGS -Wpointer-arith" - fi -fi - - # # Options depending on the host OS. # diff --git a/src/assuan-handler.c b/src/assuan-handler.c index a04ab4e..ebd7508 100644 --- a/src/assuan-handler.c +++ b/src/assuan-handler.c @@ -44,6 +44,7 @@ static int my_strcasecmp (const char *a, const char *b); static gpg_error_t dummy_handler (assuan_context_t ctx, char *line) { + (void)line; return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_ASSUAN_SERVER_FAULT, "no handler registered")); @@ -57,6 +58,7 @@ static const char std_help_nop[] = static gpg_error_t std_handler_nop (assuan_context_t ctx, char *line) { + (void)line; return PROCESS_DONE (ctx, 0); /* okay */ } @@ -158,6 +160,7 @@ static const char std_help_auth[] = static gpg_error_t std_handler_auth (assuan_context_t ctx, char *line) { + (void)line; return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL)); } @@ -254,6 +257,7 @@ static const char std_help_end[] = static gpg_error_t std_handler_end (assuan_context_t ctx, char *line) { + (void)line; return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL)); } @@ -611,6 +615,8 @@ _assuan_register_std_commands (assuan_context_t ctx) static gpg_error_t handle_data_line (assuan_context_t ctx, char *line, int linelen) { + (void)line; + (void)linelen; return set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL); } @@ -1006,6 +1012,7 @@ assuan_get_data_fp (assuan_context_t ctx) ctx->outbound.data.error = 0; return ctx->outbound.data.fp; #else + (void)ctx; gpg_err_set_errno (ENOSYS); return NULL; #endif diff --git a/src/assuan-logging.c b/src/assuan-logging.c index 766bd82..2d59b17 100644 --- a/src/assuan-logging.c +++ b/src/assuan-logging.c @@ -130,6 +130,8 @@ _assuan_log_handler (assuan_context_t ctx, void *hook, unsigned int cat, const char *prf; int saved_errno = errno; + (void)hook; + /* For now. */ if (msg == NULL) return TEST_LOG_CAT (cat); diff --git a/src/assuan-socket-connect.c b/src/assuan-socket-connect.c index b2f3c76..a6ff495 100644 --- a/src/assuan-socket-connect.c +++ b/src/assuan-socket-connect.c @@ -233,6 +233,8 @@ assuan_socket_connect (assuan_context_t ctx, const char *name, int af = AF_LOCAL; int pf = PF_LOCAL; + (void)server_pid; + TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_socket_connect", ctx, "name=%s, flags=0x%x", name ? name : "(null)", flags); diff --git a/src/assuan-socket.c b/src/assuan-socket.c index 78af46f..b1d778e 100644 --- a/src/assuan-socket.c +++ b/src/assuan-socket.c @@ -779,6 +779,8 @@ socks5_connect (assuan_context_t ctx, assuan_fd_t sock, fd_set fds; struct timeval tv = { TIMEOUT_NOT_WAITING_SOCKS5_FOREVER, 0 }; + (void)length; + addru.addr = addr; FD_ZERO (&fds); @@ -1081,8 +1083,6 @@ _assuan_sock_accept (assuan_context_t ctx, assuan_fd_t sockfd, { assuan_fd_t res; - (void)ctx; - _assuan_pre_syscall (); #ifdef HAVE_W32_SYSTEM @@ -1090,6 +1090,7 @@ _assuan_sock_accept (assuan_context_t ctx, assuan_fd_t sockfd, if (res == SOCKET2HANDLE (INVALID_SOCKET)) gpg_err_set_errno (_assuan_sock_wsa2errno (ctx, WSAGetLastError ())); #else + (void)ctx; res = accept (sockfd, addr, p_addrlen); #endif @@ -1367,6 +1368,7 @@ _assuan_sock_bind (assuan_context_t ctx, assuan_fd_t sockfd, } leave: #else + (void)ctx; res = bind (sockfd, addr, addrlen); #endif @@ -1441,6 +1443,7 @@ int _assuan_sock_get_nonce (assuan_context_t ctx, struct sockaddr *addr, socklen_t addrlen, assuan_sock_nonce_t *nonce) { + (void)ctx; #ifdef HAVE_W32_SYSTEM if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX) { @@ -1525,6 +1528,7 @@ _assuan_sock_check_nonce (assuan_context_t ctx, assuan_fd_t fd, } #else + (void)ctx; (void)fd; (void)nonce; #endif diff --git a/src/assuan-uds.c b/src/assuan-uds.c index 01f0861..b618597 100644 --- a/src/assuan-uds.c +++ b/src/assuan-uds.c @@ -237,6 +237,7 @@ uds_sendfd (assuan_context_t ctx, assuan_fd_t fd) else return 0; #else + (void)fd; return _assuan_error (ctx, GPG_ERR_NOT_IMPLEMENTED); #endif } @@ -263,6 +264,7 @@ uds_receivefd (assuan_context_t ctx, assuan_fd_t *fd) return 0; #else + (void)fd; return _assuan_error (ctx, GPG_ERR_NOT_IMPLEMENTED); #endif } diff --git a/src/debug.c b/src/debug.c index 9fe9f20..a370a6a 100644 --- a/src/debug.c +++ b/src/debug.c @@ -103,6 +103,8 @@ _assuan_debug_add (assuan_context_t ctx, void **line, const char *format, ...) char *result; int res; + (void)ctx; + if (!*line) return; @@ -129,6 +131,8 @@ _assuan_debug_add (assuan_context_t ctx, void **line, const char *format, ...) void _assuan_debug_end (assuan_context_t ctx, void **line, unsigned int cat) { + (void)cat; + if (!*line) return; diff --git a/src/system-posix.c b/src/system-posix.c index 7952907..a2b4d11 100644 --- a/src/system-posix.c +++ b/src/system-posix.c @@ -61,6 +61,8 @@ assuan_fdopen (int fd) void __assuan_usleep (assuan_context_t ctx, unsigned int usec) { + (void)ctx; + if (! usec) return; @@ -91,6 +93,8 @@ __assuan_usleep (assuan_context_t ctx, unsigned int usec) int __assuan_pipe (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx) { + (void)ctx; + (void)inherit_idx; return pipe (fd); } @@ -101,6 +105,7 @@ __assuan_pipe (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx) int __assuan_close (assuan_context_t ctx, assuan_fd_t fd) { + (void)ctx; return close (fd); } @@ -109,6 +114,7 @@ __assuan_close (assuan_context_t ctx, assuan_fd_t fd) ssize_t __assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size) { + (void)ctx; return read (fd, buffer, size); } @@ -118,6 +124,7 @@ ssize_t __assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size) { + (void)ctx; return write (fd, buffer, size); } @@ -129,6 +136,8 @@ __assuan_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, { int ret; + (void)ctx; + do ret = recvmsg (fd, msg, flags); while (ret == -1 && errno == EINTR); @@ -144,6 +153,8 @@ __assuan_sendmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, { int ret; + (void)ctx; + do ret = sendmsg (fd, msg, flags); while (ret == -1 && errno == EINTR); @@ -275,6 +286,8 @@ __assuan_spawn (assuan_context_t ctx, assuan_pid_t *r_pid, const char *name, { int pid; + (void)flags; + pid = fork (); if (pid < 0) return -1; @@ -398,6 +411,8 @@ assuan_pid_t __assuan_waitpid (assuan_context_t ctx, assuan_pid_t pid, int nowait, int *status, int options) { + (void)ctx; + if (nowait) return 0; @@ -413,6 +428,7 @@ int __assuan_socketpair (assuan_context_t ctx, int namespace, int style, int protocol, assuan_fd_t filedes[2]) { + (void)ctx; return socketpair (namespace, style, protocol, filedes); } @@ -420,6 +436,7 @@ __assuan_socketpair (assuan_context_t ctx, int namespace, int style, int __assuan_socket (assuan_context_t ctx, int namespace, int style, int protocol) { + (void)ctx; return socket (namespace, style, protocol); } @@ -428,6 +445,7 @@ int __assuan_connect (assuan_context_t ctx, int sock, struct sockaddr *addr, socklen_t length) { + (void)ctx; return connect (sock, addr, length); } diff --git a/src/system-w32.c b/src/system-w32.c index 80c935a..6c4967b 100644 --- a/src/system-w32.c +++ b/src/system-w32.c @@ -56,6 +56,8 @@ assuan_fdopen (int fd) void __assuan_usleep (assuan_context_t ctx, unsigned int usec) { + (void)ctx; + if (!usec) return; @@ -385,6 +387,10 @@ int __assuan_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags) { + (void)ctx; + (void)fd; + (void)msg; + (void)flags; gpg_err_set_errno (ENOSYS); return -1; } @@ -396,6 +402,10 @@ int __assuan_sendmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags) { + (void)ctx; + (void)fd; + (void)msg; + (void)flags; gpg_err_set_errno (ENOSYS); return -1; } @@ -635,6 +645,11 @@ int __assuan_socketpair (assuan_context_t ctx, int namespace, int style, int protocol, assuan_fd_t filedes[2]) { + (void)ctx; + (void)namespace; + (void)style; + (void)protocol; + (void)filedes; gpg_err_set_errno (ENOSYS); return -1; } diff --git a/src/system.c b/src/system.c index 9807d9d..a148a59 100644 --- a/src/system.c +++ b/src/system.c @@ -130,9 +130,11 @@ _assuan_system_hooks_copy (assuan_system_hooks_t dst, dst->connect = src->connect; } if (src->version > 2) - /* FIXME. Application uses newer version of the library. What to - do? */ - ; + { + /* FIXME. Application uses newer version of the library. What to + do? */ + ; + } } diff --git a/tests/socks5.c b/tests/socks5.c index f63992c..e001006 100644 --- a/tests/socks5.c +++ b/tests/socks5.c @@ -207,7 +207,7 @@ main (int argc, char **argv) } else if (opt_byname) { - unsigned short port; + unsigned int port; char *cred; if (user || pass) |
