* [FTBFS,PATCH,nfs-utils 1/1] getport: Fix switch case on old compilers
@ 2026-08-19 23:20 Petr Vorel
2026-08-31 23:06 ` Steve Dickson
0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread
* Re: [FTBFS,PATCH,nfs-utils 1/1] getport: Fix switch case on old compilers
2026-08-19 23:20 [FTBFS,PATCH,nfs-utils 1/1] getport: Fix switch case on old compilers Petr Vorel
@ 2026-08-31 23:06 ` Steve Dickson
0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2026-08-31 23:06 UTC (permalink / raw)
To: Petr Vorel, linux-nfs; +Cc: Giulio Benetti, Julien Olivain
On 8/19/26 7:20 PM, Petr Vorel wrote:
> 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>
Committed... (tag: nfs-utils-2-9-3-rc2)
steved.
> ---nfs-utils-2-9-3-rc2
> 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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-31 23:06 UTC | newest]
Thread overview: 2+ messages (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
2026-08-31 23:06 ` Steve Dickson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox