fixdep: use existing helper to check modular CONFIG options

str_ends_with() tests if the given token ends with a particular string.
Currently, it is used to check file paths without $(srctree).

Actually, we have one more place where this helper is useful.  Use it
to check if CONFIG option ends with _MODULE.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
Masahiro Yamada 2018-01-11 22:05:46 +09:00
parent 87b95a8135
commit ab9ce9feed

View File

@ -219,25 +219,6 @@ static void use_config(const char *m, int slen)
print_config(m, slen); print_config(m, slen);
} }
static void parse_config_file(const char *p)
{
const char *q, *r;
while ((p = strstr(p, "CONFIG_"))) {
p += 7;
q = p;
while (*q && (isalnum(*q) || *q == '_'))
q++;
if (memcmp(q - 7, "_MODULE", 7) == 0)
r = q - 7;
else
r = q;
if (r > p)
use_config(p, r - p);
p = q;
}
}
/* test if s ends in sub */ /* test if s ends in sub */
static int str_ends_with(const char *s, int slen, const char *sub) static int str_ends_with(const char *s, int slen, const char *sub)
{ {
@ -249,6 +230,25 @@ static int str_ends_with(const char *s, int slen, const char *sub)
return !memcmp(s + slen - sublen, sub, sublen); return !memcmp(s + slen - sublen, sub, sublen);
} }
static void parse_config_file(const char *p)
{
const char *q, *r;
while ((p = strstr(p, "CONFIG_"))) {
p += 7;
q = p;
while (*q && (isalnum(*q) || *q == '_'))
q++;
if (str_ends_with(p, q - p, "_MODULE"))
r = q - 7;
else
r = q;
if (r > p)
use_config(p, r - p);
p = q;
}
}
static void *read_file(const char *filename) static void *read_file(const char *filename)
{ {
struct stat st; struct stat st;