Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modpost: change mod->gpl_compatible to bool type

Currently, mod->gpl_compatible is tristate; it is set to -1 by default,
then to 1 or 0 when MODULE_LICENSE() is found.

Maybe, -1 was chosen to represent the 'unknown' license, but it is not
useful.

The current code:

if (!mod->gpl_compatible)
check_for_gpl_usage(exp->export, basename, exp->name);

... only cares whether gpl_compatible is zero or not.

Change it to a bool type with the initial value 'true', which has no
functional change.

The default value should be 'true' instead of 'false'.

Since commit 1d6cd3929360 ("modpost: turn missing MODULE_LICENSE() into
error"), unknown module license is an error.

The error message, "missing MODULE_LICENSE()" is enough to explain the
issue. It is not sensible to show another message, "GPL-incompatible
module ... uses GPL-only symbol".

Add comments to explain this.

While I was here, I renamed gpl_compatible to is_gpl_compatible for
clarification, and also slightly refactored the code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

+12 -7
+11 -6
scripts/mod/modpost.c
··· 187 187 /* add to list */ 188 188 strcpy(mod->name, modname); 189 189 mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0); 190 - mod->gpl_compatible = -1; 190 + 191 + /* 192 + * Set mod->is_gpl_compatible to true by default. If MODULE_LICENSE() 193 + * is missing, do not check the use for EXPORT_SYMBOL_GPL() becasue 194 + * modpost will exit wiht error anyway. 195 + */ 196 + mod->is_gpl_compatible = true; 197 + 191 198 mod->next = modules; 192 199 modules = mod; 193 200 ··· 2019 2012 if (!license) 2020 2013 error("missing MODULE_LICENSE() in %s\n", modname); 2021 2014 while (license) { 2022 - if (license_is_gpl_compatible(license)) 2023 - mod->gpl_compatible = 1; 2024 - else { 2025 - mod->gpl_compatible = 0; 2015 + if (!license_is_gpl_compatible(license)) { 2016 + mod->is_gpl_compatible = false; 2026 2017 break; 2027 2018 } 2028 2019 license = get_next_modinfo(&info, "license", license); ··· 2188 2183 add_namespace(&mod->missing_namespaces, exp->namespace); 2189 2184 } 2190 2185 2191 - if (!mod->gpl_compatible) 2186 + if (!mod->is_gpl_compatible) 2192 2187 check_for_gpl_usage(exp->export, basename, exp->name); 2193 2188 } 2194 2189 }
+1 -1
scripts/mod/modpost.h
··· 112 112 113 113 struct module { 114 114 struct module *next; 115 - int gpl_compatible; 115 + bool is_gpl_compatible; 116 116 struct symbol *unres; 117 117 bool from_dump; /* true if module was loaded from *.symvers */ 118 118 bool is_vmlinux;