Skip to content

Commit ab9ce9f

Browse files
committed
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>
1 parent 87b95a8 commit ab9ce9f

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

scripts/basic/fixdep.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ static void use_config(const char *m, int slen)
219219
print_config(m, slen);
220220
}
221221

222+
/* test if s ends in sub */
223+
static int str_ends_with(const char *s, int slen, const char *sub)
224+
{
225+
int sublen = strlen(sub);
226+
227+
if (sublen > slen)
228+
return 0;
229+
230+
return !memcmp(s + slen - sublen, sub, sublen);
231+
}
232+
222233
static void parse_config_file(const char *p)
223234
{
224235
const char *q, *r;
@@ -228,7 +239,7 @@ static void parse_config_file(const char *p)
228239
q = p;
229240
while (*q && (isalnum(*q) || *q == '_'))
230241
q++;
231-
if (memcmp(q - 7, "_MODULE", 7) == 0)
242+
if (str_ends_with(p, q - p, "_MODULE"))
232243
r = q - 7;
233244
else
234245
r = q;
@@ -238,17 +249,6 @@ static void parse_config_file(const char *p)
238249
}
239250
}
240251

241-
/* test if s ends in sub */
242-
static int str_ends_with(const char *s, int slen, const char *sub)
243-
{
244-
int sublen = strlen(sub);
245-
246-
if (sublen > slen)
247-
return 0;
248-
249-
return !memcmp(s + slen - sublen, sub, sublen);
250-
}
251-
252252
static void *read_file(const char *filename)
253253
{
254254
struct stat st;

0 commit comments

Comments
 (0)