Skip to content

Commit 29cdfb4

Browse files
nathanchancechucklever
authored andcommitted
nfsd: Avoid strlen conflict in nfsd4_encode_components_esc()
There is an error building nfs4xdr.c with CONFIG_SUNRPC_DEBUG_TRACE=y and CONFIG_FORTIFY_SOURCE=n due to the local variable strlen conflicting with the function strlen(): In file included from include/linux/cpumask.h:11, from arch/x86/include/asm/paravirt.h:21, from arch/x86/include/asm/irqflags.h:102, from include/linux/irqflags.h:18, from include/linux/spinlock.h:59, from include/linux/mmzone.h:8, from include/linux/gfp.h:7, from include/linux/slab.h:16, from fs/nfsd/nfs4xdr.c:37: fs/nfsd/nfs4xdr.c: In function 'nfsd4_encode_components_esc': include/linux/kernel.h:321:46: error: called object 'strlen' is not a function or function pointer 321 | __trace_puts(_THIS_IP_, str, strlen(str)); \ | ^~~~~~ include/linux/kernel.h:265:17: note: in expansion of macro 'trace_puts' 265 | trace_puts(fmt); \ | ^~~~~~~~~~ include/linux/sunrpc/debug.h:34:41: note: in expansion of macro 'trace_printk' 34 | # define __sunrpc_printk(fmt, ...) trace_printk(fmt, ##__VA_ARGS__) | ^~~~~~~~~~~~ include/linux/sunrpc/debug.h:42:17: note: in expansion of macro '__sunrpc_printk' 42 | __sunrpc_printk(fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~~~ include/linux/sunrpc/debug.h:25:9: note: in expansion of macro 'dfprintk' 25 | dfprintk(FACILITY, fmt, ##__VA_ARGS__) | ^~~~~~~~ fs/nfsd/nfs4xdr.c:2646:9: note: in expansion of macro 'dprintk' 2646 | dprintk("nfsd4_encode_components(%s)\n", components); | ^~~~~~~ fs/nfsd/nfs4xdr.c:2643:13: note: declared here 2643 | int strlen, count=0; | ^~~~~~ This dprintk() instance is not particularly useful, so just remove it altogether to get rid of the immediate strlen() conflict. At the same time, eliminate the local strlen variable to avoid potential conflicts with strlen() in the future. Fixes: ec7d8e6 ("sunrpc: add a Kconfig option to redirect dfprintk() output to trace buffer") Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: NeilBrown <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent abb1f08 commit 29cdfb4

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

fs/nfsd/nfs4xdr.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,10 +2628,8 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
26282628
__be32 *p;
26292629
__be32 pathlen;
26302630
int pathlen_offset;
2631-
int strlen, count=0;
26322631
char *str, *end, *next;
2633-
2634-
dprintk("nfsd4_encode_components(%s)\n", components);
2632+
int count = 0;
26352633

26362634
pathlen_offset = xdr->buf->len;
26372635
p = xdr_reserve_space(xdr, 4);
@@ -2658,9 +2656,8 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
26582656
for (; *end && (*end != sep); end++)
26592657
/* find sep or end of string */;
26602658

2661-
strlen = end - str;
2662-
if (strlen) {
2663-
if (xdr_stream_encode_opaque(xdr, str, strlen) < 0)
2659+
if (end > str) {
2660+
if (xdr_stream_encode_opaque(xdr, str, end - str) < 0)
26642661
return nfserr_resource;
26652662
count++;
26662663
} else

0 commit comments

Comments
 (0)