Skip to content

Commit 9d98038

Browse files
committed
modpost: move strstarts() to modpost.h
This macro is useful in file2alias.c as well. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent abd2042 commit 9d98038

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

scripts/mod/file2alias.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
15151515
return;
15161516

15171517
/* All our symbols are of form __mod_<name>__<identifier>_device_table. */
1518-
if (strncmp(symname, "__mod_", strlen("__mod_")))
1518+
if (!strstarts(symname, "__mod_"))
15191519
return;
15201520
name = symname + strlen("__mod_");
15211521
namelen = strlen(name);

scripts/mod/modpost.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,6 @@ static const char *sec_name(const struct elf_info *info, unsigned int secindex)
341341
return sech_name(info, &info->sechdrs[secindex]);
342342
}
343343

344-
#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
345-
346344
static struct symbol *sym_add_exported(const char *name, struct module *mod,
347345
bool gpl_only, const char *namespace)
348346
{

scripts/mod/modpost.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767

6868
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
6969

70+
#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
71+
7072
struct buffer {
7173
char *p;
7274
int pos;

0 commit comments

Comments
 (0)