linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Fixes for various compiler warnings
@ 2019-08-28  7:10 Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 1/6] Annotate unused fields with UNUSED Patrick Steinhardt
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2019-08-28  7:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

Hi,

here's some assorted fixes for compiler warnings I'm seeing on my
platform. Most warnings are probably due to using musl libc, but
the fixes should be the correct thing to do regardless. With this
patchset, I can now compile nfs-utils with -Werror just fine.

Regards
Patrick

Patrick Steinhardt (6):
  Annotate unused fields with UNUSED
  Use <fcntl.h> header instead of <sys/fcntl.h>
  Use <poll.h> header instead of <sys/poll.h>
  configure.ac: Add <sys/socket.h> header when checking
    sizeof(socklen_t)
  nfsd_path: Include missing header for `struct stat`
  mountd: Use unsigned for filesystem type magic constants

 configure.ac                   | 5 ++++-
 support/export/xtab.c          | 2 +-
 support/include/nfsd_path.h    | 2 ++
 support/misc/xstat.c           | 3 ++-
 support/nfs/rmtab.c            | 2 +-
 support/nfs/rpc_socket.c       | 3 ++-
 support/nfs/svc_socket.c       | 2 +-
 support/nfs/xio.c              | 2 +-
 utils/gssd/svcgssd_main_loop.c | 2 +-
 utils/mountd/cache.c           | 4 ++--
 utils/statd/sm-notify.c        | 2 +-
 11 files changed, 18 insertions(+), 11 deletions(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/6] Annotate unused fields with UNUSED
  2019-08-28  7:10 [PATCH 0/6] Fixes for various compiler warnings Patrick Steinhardt
@ 2019-08-28  7:10 ` Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 2/6] Use <fcntl.h> header instead of <sys/fcntl.h> Patrick Steinhardt
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2019-08-28  7:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

There are some parameters that may be potentially unused. Add the UNUSED
macro to avoid any warnings.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 support/misc/xstat.c     | 3 ++-
 support/nfs/rpc_socket.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/support/misc/xstat.c b/support/misc/xstat.c
index 4c997eea..661e29e4 100644
--- a/support/misc/xstat.c
+++ b/support/misc/xstat.c
@@ -9,6 +9,7 @@
 #include <sys/sysmacros.h>
 #include <unistd.h>
 
+#include "nfslib.h"
 #include "xstat.h"
 
 #ifdef HAVE_FSTATAT
@@ -66,7 +67,7 @@ statx_stat_nosync(int fd, const char *pathname, struct stat *statbuf, int flags)
 #else
 
 static int
-statx_stat_nosync(int fd, const char *pathname, struct stat *statbuf, int flags)
+statx_stat_nosync(int UNUSED(fd), const char *UNUSED(pathname), struct stat *UNUSED(statbuf), int UNUSED(flags))
 {
 	errno = ENOSYS;
 	return -1;
diff --git a/support/nfs/rpc_socket.c b/support/nfs/rpc_socket.c
index bdf6d2f6..03048feb 100644
--- a/support/nfs/rpc_socket.c
+++ b/support/nfs/rpc_socket.c
@@ -41,6 +41,7 @@
 #include <rpc/pmap_prot.h>
 
 #include "sockaddr.h"
+#include "nfslib.h"
 #include "nfsrpc.h"
 
 #ifdef HAVE_LIBTIRPC
@@ -519,7 +520,7 @@ CLIENT *nfs_get_priv_rpcclient(const struct sockaddr *sap,
  * Returns program number of first name to be successfully looked
  * up, or the default program number if all lookups fail.
  */
-rpcprog_t nfs_getrpcbyname(const rpcprog_t program, const char *table[])
+rpcprog_t nfs_getrpcbyname(const rpcprog_t program, const char *UNUSED(table[]))
 {
 #ifdef HAVE_GETRPCBYNAME
 	struct rpcent *entry;
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/6] Use <fcntl.h> header instead of <sys/fcntl.h>
  2019-08-28  7:10 [PATCH 0/6] Fixes for various compiler warnings Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 1/6] Annotate unused fields with UNUSED Patrick Steinhardt
@ 2019-08-28  7:10 ` Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 3/6] Use <poll.h> header instead of <sys/poll.h> Patrick Steinhardt
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2019-08-28  7:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

