[FTBFS,PATCH,nfs-utils 1/1] getport: Fix switch case on old compilers
Petr Vorel <[email protected]>
| Newsgroups | org.kernel.vger.linux-nfs |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]>
---
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