* [FTBFS,PATCH,nfs-utils 1/1] getport: Fix switch case on old compilers
@ 2026-08-19 23:20 Petr Vorel
0 siblings, 0 replies; only message in thread
From: Petr Vorel @ 2026-08-19 23:20 UTC (permalink / raw)
To: linux-nfs; +Cc: Petr Vorel, Steve Dickson, Giulio Benetti, Julien Olivain
Buildroot distro compiles with fairly old compilers, which defaults to
old C11 standard (some of still used compilers don't even have newer
standard than C11). Workaround code which requires C23 with using { }.
This fixes error:
getport.c:460:3: error: a label can only be part of a statement and a declaration is not a statement
size_t path_len = len - offsetof(struct sockaddr_un, sun_path);
^~~~~~
Fixes: 1a6dcd74 ("Removed warnings in nfs_sockaddr2universal()")
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Steve, other option would be to use ';'. Not sure which one you prefer.
Found with Buildroot, which still uses:
$ aarch64-linux-gcc --version
aarch64-linux-gcc.br_real (Buildroot 2017.05) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
support/nfs/getport.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/support/nfs/getport.c b/support/nfs/getport.c
index 6bd2f713..18ea0777 100644
--- a/support/nfs/getport.c
+++ b/support/nfs/getport.c
@@ -456,9 +456,10 @@ char *nfs_sockaddr2universal(const struct sockaddr *sap)
int len = sizeof(struct sockaddr);
switch (sap->sa_family) {
- case AF_LOCAL:
+ case AF_LOCAL: {
size_t path_len = len - offsetof(struct sockaddr_un, sun_path);
return strndup(sun->sun_path, path_len);
+ }
case AF_INET:
if (inet_ntop(AF_INET, (const void *)&sin->sin_addr.s_addr,
buf, (socklen_t)sizeof(buf)) == NULL)
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-19 23:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 23:20 [FTBFS,PATCH,nfs-utils 1/1] getport: Fix switch case on old compilers Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox