提交 d62c4765 编写于 作者: M Masahiro Yamada

modpost: use strstarts() helper more widely

Currently, strstarts() is only used in export_from_secname().
Use it more widely to improve the code readability.
Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
上级 bca2ccee
...@@ -596,19 +596,19 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) ...@@ -596,19 +596,19 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
return 1; return 1;
if (info->hdr->e_machine == EM_PPC) if (info->hdr->e_machine == EM_PPC)
/* Special register function linked on all modules during final link of .ko */ /* Special register function linked on all modules during final link of .ko */
if (strncmp(symname, "_restgpr_", sizeof("_restgpr_") - 1) == 0 || if (strstarts(symname, "_restgpr_") ||
strncmp(symname, "_savegpr_", sizeof("_savegpr_") - 1) == 0 || strstarts(symname, "_savegpr_") ||
strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 || strstarts(symname, "_rest32gpr_") ||
strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0 || strstarts(symname, "_save32gpr_") ||
strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || strstarts(symname, "_restvr_") ||
strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0) strstarts(symname, "_savevr_"))
return 1; return 1;
if (info->hdr->e_machine == EM_PPC64) if (info->hdr->e_machine == EM_PPC64)
/* Special register function linked on all modules during final link of .ko */ /* Special register function linked on all modules during final link of .ko */
if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 || if (strstarts(symname, "_restgpr0_") ||
strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 || strstarts(symname, "_savegpr0_") ||
strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || strstarts(symname, "_restvr_") ||
strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0 || strstarts(symname, "_savevr_") ||
strcmp(symname, ".TOC.") == 0) strcmp(symname, ".TOC.") == 0)
return 1; return 1;
/* Do not ignore this symbol */ /* Do not ignore this symbol */
...@@ -623,13 +623,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info, ...@@ -623,13 +623,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
bool is_crc = false; bool is_crc = false;
if ((!is_vmlinux(mod->name) || mod->is_dot_o) && if ((!is_vmlinux(mod->name) || mod->is_dot_o) &&
strncmp(symname, "__ksymtab", 9) == 0) strstarts(symname, "__ksymtab"))
export = export_from_secname(info, get_secindex(info, sym)); export = export_from_secname(info, get_secindex(info, sym));
else else
export = export_from_sec(info, get_secindex(info, sym)); export = export_from_sec(info, get_secindex(info, sym));
/* CRC'd symbol */ /* CRC'd symbol */
if (strncmp(symname, "__crc_", strlen("__crc_")) == 0) { if (strstarts(symname, "__crc_")) {
is_crc = true; is_crc = true;
crc = (unsigned int) sym->st_value; crc = (unsigned int) sym->st_value;
if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) { if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) {
...@@ -648,7 +648,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, ...@@ -648,7 +648,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
switch (sym->st_shndx) { switch (sym->st_shndx) {
case SHN_COMMON: case SHN_COMMON:
if (!strncmp(symname, "__gnu_lto_", sizeof("__gnu_lto_")-1)) { if (strstarts(symname, "__gnu_lto_")) {
/* Should warn here, but modpost runs before the linker */ /* Should warn here, but modpost runs before the linker */
} else } else
warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
...@@ -691,7 +691,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, ...@@ -691,7 +691,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
break; break;
default: default:
/* All exported symbols */ /* All exported symbols */
if (strncmp(symname, "__ksymtab_", strlen("__ksymtab_")) == 0) { if (strstarts(symname, "__ksymtab_")) {
sym_add_exported(symname + strlen("__ksymtab_"), mod, sym_add_exported(symname + strlen("__ksymtab_"), mod,
export); export);
} }
...@@ -1171,13 +1171,13 @@ static int secref_whitelist(const struct sectioncheck *mismatch, ...@@ -1171,13 +1171,13 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
/* Check for pattern 1 */ /* Check for pattern 1 */
if (match(tosec, init_data_sections) && if (match(tosec, init_data_sections) &&
match(fromsec, data_sections) && match(fromsec, data_sections) &&
(strncmp(fromsym, "__param", strlen("__param")) == 0)) strstarts(fromsym, "__param"))
return 0; return 0;
/* Check for pattern 1a */ /* Check for pattern 1a */
if (strcmp(tosec, ".init.text") == 0 && if (strcmp(tosec, ".init.text") == 0 &&
match(fromsec, data_sections) && match(fromsec, data_sections) &&
(strncmp(fromsym, "__param_ops_", strlen("__param_ops_")) == 0)) strstarts(fromsym, "__param_ops_"))
return 0; return 0;
/* Check for pattern 2 */ /* Check for pattern 2 */
...@@ -1532,8 +1532,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, ...@@ -1532,8 +1532,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
from = find_elf_symbol2(elf, r->r_offset, fromsec); from = find_elf_symbol2(elf, r->r_offset, fromsec);
fromsym = sym_name(elf, from); fromsym = sym_name(elf, from);
if (!strncmp(fromsym, "reference___initcall", if (strstarts(fromsym, "reference___initcall"))
sizeof("reference___initcall")-1))
return; return;
tosec = sec_name(elf, get_secindex(elf, sym)); tosec = sec_name(elf, get_secindex(elf, sym));
...@@ -2163,9 +2162,7 @@ static void add_retpoline(struct buffer *b) ...@@ -2163,9 +2162,7 @@ static void add_retpoline(struct buffer *b)
static void add_staging_flag(struct buffer *b, const char *name) static void add_staging_flag(struct buffer *b, const char *name)
{ {
static const char *staging_dir = "drivers/staging"; if (strstarts(name, "drivers/staging"))
if (strncmp(staging_dir, name, strlen(staging_dir)) == 0)
buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册