cifs.upcall: fix compiler warning with -Wvla
Subsystems (2)
Paulo Alcantara
maintainerPATCH 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];
| ^~~~--- cifs.upcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cifs.upcall.c +1 -1
@@ -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
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 replacestrlen()withsizeof()when definingPROC_PID_PATH_MAXLENand 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")Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>Cc Enzo Matsumiya <[email protected]>--- cifs.upcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cifs.upcall.c +1
-2@@ -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