Re: [PATCH v5 03/13] module: Make internal.h more compliant

From: Christophe Leroy
Date: Thu Feb 10 2022 - 06:20:15 EST




Le 09/02/2022 à 18:03, Aaron Tomlin a écrit :
> This patch will address the following warning and style violations
> generated by ./scripts/checkpatch.pl:
>
> WARNING: Use #include <linux/module.h> instead of <asm/module.h>
> #10: FILE: kernel/module/internal.h:10:
> +#include <asm/module.h>
>
> CHECK: spaces preferred around that '-' (ctx:VxV)
> #18: FILE: kernel/module/internal.h:18:
> +#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))
> ^
> CHECK: extern prototypes should be avoided in .h files
> #84: FILE: kernel/module/internal.h:84:
> +extern int mod_verify_sig(const void *mod, struct load_info *info);
>
> Note: Fortunately, the multiple-include optimisation found in
> include/linux/module.h will prevent duplication/or inclusion more than
> once.
>
> Fixes: f314dfea16a ("modsign: log module name in the event of an error")
> Signed-off-by: Aaron Tomlin <atomlin@xxxxxxxxxx>

Reviewed-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>

> ---
> kernel/module/internal.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/module/internal.h b/kernel/module/internal.h
> index 1a4b33ce9f5f..1cf5d6dabc97 100644
> --- a/kernel/module/internal.h
> +++ b/kernel/module/internal.h
> @@ -6,7 +6,8 @@
> */
>
> #include <linux/elf.h>
> -#include <asm/module.h>
> +#include <linux/compiler.h>
> +#include <linux/module.h>
> #include <linux/mutex.h>
>
> #ifndef ARCH_SHF_SMALL
> @@ -14,7 +15,7 @@
> #endif
>
> /* If this is set, the section belongs in the init part of the module */
> -#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))
> +#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG - 1))
> /* Maximum number of characters written by module_flags() */
> #define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4)
> #define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4))
> @@ -55,7 +56,7 @@ struct load_info {
> } index;
> };
>
> -extern int mod_verify_sig(const void *mod, struct load_info *info);
> +int mod_verify_sig(const void *mod, struct load_info *info);
>
> #ifdef CONFIG_MODULE_DECOMPRESS
> int module_decompress(struct load_info *info, const void *buf, size_t size);