Re: [hnaz-mm:master 272/379] lib/vsprintf.c:991:13: warning: variable 'modbuildid' set but not used

From: Andrew Morton
Date: Tue Mar 01 2022 - 13:24:57 EST


On Tue, 1 Mar 2022 20:11:04 +0800 kernel test robot <lkp@xxxxxxxxx> wrote:

> tree: https://github.com/hnaz/linux-mm master
> head: a46912c14343fd3269cc133494988af90b377d9f
> commit: b314f622e664eb263ea03ef7f4580e37146f123f [272/379] kallsyms: enhance %pS/s/b printing when KALLSYSMS is disabled
> config: arm-eseries_pxa_defconfig (https://download.01.org/0day-ci/archive/20220301/202203012040.uFWGm3My-lkp@xxxxxxxxx/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/hnaz/linux-mm/commit/b314f622e664eb263ea03ef7f4580e37146f123f
> git remote add hnaz-mm https://github.com/hnaz/linux-mm
> git fetch --no-tags hnaz-mm master
> git checkout b314f622e664eb263ea03ef7f4580e37146f123f
> # save the config file to linux build tree
> mkdir build_dir
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All warnings (new ones prefixed by >>):
>
> lib/vsprintf.c: In function 'sprint_module_info':
> >> lib/vsprintf.c:991:13: warning: variable 'modbuildid' set but not used [-Wunused-but-set-variable]
> 991 | int modbuildid = 0;
> | ^~~~~~~~~~

Do we care about this? [-Wunused-but-set-variable isn't normally set.
Under what circumstances does it get set in your setup?

I did this:

--- a/lib/vsprintf.c~kallsyms-enhance-%ps-s-b-printing-when-kallsysms-is-disabled-fix
+++ a/lib/vsprintf.c
@@ -988,7 +988,7 @@ static int sprint_module_info(char *buf,
unsigned long base;
int ret = 0;
const char *modname;
- int modbuildid = 0;
+ int modbuildid __maybe_unused = 0;
int len;
#if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
const unsigned char *buildid = NULL;
_


> lib/vsprintf.c: In function 'va_format':
> lib/vsprintf.c:1759:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 1759 | buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
> | ^~~

I wonder what this means.