modpost: rework and consolidate logging interface
PATCH v2 1/2 modpost: rework and consolidate logging interface
Rework modpost's logging interface by consolidating merror(), warn(), and fatal() to use a single function, modpost_log(). Introduce different logging levels (WARN, ERROR, FATAL) as well as a conditional warn (warn_unless()). The conditional warn is useful in determining whether to use merror() or warn() based on a condition. This reduces code duplication overall.
---
v2:
- modpost_log: initialize level to ""
- remove parens () from case labels
scripts/mod/modpost.c | 69 +++++++++++++++++++++++---------------------------- scripts/mod/modpost.h | 22 +++++++++++++--- 2 files changed, 50 insertions(+), 41 deletions(-)
scripts/mod/modpost.c +31 -38
@@ -51,41 +51,37 @@ enum export {#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) -#define PRINTF __attribute__ ((format (printf, 1, 2))) +#define PRINTF __attribute__ ((format (printf, 2, 3))) -PRINTF void fatal(const char *fmt, ...) +PRINTF void modpost_log(enum loglevel loglevel, const char *fmt, ...) { +char *level ="" ;va_list arglist; -fprintf (stderr,"FATAL: " ); - -va_start (arglist, fmt); -vfprintf (stderr, fmt, arglist); -va_end (arglist); - -exit (1 ); -} - -PRINTF void warn(const char *fmt, ...) -{ -va_list arglist; +switch (loglevel) { +case LOG_WARN : + level ="WARNING: " ; +break ; +case LOG_ERROR : + level ="ERROR: " ; +break ; +case LOG_FATAL : + level ="FATAL: " ; +break ; +default :/* invalid loglevel, ignore */ +break ; + } -fprintf (stderr,"WARNING: " ); +fprintf (stderr, level); +fprintf (stderr,"modpost: " );va_start (arglist, fmt);vfprintf (stderr, fmt, arglist);va_end (arglist); -} -PRINTF void merror(const char *fmt, ...) -{ -va_list arglist; - -fprintf (stderr,"ERROR: " ); +if (loglevel ==LOG_FATAL ) +exit (1 ); -va_start (arglist, fmt); -vfprintf (stderr, fmt, arglist); -va_end (arglist); }static inline bool strends (const char *str,const char *postfix)
@@ -113,7 +109,7 @@ static int is_vmlinux(const char *modname)void *do_nofail (void *ptr,const char *expr) {if (!ptr) -fatal ("modpost: Memory allocation failure: %s.\n" , expr); +fatal ("Memory allocation failure: %s.\n" , expr);return ptr; }
@@ -2021,7 +2017,7 @@ static void read_symbols(const char *modname) license =get_modinfo (&info,"license" );if (!license && !is_vmlinux (modname)) -warn ("modpost: missing MODULE_LICENSE() in %s\n" +warn ("missing MODULE_LICENSE() in %s\n" "see include/linux/module.h for " "more information\n" , modname);while (license) {
@@ -2152,15 +2148,15 @@ static void check_for_gpl_usage(enum export exp, const char *m, const char *s)switch (exp) {case export_gpl: -fatal ("modpost: GPL-incompatible module %s%s " +fatal ("GPL-incompatible module %s%s " "uses GPL-only symbol '%s'\n" , m, e, s);break ;case export_unused_gpl: -fatal ("modpost: GPL-incompatible module %s%s " +fatal ("GPL-incompatible module %s%s " "uses GPL-only symbol marked UNUSED '%s'\n" , m, e, s);break ;case export_gpl_future: -warn ("modpost: GPL-incompatible module %s%s " +warn ("GPL-incompatible module %s%s " "uses future GPL-only symbol '%s'\n" , m, e, s);break ;case export_plain:
@@ -2178,7 +2174,7 @@ static void check_for_unused(enum export exp, const char *m, const char *s)switch (exp) {case export_unused:case export_unused_gpl: -warn ("modpost: module %s%s " +warn ("module %s%s " "uses symbol '%s' marked UNUSED\n" , m, e, s);break ;default :
@@ -2197,14 +2193,11 @@ static int check_exports(struct module *mod) exp =find_symbol (s->name);if (!exp || exp->module == mod) {if (have_vmlinux && !s->weak) { -if (warn_unresolved) { -warn ("\"%s\" [%s.ko] undefined!\n" , - s->name, mod->name); - }else { -merror ("\"%s\" [%s.ko] undefined!\n" , - s->name, mod->name); +warn_unless (!warn_unresolved, +"\"%s\" [%s.ko] undefined!\n" , + s->name, mod->name); +if (!warn_unresolved) err =1 ; - } }continue ; }
@@ -2653,7 +2646,7 @@ int main(int argc, char **argv)if (dump_write)write_dump (dump_write);if (sec_mismatch_count && sec_mismatch_fatal) -fatal ("modpost: Section mismatches detected.\n" +fatal ("Section mismatches detected.\n" "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n" );for (n =0 ; n <SYMBOL_HASH_SIZE ; n++) {struct symbol *s;
scripts/mod/modpost.h +19 -3
@@ -198,6 +198,22 @@ void *grab_file(const char *filename, unsigned long *size);char *get_next_line (unsigned long *pos,void *file,unsigned long size);void release_file (void *file,unsigned long size); -void fatal (const char *fmt, ...); -void warn (const char *fmt, ...); -void merror (const char *fmt, ...); +enum loglevel { +LOG_WARN , +LOG_ERROR , +LOG_FATAL +}; + +void modpost_log (enum loglevel loglevel,const char *fmt, ...); + +#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args) +#define merror(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) +#define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args) +/* Warn unless condition is true, then use merror() */ +#define warn_unless(condition, fmt, args...) \ +do { \ + if (condition) \ + merror(fmt, ##args); \ + else \ + warn(fmt, ##args); \ +} while (0)
Signature · 1 line
2.16.4
PATCH v2 2/2 modpost: return error if module is missing ns imports and MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n
Currently when CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n, modpost only warns when a module is missing namespace imports. Under this configuration, such a module cannot be loaded into the kernel anyway, as the module loader would reject it. We might as well return a build error when a module is missing namespace imports under CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n, so that the build warning does not go ignored/unnoticed.
--- scripts/Makefile.modpost | 15 ++++++++------- scripts/mod/modpost.c | 14 +++++++++++--- 2 files changed, 19 insertions(+), 10 deletions(-)
scripts/Makefile.modpost +8 -7
@@ -46,13 +46,14 @@ include scripts/Kbuild.include kernelsymfile := $(objtree)/Module.symvers modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers -MODPOST = scripts/mod/modpost \ - $(if $(CONFIG_MODVERSIONS),-m) \ - $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ - $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ - $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ - $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ - $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ +MODPOST = scripts/mod/modpost \ + $(if $(CONFIG_MODVERSIONS),-m) \ + $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ + $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ + $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ + $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ + $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ + $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \ $(if $(KBUILD_MODPOST_WARN),-w) ifdef MODPOST_VMLINUX
scripts/mod/modpost.c +11 -3
@@ -39,6 +39,8 @@ static int sec_mismatch_count = 0;static int sec_mismatch_fatal =0 ;/* ignore missing files */ static int ignore_missing_files; +/* If set to 1, only warn (instead of error) about missing ns imports */ +static int allow_missing_ns_imports =0 ;enum export { export_plain, export_unused, export_gpl,
@@ -2209,8 +2211,11 @@ static int check_exports(struct module *mod)if (exp->namespace && !module_imports_namespace (mod, exp->namespace)) { -warn ("module %s uses symbol %s from namespace %s, but does not import it.\n" , - basename, exp->name, exp->namespace); +warn_unless (!allow_missing_ns_imports, +"module %s uses symbol %s from namespace %s, but does not import it.\n" , + basename, exp->name, exp->namespace); +if (!allow_missing_ns_imports) + err =1 ;add_namespace (&mod->missing_namespaces, exp->namespace); }
@@ -2553,7 +2558,7 @@ int main(int argc, char **argv)struct ext_sym_list *extsym_iter;struct ext_sym_list *extsym_start =NULL ; -while ((opt =getopt (argc, argv,"i:e:mnsT:o:awEd:" )) !=-1 ) { +while ((opt =getopt (argc, argv,"i:e:mnsT:o:awENd:" )) !=-1 ) {switch (opt) {case 'i' : kernel_read = optarg;
@@ -2591,6 +2596,9 @@ int main(int argc, char **argv)case 'E' : sec_mismatch_fatal =1 ;break ; +case 'N' : + allow_missing_ns_imports =1 ; +break ;case 'd' : missing_namespace_deps = optarg;break ;
Signature · 1 line
2.16.4
Re: [PATCH v2 2/2] modpost: return error if module is missing ns imports and MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n
Quoted 10 lines · Jessica Yu
Currently when
CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n, modpost only warns when a module is missing namespace imports. Under this configuration, such a module cannot be loaded into the kernel anyway, as the module loader would reject it. We might as well return a build error when a module is missing namespace imports underCONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n, so that the build warning does not go ignored/unnoticed.Signed-off-by Jessica Yu <[email protected]>---
When you send v3, could you please fix the
following checkpatch warning and error?
WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#59:
Currently when CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n, modpost only warns
ERROR: do not initialise statics to 0
#107: FILE: scripts/mod/modpost.c:43:
+static int allow_missing_ns_imports = 0;
Quoted 79 lines
scripts/Makefile.modpost | 15 ++++++++------- scripts/mod/modpost.c | 14 +++++++++++--- 2 files changed, 19 insertions(+), 10 deletions(-)scripts/Makefile.modpost +8
-7@@ -46,13 +46,14 @@ include scripts/Kbuild.include kernelsymfile := $(objtree)/Module.symvers modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers -MODPOST = scripts/mod/modpost \ - $(if $(CONFIG_MODVERSIONS),-m) \ - $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ - $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ - $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ - $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ - $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ +MODPOST = scripts/mod/modpost \ + $(if $(CONFIG_MODVERSIONS),-m) \ + $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ + $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ + $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ + $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ + $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ + $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \ $(if $(KBUILD_MODPOST_WARN),-w) ifdef MODPOST_VMLINUXscripts/mod/modpost.c +11
-4@@ -39,6 +39,8 @@ static int sec_mismatch_count = 0;static int sec_mismatch_fatal =0 ;/* ignore missing files */ static int ignore_missing_files; +/* If set to 1, only warn (instead of error) about missing ns imports */ +static int allow_missing_ns_imports =0 ;enum export { export_plain, export_unused, export_gpl,@@ -2209,8 +2211,11 @@ static int check_exports(struct module *mod)if (exp->namespace && !module_imports_namespace (mod, exp->namespace)) { -warn ("module %s uses symbol %s from namespace %s, but does not import it.\n" , - basename, exp->name, exp->namespace); +warn_unless (!allow_missing_ns_imports, +"module %s uses symbol %s from namespace %s, but does not import it.\n" , + basename, exp->name, exp->namespace); +if (!allow_missing_ns_imports) + err =1 ;add_namespace (&mod->missing_namespaces, exp->namespace); }@@ -2553,7 +2558,7 @@ int main(int argc, char **argv)struct ext_sym_list *extsym_iter;struct ext_sym_list *extsym_start =NULL ; -while ((opt =getopt (argc, argv,"i:e:mnsT:o:awEd:" )) !=-1 ) { +while ((opt =getopt (argc, argv,"i:e:mnsT:o:awENd:" )) !=-1 ) {switch (opt) {case 'i' : kernel_read = optarg;@@ -2591,6 +2596,9 @@ int main(int argc, char **argv)case 'E' : sec_mismatch_fatal =1 ;break ; +case 'N' : + allow_missing_ns_imports =1 ; +break ;case 'd' : missing_namespace_deps = optarg;break ; --2.16.4
Signature · 2 lines
Best Regards Masahiro Yamada
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Jessica,
I love your patch! Yet something to improve:
[auto build test ERROR on kbuild/for-next]
[also build test ERROR on v5.6-rc4 next-20200302]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Jessica-Yu/modpost-rework-and-consolidate-logging-interface/20200227-024632 base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next config: openrisc-randconfig-a001-20200302 (attached as .config) compiler: or1k-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=openrisc
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
>> ERROR: modpost: "__mulsi3" [lib/xz/xz_dec.ko] undefined! >> ERROR: modpost: "__mulsi3" [lib/zstd/zstd_decompress.ko] undefined! >> ERROR: modpost: "__mulsi3" [lib/zstd/zstd_compress.ko] undefined! >> ERROR: modpost: "__mulsi3" [lib/842/842_compress.ko] undefined! ERROR: modpost: "__mulsi3" [lib/test_bpf.ko] undefined! ERROR: modpost: "__mulsi3" [lib/math/prime_numbers.ko] undefined! ERROR: modpost: "__mulsi3" [net/sunrpc/auth_gss/auth_rpcgss.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/counter/counter.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/rpmsg/virtio_rpmsg_bus.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/ssb/ssb.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-sensor-hub.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-wiimote.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-waltop.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/wacom.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-uclogic.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-tmff.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-steam.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-sony.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-roccat-kone.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-picolcd.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-ntrig.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-multitouch.ko] undefined! >> ERROR: modpost: "__mulsi3" [drivers/hid/hid-magicmouse.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hid/hid-logitech-hidpp.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hid/hid-lg-g15.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hid/hid-logitech.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hid/hid-gt683r.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hid/hid-elan.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hid/hid-asus.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hid/hid.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hid/usbhid/usbhid.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/w83l786ng.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/w83627ehf.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/tmp513.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/tmp401.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/tmp103.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/tmp102.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/thmc50.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/tc74.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/amc6821.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/smsc47m192.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/smsc47b397.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/smm665.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/shtc1.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/sht15.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/pc87360.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ntc_thermistor.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/nct6683.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/tc654.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/mcp3021.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/mc13783-adc.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/max6697.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/max6650.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/max6639.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/max6621.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/max1668.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/max1619.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/max16065.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ltc4261.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ltc4260.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ltc4245.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ltc4222.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ltc4215.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ltc4151.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ltc2990.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ltc2947-core.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm95245.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm95241.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm93.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm87.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm85.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm80.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm77.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm75.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lm73.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/lineage-pem.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/jc42.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/it87.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ina3221.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ina2xx.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ibmaem.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/gpio-fan.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/gl520sm.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/g762.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/g760a.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/f75375s.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/emc6w201.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/emc1403.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ds1621.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ds620.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/drivetemp.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/dme1737.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/aspeed-pwm-tacho.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/adt7462.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/adt7411.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ads7828.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/adm9240.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/adm1029.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/adm1026.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/adm1025.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/adm1021.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/adc128d818.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ad7418.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/ad7414.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/w83791d.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/w83781d.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/w83795.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/w83773g.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/hwmon/hwmon-vid.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/ata/libahci.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/ata/libata.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/temperature/mlx90632.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/temperature/mlx90614.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/proximity/srf04.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/proximity/isl29501.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/pressure/t5403.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/pressure/st_pressure.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/pressure/ms5637.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/pressure/ms5611_core.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/pressure/mpl115.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/pressure/hp03.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/pressure/dlhl60d.ko] undefined!
ERROR: modpost: "__mulsi3" [drivers/iio/potentiostat/lmp91000.ko] undefined!
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 23 lines · Jessica Yu
Rework modpost's logging interface by consolidating
merror(),warn(), andfatal()to use a single function,modpost_log(). Introduce different logging levels (WARN, ERROR, FATAL) as well as a conditional warn (warn_unless()). The conditional warn is useful in determining whether to usemerror()orwarn()based on a condition. This reduces code duplication overall.Signed-off-by Jessica Yu <[email protected]>---
v2:
-modpost_log: initialize level to ""
- remove parens () from case labelsscripts/mod/modpost.c | 69 +++++++++++++++++++++++---------------------------- scripts/mod/modpost.h | 22 +++++++++++++--- 2 files changed, 50 insertions(+), 41 deletions(-)scripts/mod/modpost.c +0
-0
scripts/mod/modpost.c enum export { · line 58
Quoted 10 lines
scripts/mod/modpost.c +3
-2@@ -51,41 +51,37 @@ enum export {#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) -#define PRINTF __attribute__ ((format (printf, 1, 2))) +#define PRINTF __attribute__ ((format (printf, 2, 3))) -PRINTF void fatal(const char *fmt, ...) +PRINTF void modpost_log(enum loglevel loglevel, const char *fmt, ...) { +char *level ="" ;
You can add 'const'.
const char *level = "";
Quoted 20 lines
scripts/mod/modpost.c +6
-12va_list arglist; -fprintf (stderr,"FATAL: " ); - -va_start (arglist, fmt); -vfprintf (stderr, fmt, arglist); -va_end (arglist); - -exit (1 ); -} - -PRINTF void warn(const char *fmt, ...) -{ -va_list arglist; +switch (loglevel) { +case LOG_WARN : + level ="WARNING: " ; +break ; +case LOG_ERROR : + level ="ERROR: " ;
scripts/mod/modpost.c enum export { · line 75
Quoted 10 lines
scripts/mod/modpost.c +8
-1+break ; +case LOG_FATAL : + level ="FATAL: " ; +break ; +default :/* invalid loglevel, ignore */ +break ; + } -fprintf (stderr,"WARNING: " ); +fprintf (stderr, level);
If I apply this patch, I see this warning:
scripts/mod/modpost.c: In function ‘modpost_log’:scripts/mod/modpost.c:77:2: warning: format not a string literal and no format arguments [-Wformat-security]
fprintf(stderr, level);
^~~~~~~
Please write like this:
fprintf(stderr, "%s", level);
Or, you can delete 'level', then write
string literals directly in fprintf().
switch(loglevel) {
case LOG_WARN:
fprintf(stderr, "WARNING: ");
break;
case LOG_ERROR:
fprintf(stderr, "ERROR: ");
break;
case LOG_FATAL:
fprintf(stderr, "FATAL: ");
break;
}Quoted 7 lines
scripts/mod/modpost.c +1
-1+fprintf (stderr,"modpost: " );va_start (arglist, fmt);vfprintf (stderr, fmt, arglist);va_end (arglist); -}
<snip>
Quoted 20 lines
scripts/mod/modpost.h +9
-3@@ -198,6 +198,22 @@ void *grab_file(const char *filename, unsigned long *size);char *get_next_line (unsigned long *pos,void *file,unsigned long size);void release_file (void *file,unsigned long size); -void fatal (const char *fmt, ...); -void warn (const char *fmt, ...); -void merror (const char *fmt, ...); +enum loglevel { +LOG_WARN , +LOG_ERROR , +LOG_FATAL +}; + +void modpost_log (enum loglevel loglevel,const char *fmt, ...); + +#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args)
scripts/mod/modpost.h void *grab_file(const char *filename, unsigned long *size); · line 219
Quoted 10 lines
scripts/mod/modpost.h +10
-0+#define merror(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) +#define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args) +/* Warn unless condition is true, then use merror() */ +#define warn_unless(condition, fmt, args...) \ +do { \ + if (condition) \ + merror(fmt, ##args); \ + else \ + warn(fmt, ##args); \ +} while (0)
Hmm, warn_unless() is not intuitive naming...
You could use modpost_log() directly in C code,
what do you think?
modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR,
"module %s uses symbol %s from namespace %s,
but does not import it.\n",
basename, exp->name, exp->namespace);
--
Best Regards
Masahiro Yamada
+++ Masahiro Yamada [03/03/20 23:42 +0900]:
Quoted 156 lines · Jessica Yu
Quoted 23 lines
Rework modpost's logging interface by consolidating
merror(),warn(), andfatal()to use a single function,modpost_log(). Introduce different logging levels (WARN, ERROR, FATAL) as well as a conditional warn (warn_unless()). The conditional warn is useful in determining whether to usemerror()orwarn()based on a condition. This reduces code duplication overall.Signed-off-by Jessica Yu <[email protected]>---
v2:
-modpost_log: initialize level to ""
- remove parens () from case labelsscripts/mod/modpost.c | 69 +++++++++++++++++++++++---------------------------- scripts/mod/modpost.h | 22 +++++++++++++--- 2 files changed, 50 insertions(+), 41 deletions(-)scripts/mod/modpost.c +0
-0scripts/mod/modpost.c enum export { · line 58
Quoted 10 lines
scripts/mod/modpost.c +3
-2@@ -51,41 +51,37 @@ enum export {#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) -#define PRINTF __attribute__ ((format (printf, 1, 2))) +#define PRINTF __attribute__ ((format (printf, 2, 3))) -PRINTF void fatal(const char *fmt, ...) +PRINTF void modpost_log(enum loglevel loglevel, const char *fmt, ...) { +char *level ="" ;You can add 'const'.
const char *level = "";Quoted 20 lines
scripts/mod/modpost.c +6
-12va_list arglist; -fprintf (stderr,"FATAL: " ); - -va_start (arglist, fmt); -vfprintf (stderr, fmt, arglist); -va_end (arglist); - -exit (1 ); -} - -PRINTF void warn(const char *fmt, ...) -{ -va_list arglist; +switch (loglevel) { +case LOG_WARN : + level ="WARNING: " ; +break ; +case LOG_ERROR : + level ="ERROR: " ;scripts/mod/modpost.c enum export { · line 75
Quoted 10 lines
scripts/mod/modpost.c +8
-1+break ; +case LOG_FATAL : + level ="FATAL: " ; +break ; +default :/* invalid loglevel, ignore */ +break ; + } -fprintf (stderr,"WARNING: " ); +fprintf (stderr, level);If I apply this patch, I see this warning:
scripts/mod/modpost.c: In function ‘modpost_log’:scripts/mod/modpost.c:77:2: warning: format not a string literal and no format arguments [-Wformat-security]
fprintf(stderr, level);
^~~~~~~Please write like this:
fprintf(stderr, "%s", level);Or, you can delete 'level', then write
string literals directly infprintf().switch(loglevel) {
caseLOG_WARN:fprintf(stderr, "WARNING: "); break; case LOG_ERROR: fprintf(stderr, "ERROR: "); break; case LOG_FATAL: fprintf(stderr, "FATAL: "); break; }Quoted 7 lines
scripts/mod/modpost.c +1
-1+fprintf (stderr,"modpost: " );va_start (arglist, fmt);vfprintf (stderr, fmt, arglist);va_end (arglist); -}<snip>
Quoted 20 lines
scripts/mod/modpost.h +9
-3@@ -198,6 +198,22 @@ void *grab_file(const char *filename, unsigned long *size);char *get_next_line (unsigned long *pos,void *file,unsigned long size);void release_file (void *file,unsigned long size); -void fatal (const char *fmt, ...); -void warn (const char *fmt, ...); -void merror (const char *fmt, ...); +enum loglevel { +LOG_WARN , +LOG_ERROR , +LOG_FATAL +}; + +void modpost_log (enum loglevel loglevel,const char *fmt, ...); + +#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args)scripts/mod/modpost.h void *grab_file(const char *filename, unsigned long *size); · line 219
Quoted 10 lines
scripts/mod/modpost.h +10
-0+#define merror(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) +#define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args) +/* Warn unless condition is true, then use merror() */ +#define warn_unless(condition, fmt, args...) \ +do { \ + if (condition) \ + merror(fmt, ##args); \ + else \ + warn(fmt, ##args); \ +} while (0)Hmm,
warn_unless()is not intuitive naming...
Quoted 8 lines
You could use
modpost_log()directly in C code,
what do you think?modpost_log(allow_missing_ns_imports ?
LOG_WARN:LOG_ERROR,
"module %s uses symbol %s from namespace %s,
but does not import it.\n",basename, exp->name, exp->namespace);
Yeah, I wasn't sure if I should expose modpost_log() and call it directly, so I wrapped it in warn_unless(). But I think it's not a big deal, so I'll just change it to a direct call. Thank you for the review!
Jessica
Quoted 131 lines · Jessica Yu
+++ Masahiro Yamada [03/03/20 23:42 +0900]:
Quoted 130 lines · Jessica Yu
Quoted 23 lines
Rework modpost's logging interface by consolidating
merror(),warn(), andfatal()to use a single function,modpost_log(). Introduce different logging levels (WARN, ERROR, FATAL) as well as a conditional warn (warn_unless()). The conditional warn is useful in determining whether to usemerror()orwarn()based on a condition. This reduces code duplication overall.Signed-off-by Jessica Yu <[email protected]>---
v2:
-modpost_log: initialize level to ""
- remove parens () from case labels
scripts/mod/modpost.c| 69 +++++++++++++++++++++++----------------------------scripts/mod/modpost.h| 22 +++++++++++++---2 files changed, 50 insertions(+), 41 deletions(-)scripts/mod/modpost.c +0
-0scripts/mod/modpost.c enum export { · line 58
Quoted 10 lines
scripts/mod/modpost.c +3
-2@@ -51,41 +51,37 @@ enum export {#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) -#define PRINTF __attribute__ ((format (printf, 1, 2))) +#define PRINTF __attribute__ ((format (printf, 2, 3))) -PRINTF void fatal(const char *fmt, ...) +PRINTF void modpost_log(enum loglevel loglevel, const char *fmt, ...) { +char *level ="" ;You can add 'const'.
const char *level = "";Quoted 20 lines
scripts/mod/modpost.c +6
-12va_list arglist; -fprintf (stderr,"FATAL: " ); - -va_start (arglist, fmt); -vfprintf (stderr, fmt, arglist); -va_end (arglist); - -exit (1 ); -} - -PRINTF void warn(const char *fmt, ...) -{ -va_list arglist; +switch (loglevel) { +case LOG_WARN : + level ="WARNING: " ; +break ; +case LOG_ERROR : + level ="ERROR: " ;scripts/mod/modpost.c enum export { · line 75
Quoted 10 lines
scripts/mod/modpost.c +8
-1+break ; +case LOG_FATAL : + level ="FATAL: " ; +break ; +default :/* invalid loglevel, ignore */ +break ; + } -fprintf (stderr,"WARNING: " ); +fprintf (stderr, level);If I apply this patch, I see this warning:
scripts/mod/modpost.c: In function ‘modpost_log’:scripts/mod/modpost.c:77:2: warning: format not a string literal and no format arguments [-Wformat-security]fprintf(stderr, level);
^~~~~~~Please write like this:
fprintf(stderr, "%s", level);Or, you can delete 'level', then write
string literals directly infprintf().switch(loglevel) {
caseLOG_WARN:fprintf(stderr, "WARNING: "); break; case LOG_ERROR: fprintf(stderr, "ERROR: "); break; case LOG_FATAL: fprintf(stderr, "FATAL: "); break; }Quoted 7 lines
scripts/mod/modpost.c +1
-1+fprintf (stderr,"modpost: " );va_start (arglist, fmt);vfprintf (stderr, fmt, arglist);va_end (arglist); -}<snip>
Quoted 8 lines
scripts/mod/modpost.h +0
-0@@ -198,6 +198,22 @@ void *grab_file(const char *filename, unsigned long *size);char *get_next_line (unsigned long *pos,void *file,unsigned long size);void release_file (void *file,unsigned long size);
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
scripts/mod/modpost.h +2
-3-void fatal (const char *fmt, ...); -void warn (const char *fmt, ...); -void merror (const char *fmt, ...); +enum loglevel { +LOG_WARN ,Quoted 8 lines
scripts/mod/modpost.h void *grab_file(const char *filename, unsigned long *size); · line 210
Quoted 8 lines
scripts/mod/modpost.h +8
-0+LOG_ERROR , +LOG_FATAL +}; + +void modpost_log (enum loglevel loglevel,const char *fmt, ...); + +#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args) +#define merror(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args)
The only thing that bothered me a bit was the inconsistent naming with 'merror'. I know error is reserved, but refactoring this whole code (thanks for that!) seems like a code opportunity to clean this up. (Or is it just me?)
Cheers,
Matthias
Quoted 27 lines
Quoted 13 lines
scripts/mod/modpost.h void *grab_file(const char *filename, unsigned long *size); · line 219
Quoted 9 lines
scripts/mod/modpost.h +9
-0+#define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args) +/* Warn unless condition is true, then use merror() */ +#define warn_unless(condition, fmt, args...) \ +do { \ + if (condition) \ + merror(fmt, ##args); \ + else \ + warn(fmt, ##args); \ +} while (0)Hmm,
warn_unless()is not intuitive naming...Quoted 8 lines
You could use
modpost_log()directly in C code,
what do you think?modpost_log(allow_missing_ns_imports ?
LOG_WARN:LOG_ERROR,
"module %s uses symbol %s from namespace %s,
but does not import it.\n",basename, exp->name, exp->namespace);Yeah, I wasn't sure if I should expose
modpost_log()and call it directly, so I wrapped it inwarn_unless(). But I think it's not a big deal, so I'll just change it to a direct call. Thank you for the review!Jessica
Quoted 38 lines · Jessica Yu
Rework modpost's logging interface by consolidating
merror(),warn(), andfatal()to use a single function,modpost_log(). Introduce different logging levels (WARN, ERROR, FATAL) as well as a conditional warn (warn_unless()). The conditional warn is useful in determining whether to usemerror()orwarn()based on a condition. This reduces code duplication overall.Signed-off-by Jessica Yu <[email protected]>---
v2:
-modpost_log: initialize level to ""
- remove parens () from case labelsscripts/mod/modpost.c | 69 +++++++++++++++++++++++---------------------------- scripts/mod/modpost.h | 22 +++++++++++++--- 2 files changed, 50 insertions(+), 41 deletions(-)scripts/mod/modpost.c +3
-5@@ -51,41 +51,37 @@ enum export {#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) -#define PRINTF __attribute__ ((format (printf, 1, 2))) +#define PRINTF __attribute__ ((format (printf, 2, 3))) -PRINTF void fatal(const char *fmt, ...) +PRINTF void modpost_log(enum loglevel loglevel, const char *fmt, ...) { +char *level ="" ;va_list arglist; -fprintf (stderr,"FATAL: " ); - -va_start (arglist, fmt);
scripts/mod/modpost.c enum export { · line 61
Quoted 10 lines
scripts/mod/modpost.c +1
-9-vfprintf (stderr, fmt, arglist); -va_end (arglist); - -exit (1 ); -} - -PRINTF void warn(const char *fmt, ...) -{ -va_list arglist; +switch (loglevel) {
One nit:
Please insert a space after 'switch'.
I see this checkpatch error:
ERROR: space required before the open parenthesis '(' #102: FILE: scripts/mod/modpost.c:61:
+ switch(loglevel) {
Signature · 2 lines
Best Regards Masahiro Yamada