While most source files already use the standard header <fcntl.h>
instead of <sys/fcntl.h>, some do not, causing warnings on musl libc
systems.

Fix the remaining ones to use <fcntl.h>. As we already use the header
unconditionally in a lot of places, this change should not cause any
problems for other platforms.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 support/export/xtab.c    | 2 +-
 support/nfs/rmtab.c      | 2 +-
 support/nfs/svc_socket.c | 2 +-
 support/nfs/xio.c        | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/support/export/xtab.c b/support/export/xtab.c
index 1e1d679e..00b25eaa 100644
--- a/support/export/xtab.c
+++ b/support/export/xtab.c
@@ -10,7 +10,7 @@
 #include <config.h>
 #endif
 
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/support/nfs/rmtab.c b/support/nfs/rmtab.c
index 2ecb2cc9..9f03167d 100644
--- a/support/nfs/rmtab.c
+++ b/support/nfs/rmtab.c
@@ -10,7 +10,7 @@
 #include <config.h>
 #endif
 
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/support/nfs/svc_socket.c b/support/nfs/svc_socket.c
index 5afc6aa5..2e8fe1af 100644
--- a/support/nfs/svc_socket.c
+++ b/support/nfs/svc_socket.c
@@ -22,7 +22,7 @@
 #include <netdb.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include "xlog.h"
 #include "rpcmisc.h"
diff --git a/support/nfs/xio.c b/support/nfs/xio.c
index e3d27d2f..6962751d 100644
--- a/support/nfs/xio.c
+++ b/support/nfs/xio.c
@@ -10,7 +10,7 @@
 #include <config.h>
 #endif
 
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] Use <poll.h> header instead of <sys/poll.h>
  2019-08-28  7:10 [PATCH 0/6] Fixes for various compiler warnings Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 1/6] Annotate unused fields with UNUSED Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 2/6] Use <fcntl.h> header instead of <sys/fcntl.h> Patrick Steinhardt
@ 2019-08-28  7:10 ` Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 4/6] configure.ac: Add <sys/socket.h> header when checking sizeof(socklen_t) Patrick Steinhardt
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2019-08-28  7:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

The POSIX standard specifies that poll(3P) should be declared in the
header <poll.h> instead of <sys/poll.h>. While there is one location
where we use the correct header, two others do not, causing warnings on
musl libc systems.

Fix the warning by switching from <sys/poll.h> to <poll.h>. As we're
already using the latter one already, this change should not cause any
problems for other platforms.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 utils/gssd/svcgssd_main_loop.c | 2 +-
 utils/statd/sm-notify.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/gssd/svcgssd_main_loop.c b/utils/gssd/svcgssd_main_loop.c
index b5681ce1..920520d0 100644
--- a/utils/gssd/svcgssd_main_loop.c
+++ b/utils/gssd/svcgssd_main_loop.c
@@ -34,7 +34,7 @@
 
 #include <sys/param.h>
 #include <sys/socket.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <netinet/in.h>
diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c
index abfb8bc7..739731f5 100644
--- a/utils/statd/sm-notify.c
+++ b/utils/statd/sm-notify.c
@@ -12,7 +12,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
-#include <sys/poll.h>
+#include <poll.h>
 #include <sys/param.h>
 #include <sys/syslog.h>
 #include <arpa/inet.h>
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/6] configure.ac: Add <sys/socket.h> header when checking sizeof(socklen_t)
  2019-08-28  7:10 [PATCH 0/6] Fixes for various compiler warnings Patrick Steinhardt
                   ` (2 preceding siblings ...)
  2019-08-28  7:10 ` [PATCH 3/6] Use <poll.h> header instead of <sys/poll.h> Patrick Steinhardt
@ 2019-08-28  7:10 ` Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 5/6] nfsd_path: Include missing header for `struct stat` Patrick Steinhardt
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2019-08-28  7:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

