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.
Showing the changes to scripts (2 of 2 files). Show all
Unified · Split
| @@ -187,7 +187,14 @@ static struct module *new_module(const char *modname) · 186 unmodified lines | ||
| 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 | |
| @@ -2012,10 +2019,8 @@ static void read_symbols(const char *modname) · 1818 unmodified lines | ||
| 2012 | 2019 | if (!license) |
| 2013 | 2020 | error("missing MODULE_LICENSE() in %s\n", modname); |
| 2014 | 2021 | while (license) { |
| 2015 | − if (license_is_gpl_compatible(license)) | |
| 2016 | − mod->gpl_compatible = 1; | |
| 2017 | − else { | |
| 2018 | − mod->gpl_compatible = 0; | |
| 2022 | + if (!license_is_gpl_compatible(license)) { | |
| 2023 | + mod->is_gpl_compatible = false; | |
| 2019 | 2024 | break; |
| 2020 | 2025 | } |
| 2021 | 2026 | license = get_next_modinfo(&info, "license", license); |
| @@ -2183,7 +2188,7 @@ static void check_exports(struct module *mod) · 161 unmodified lines | ||
| 2183 | 2188 | add_namespace(&mod->missing_namespaces, exp->namespace); |
| 2184 | 2189 | } |
| 2185 | 2190 | |
| 2186 | − if (!mod->gpl_compatible) | |
| 2191 | + if (!mod->is_gpl_compatible) | |
| 2187 | 2192 | check_for_gpl_usage(exp->export, basename, exp->name); |
| 2188 | 2193 | } |
| 2189 | 2194 | } |
| @@ -112,7 +112,7 @@ buf_write(struct buffer *buf, const char *s, int len); · 111 unmodified lines | ||
| 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; |