Skip to contentSkip to conversation

cifs.upcall: fix compiler warning with -Wvla

PATCH In review Paulo Alcantara 2 participants 2 messages Jun 23

Subsystems (2)
lore
Share & tools
lore

Paulo Alcantara

author maintainer
#0 lore raw

PATCH 1/1 cifs.upcall: fix compiler warning with -Wvla

The length value for @path array in get_uidgid() needs to be evaluated at compile time, so replace strlen() with sizeof() when defining PROC_PID_PATH_MAXLEN and then fix the following warning:

cifs.upcall.c: In function ‘get_uidgid’:
cifs.upcall.c:1400:9: warning: ISO C90 forbids array ‘path’ whose size cannot be evaluated [-Wvla]

  1400 |         char path[PROC_PID_PATH_MAXLEN] = {}, buf[256];
       |         ^~~~
Fixes 972c5b5ff95e ("cifs.upcall: remove getpwuid() dependency")
Cc Enzo Matsumiya <[email protected]>
---
 cifs.upcall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cifs.upcall.c +1 -1
index 01690dfcade1..5bb3e6881491 100644
@@ -1376,7 +1376,7 @@ static int ip_to_fqdn(const char *addrstr, char *host, size_t hostlen)
 }
 
 /* cover worst case/impossible scenarios, + 1 for NUL */
-#define PROC_PID_PATH_MAXLEN	((int)strlen("/proc/2147483647/status") + 1)
+#define PROC_PID_PATH_MAXLEN	((int)sizeof("/proc/2147483647/status"))
 /* max valid UID/GID is (UINT_MAX - 1) */
 #define INVALID_UIDGID		UINT_MAX
 
Signature · 1 line
2.54.0
#1 lore raw

FIxed one misleading comment and merged into cifs-utils and smb3-utils for-next

Quoted 35 lines · Paulo Alcantara

The length value for @path array in get_uidgid() needs to be evaluated at compile time, so replace strlen() with sizeof() when defining PROC_PID_PATH_MAXLEN and then fix the following warning:

cifs.upcall.c: In function ‘get_uidgid’:
cifs.upcall.c:1400:9: warning: ISO C90 forbids array ‘path’ whose size cannot be evaluated [-Wvla]

  1400 |         char path[PROC_PID_PATH_MAXLEN] = {}, buf[256];
       |         ^~~~
Fixes 972c5b5ff95e ("cifs.upcall: remove getpwuid() dependency")
Cc Enzo Matsumiya <[email protected]>
---
 cifs.upcall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cifs.upcall.c +1 -2
index 01690dfcade1..5bb3e6881491 100644
@@ -1376,7 +1376,7 @@ static int ip_to_fqdn(const char *addrstr, char *host, size_t hostlen)
 }
 
 /* cover worst case/impossible scenarios, + 1 for NUL */
-#define PROC_PID_PATH_MAXLEN   ((int)strlen("/proc/2147483647/status") + 1)
+#define PROC_PID_PATH_MAXLEN   ((int)sizeof("/proc/2147483647/status"))
 /* max valid UID/GID is (UINT_MAX - 1) */
 #define INVALID_UIDGID         UINT_MAX
 
--

2.54.0

Signature · 3 lines
Thanks,

Steve