We're checking for various sizes in configure.ac, among them the size of
the socklen_t type. If socklen_t's size is not found and thus reported
to be zero, we will typedef our own socklen_t as "unsigned int".

The check for socklen_t is insufficient, though. While the type is
declared via <sys/socket.h>, we only search AC_INCLUDES_DEFAULT for its
declaration, which doesn't include <sys/socket.h>. On musl libc, this
causes us to not find the declaration and redeclare it with an
incompatible type.

Fix the issue by searching both the default includes as well as
<sys/socket.h>.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 configure.ac | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 50002b4a..37096944 100644
--- a/configure.ac
+++ b/configure.ac
@@ -545,7 +545,10 @@ AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(size_t)
-AC_CHECK_SIZEOF(socklen_t)
+AC_CHECK_SIZEOF(socklen_t,, [AC_INCLUDES_DEFAULT
+                             #ifdef HAVE_SYS_SOCKET_H
+                             # include <sys/socket.h>
+                             #endif])
 
 
 dnl *************************************************************
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/6] nfsd_path: Include missing header for `struct stat`
  2019-08-28  7:10 [PATCH 0/6] Fixes for various compiler warnings Patrick Steinhardt
                   ` (3 preceding siblings ...)
  2019-08-28  7:10 ` [PATCH 4/6] configure.ac: Add <sys/socket.h> header when checking sizeof(socklen_t) Patrick Steinhardt
@ 2019-08-28  7:10 ` Patrick Steinhardt
  2019-08-28  7:10 ` [PATCH 6/6] mountd: Use unsigned for filesystem type magic constants Patrick Steinhardt
  2019-09-05 12:07 ` [PATCH 0/6] Fixes for various compiler warnings Steve Dickson
  6 siblings, 0 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2019-08-28  7:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

The header "nfsd_path.h" uses `struct stat` in its function signatures,
but doesn't include the <sys/stat.h> header. This may cause compiler
warnings if a compilation unit includes "nfsd_path.h" while not
transitively including <sys/stat.h>.

Fix the potential warning by including <sys/stat.h> in the header.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 support/include/nfsd_path.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/support/include/nfsd_path.h b/support/include/nfsd_path.h
index ca2570a9..b42416bb 100644
--- a/support/include/nfsd_path.h
+++ b/support/include/nfsd_path.h
@@ -4,6 +4,8 @@
 #ifndef NFSD_PATH_H
 #define NFSD_PATH_H
 
+#include <sys/stat.h>
+
 void 		nfsd_path_init(void);
 
 const char *	nfsd_path_nfsd_rootdir(void);
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/6] mountd: Use unsigned for filesystem type magic constants
  2019-08-28  7:10 [PATCH 0/6] Fixes for various compiler warnings Patrick Steinhardt
                   ` (4 preceding siblings ...)
  2019-08-28  7:10 ` [PATCH 5/6] nfsd_path: Include missing header for `struct stat` Patrick Steinhardt
@ 2019-08-28  7:10 ` Patrick Steinhardt
  2019-09-05 12:07 ` [PATCH 0/6] Fixes for various compiler warnings Steve Dickson
  6 siblings, 0 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2019-08-28  7:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

The filesystem type magic constants are all unsigned integers, but we
declare them as signed ones. This may cause a compiler warning when
comparing our own signed magic constants with the unsigned ones return
by statfs64(3).

Fix the issue by uniformly usign unsigned types.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 utils/mountd/cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index ecda18c7..6cfa0549 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -302,7 +302,7 @@ static int get_uuid(const char *val, size_t uuidlen, char *u)
  * we generate the identifier from statfs->f_fsid. The rest are network or
  * pseudo filesystems. (See <linux/magic.h> for the basic IDs.)
  */
-static const long int nonblkid_filesystems[] = {
+static const unsigned long nonblkid_filesystems[] = {
     0x2fc12fc1,    /* ZFS_SUPER_MAGIC */
     0x9123683E,    /* BTRFS_SUPER_MAGIC */
     0xFF534D42,    /* CIFS_MAGIC_NUMBER */
@@ -355,7 +355,7 @@ static int uuid_by_path(char *path, int type, size_t uuidlen, char *uuid)
 	rc = statfs64(path, &st);
 
 	if (type == 0 && rc == 0) {
-		const long int *bad;
+		const unsigned long *bad;
 		for (bad = nonblkid_filesystems; *bad; bad++) {
 			if (*bad == st.f_type)
 				break;
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/6] Fixes for various compiler warnings
  2019-08-28  7:10 [PATCH 0/6] Fixes for various compiler warnings Patrick Steinhardt
                   ` (5 preceding siblings ...)
  2019-08-28  7:10 ` [PATCH 6/6] mountd: Use unsigned for filesystem type magic constants Patrick Steinhardt
@ 2019-09-05 12:07 ` Steve Dickson
  6 siblings, 0 replies; 8+ messages in thread
From: Steve Dickson @ 2019-09-05 12:07 UTC (permalink / raw)
  To: Patrick Steinhardt, linux-nfs



On 8/28/19 3:10 AM, Patrick Steinhardt wrote:
> Hi,
> 
> here's some assorted fixes for compiler warnings I'm seeing on my
> platform. Most warnings are probably due to using musl libc, but
> the fixes should be the correct thing to do regardless. With this
> patchset, I can now compile nfs-utils with -Werror just fine.
Patchset committed.... 

steved.
> 
> Regards
> Patrick
> 
> Patrick Steinhardt (6):
>   Annotate unused fields with UNUSED
>   Use <fcntl.h> header instead of <sys/fcntl.h>
>   Use <poll.h> header instead of <sys/poll.h>
>   configure.ac: Add <sys/socket.h> header when checking
>     sizeof(socklen_t)
>   nfsd_path: Include missing header for `struct stat`
>   mountd: Use unsigned for filesystem type magic constants
> 
>  configure.ac                   | 5 ++++-
>  support/export/xtab.c          | 2 +-
>  support/include/nfsd_path.h    | 2 ++
>  support/misc/xstat.c           | 3 ++-
>  support/nfs/rmtab.c            | 2 +-
>  support/nfs/rpc_socket.c       | 3 ++-
>  support/nfs/svc_socket.c       | 2 +-
>  support/nfs/xio.c              | 2 +-
>  utils/gssd/svcgssd_main_loop.c | 2 +-
>  utils/mountd/cache.c           | 4 ++--
>  utils/statd/sm-notify.c        | 2 +-
>  11 files changed, 18 insertions(+), 11 deletions(-)
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-05 12:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28  7:10 [PATCH 0/6] Fixes for various compiler warnings Patrick Steinhardt
2019-08-28  7:10 ` [PATCH 1/6] Annotate unused fields with UNUSED Patrick Steinhardt
2019-08-28  7:10 ` [PATCH 2/6] Use <fcntl.h> header instead of <sys/fcntl.h> Patrick Steinhardt
2019-08-28  7:10 ` [PATCH 3/6] Use <poll.h> header instead of <sys/poll.h> Patrick Steinhardt
2019-08-28  7:10 ` [PATCH 4/6] configure.ac: Add <sys/socket.h> header when checking sizeof(socklen_t) Patrick Steinhardt
2019-08-28  7:10 ` [PATCH 5/6] nfsd_path: Include missing header for `struct stat` Patrick Steinhardt
2019-08-28  7:10 ` [PATCH 6/6] mountd: Use unsigned for filesystem type magic constants Patrick Steinhardt
2019-09-05 12:07 ` [PATCH 0/6] Fixes for various compiler warnings Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).