Message ID | 20200626130525.389469-5-lee.jones@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix a bunch of W=1 warnings in Misc | expand |
On Fri, Jun 26, 2020 at 3:05 PM Lee Jones <lee.jones@linaro.org> wrote: > > The result may not be intereresting, but not using a set variable > is bad form and causes W=1 kernel builds to complain. > > Fixes the following W=1 warning(s): > > drivers/misc/lkdtm/bugs.c: In function ‘lkdtm_STACK_GUARD_PAGE_LEADING’: > drivers/misc/lkdtm/bugs.c:331:25: warning: variable ‘byte’ set but not used [-Wunused-but-set-variable] > 331 | volatile unsigned char byte; > | ^~~~ > drivers/misc/lkdtm/bugs.c: In function ‘lkdtm_STACK_GUARD_PAGE_TRAILING’: > drivers/misc/lkdtm/bugs.c:345:25: warning: variable ‘byte’ set but not used [-Wunused-but-set-variable] > 345 | volatile unsigned char byte; > | ^~~~ > > Cc: Kees Cook <keescook@chromium.org> > Signed-off-by: Lee Jones <lee.jones@linaro.org> I think a clearer way to address this would be to add a cast to void than to actually use the variable. Looking at the implementation, it also seems odd to use a 'const char *' as the source and a 'volatile char' as the destination, I would have expected the opposite (marking the source volatile to force the access), though I suppose the effect is the same. Arnd
On Fri, Jun 26, 2020 at 02:05:19PM +0100, Lee Jones wrote: > The result may not be intereresting, but not using a set variable > is bad form and causes W=1 kernel builds to complain. > > Fixes the following W=1 warning(s): > > drivers/misc/lkdtm/bugs.c: In function ‘lkdtm_STACK_GUARD_PAGE_LEADING’: > drivers/misc/lkdtm/bugs.c:331:25: warning: variable ‘byte’ set but not used [-Wunused-but-set-variable] > 331 | volatile unsigned char byte; > | ^~~~ > drivers/misc/lkdtm/bugs.c: In function ‘lkdtm_STACK_GUARD_PAGE_TRAILING’: > drivers/misc/lkdtm/bugs.c:345:25: warning: variable ‘byte’ set but not used [-Wunused-but-set-variable] > 345 | volatile unsigned char byte; > | ^~~~ > > Cc: Kees Cook <keescook@chromium.org> > Signed-off-by: Lee Jones <lee.jones@linaro.org> Ah yeah, this looks like a reasonable way to deal with it. Thanks! Acked-by: Kees Cook <keescook@chromium.org>
diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c index 736675f0a2464..4f94296fc58ad 100644 --- a/drivers/misc/lkdtm/bugs.c +++ b/drivers/misc/lkdtm/bugs.c @@ -334,7 +334,7 @@ void lkdtm_STACK_GUARD_PAGE_LEADING(void) byte = *ptr; - pr_err("FAIL: accessed page before stack!\n"); + pr_err("FAIL: accessed page before stack! (byte: %x)\n", byte); } /* Test that VMAP_STACK is actually allocating with a trailing guard page */ @@ -348,7 +348,7 @@ void lkdtm_STACK_GUARD_PAGE_TRAILING(void) byte = *ptr; - pr_err("FAIL: accessed page after stack!\n"); + pr_err("FAIL: accessed page after stack! (byte: %x)\n", byte); } void lkdtm_UNSET_SMEP(void)
The result may not be intereresting, but not using a set variable is bad form and causes W=1 kernel builds to complain. Fixes the following W=1 warning(s): drivers/misc/lkdtm/bugs.c: In function ‘lkdtm_STACK_GUARD_PAGE_LEADING’: drivers/misc/lkdtm/bugs.c:331:25: warning: variable ‘byte’ set but not used [-Wunused-but-set-variable] 331 | volatile unsigned char byte; | ^~~~ drivers/misc/lkdtm/bugs.c: In function ‘lkdtm_STACK_GUARD_PAGE_TRAILING’: drivers/misc/lkdtm/bugs.c:345:25: warning: variable ‘byte’ set but not used [-Wunused-but-set-variable] 345 | volatile unsigned char byte; | ^~~~ Cc: Kees Cook <keescook@chromium.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> --- drivers/misc/lkdtm/bugs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)