Linux NFS development
 help / color / mirror / Atom feed
From: Petr Vorel <petr.vorel@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: Petr Vorel <petr.vorel@gmail.com>,
	Steve Dickson <SteveD@RedHat.com>,
	Giulio Benetti <giulio.benetti@benettiengineering.com>,
	Julien Olivain <ju.o@free.fr>
Subject: [FTBFS,PATCH,nfs-utils 1/1] getport: Fix switch case on old compilers
Date: Thu, 20 Aug 2026 01:20:49 +0200	[thread overview]
Message-ID: <20260819232049.438643-1-petr.vorel@gmail.com> (raw)

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


                 reply	other threads:[~2026-08-19 23:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260819232049.438643-1-petr.vorel@gmail.com \
    --to=petr.vorel@gmail.com \
    --cc=SteveD@RedHat.com \
    --cc=giulio.benetti@benettiengineering.com \
    --cc=ju.o@free.fr \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox