diff mbox series

[1/4] modpost: pass struct elf_info pointer to get_modinfo()

Message ID 1525859440-29583-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit bca2ccee4c4ac69496d3c8655d7869122fe5aeab
Headers show
Series [1/4] modpost: pass struct elf_info pointer to get_modinfo() | expand

Commit Message

Masahiro Yamada May 9, 2018, 9:50 a.m. UTC
get_(next_)modinfo takes a pointer and length pair of the .modinfo
section.  Instead, pass struct elf_info pointer to reduce the number
of function arguments.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 scripts/mod/modpost.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

-- 
2.7.4

Comments

Masahiro Yamada May 14, 2018, 12:12 a.m. UTC | #1
2018-05-09 18:50 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> get_(next_)modinfo takes a pointer and length pair of the .modinfo

> section.  Instead, pass struct elf_info pointer to reduce the number

> of function arguments.

>

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> ---


Series, applied to linux-kbuild.


>  scripts/mod/modpost.c | 25 ++++++++++++-------------

>  1 file changed, 12 insertions(+), 13 deletions(-)

>

> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c

> index bc71925..37a6a0b4 100644

> --- a/scripts/mod/modpost.c

> +++ b/scripts/mod/modpost.c

> @@ -724,16 +724,17 @@ static char *next_string(char *string, unsigned long *secsize)

>         return string;

>  }

>

> -static char *get_next_modinfo(void *modinfo, unsigned long modinfo_len,

> -                             const char *tag, char *info)

> +static char *get_next_modinfo(struct elf_info *info, const char *tag,

> +                             char *prev)

>  {

>         char *p;

>         unsigned int taglen = strlen(tag);

> -       unsigned long size = modinfo_len;

> +       char *modinfo = info->modinfo;

> +       unsigned long size = info->modinfo_len;

>

> -       if (info) {

> -               size -= info - (char *)modinfo;

> -               modinfo = next_string(info, &size);

> +       if (prev) {

> +               size -= prev - modinfo;

> +               modinfo = next_string(prev, &size);

>         }

>

>         for (p = modinfo; p; p = next_string(p, &size)) {

> @@ -743,11 +744,10 @@ static char *get_next_modinfo(void *modinfo, unsigned long modinfo_len,

>         return NULL;

>  }

>

> -static char *get_modinfo(void *modinfo, unsigned long modinfo_len,

> -                        const char *tag)

> +static char *get_modinfo(struct elf_info *info, const char *tag)

>

>  {

> -       return get_next_modinfo(modinfo, modinfo_len, tag, NULL);

> +       return get_next_modinfo(info, tag, NULL);

>  }

>

>  /**

> @@ -1951,7 +1951,7 @@ static void read_symbols(char *modname)

>                 mod->skip = 1;

>         }

>

> -       license = get_modinfo(info.modinfo, info.modinfo_len, "license");

> +       license = get_modinfo(&info, "license");

>         if (!license && !is_vmlinux(modname))

>                 warn("modpost: missing MODULE_LICENSE() in %s\n"

>                      "see include/linux/module.h for "

> @@ -1963,8 +1963,7 @@ static void read_symbols(char *modname)

>                         mod->gpl_compatible = 0;

>                         break;

>                 }

> -               license = get_next_modinfo(info.modinfo, info.modinfo_len,

> -                                          "license", license);

> +               license = get_next_modinfo(&info, "license", license);

>         }

>

>         for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {

> @@ -1977,7 +1976,7 @@ static void read_symbols(char *modname)

>              (is_vmlinux(modname) && vmlinux_section_warnings))

>                 check_sec_ref(mod, modname, &info);

>

> -       version = get_modinfo(info.modinfo, info.modinfo_len, "version");

> +       version = get_modinfo(&info, "version");

>         if (version)

>                 maybe_frob_rcs_version(modname, version, info.modinfo,

>                                        version - (char *)info.hdr);

> --

> 2.7.4

>




-- 
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index bc71925..37a6a0b4 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -724,16 +724,17 @@  static char *next_string(char *string, unsigned long *secsize)
 	return string;
 }
 
-static char *get_next_modinfo(void *modinfo, unsigned long modinfo_len,
-			      const char *tag, char *info)
+static char *get_next_modinfo(struct elf_info *info, const char *tag,
+			      char *prev)
 {
 	char *p;
 	unsigned int taglen = strlen(tag);
-	unsigned long size = modinfo_len;
+	char *modinfo = info->modinfo;
+	unsigned long size = info->modinfo_len;
 
-	if (info) {
-		size -= info - (char *)modinfo;
-		modinfo = next_string(info, &size);
+	if (prev) {
+		size -= prev - modinfo;
+		modinfo = next_string(prev, &size);
 	}
 
 	for (p = modinfo; p; p = next_string(p, &size)) {
@@ -743,11 +744,10 @@  static char *get_next_modinfo(void *modinfo, unsigned long modinfo_len,
 	return NULL;
 }
 
-static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
-			 const char *tag)
+static char *get_modinfo(struct elf_info *info, const char *tag)
 
 {
-	return get_next_modinfo(modinfo, modinfo_len, tag, NULL);
+	return get_next_modinfo(info, tag, NULL);
 }
 
 /**
@@ -1951,7 +1951,7 @@  static void read_symbols(char *modname)
 		mod->skip = 1;
 	}
 
-	license = get_modinfo(info.modinfo, info.modinfo_len, "license");
+	license = get_modinfo(&info, "license");
 	if (!license && !is_vmlinux(modname))
 		warn("modpost: missing MODULE_LICENSE() in %s\n"
 		     "see include/linux/module.h for "
@@ -1963,8 +1963,7 @@  static void read_symbols(char *modname)
 			mod->gpl_compatible = 0;
 			break;
 		}
-		license = get_next_modinfo(info.modinfo, info.modinfo_len,
-					   "license", license);
+		license = get_next_modinfo(&info, "license", license);
 	}
 
 	for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
@@ -1977,7 +1976,7 @@  static void read_symbols(char *modname)
 	     (is_vmlinux(modname) && vmlinux_section_warnings))
 		check_sec_ref(mod, modname, &info);
 
-	version = get_modinfo(info.modinfo, info.modinfo_len, "version");
+	version = get_modinfo(&info, "version");
 	if (version)
 		maybe_frob_rcs_version(modname, version, info.modinfo,
 				       version - (char *)info.hdr);