diff options
| author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-11 08:05:46 -0500 |
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-17 19:37:39 -0500 |
| commit | ab9ce9feed362f3f51e239f9421b220aaf9211aa (patch) | |
| tree | 4f4ed4dd6bb13b5ce56ed71f1ef84097ff081e6c /scripts/basic | |
| parent | 87b95a81357dd6ec679a786cebfe34d0e797f752 (diff) | |
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>
Diffstat (limited to 'scripts/basic')
| -rw-r--r-- | scripts/basic/fixdep.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 0abc15778f56..fa3d39b6f23b 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
| @@ -219,6 +219,17 @@ static void use_config(const char *m, int slen) | |||
| 219 | print_config(m, slen); | 219 | print_config(m, slen); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 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 | |||
| 222 | static void parse_config_file(const char *p) | 233 | static void parse_config_file(const char *p) |
| 223 | { | 234 | { |
| 224 | const char *q, *r; | 235 | const char *q, *r; |
| @@ -228,7 +239,7 @@ static void parse_config_file(const char *p) | |||
| 228 | q = p; | 239 | q = p; |
| 229 | while (*q && (isalnum(*q) || *q == '_')) | 240 | while (*q && (isalnum(*q) || *q == '_')) |
| 230 | q++; | 241 | q++; |
| 231 | if (memcmp(q - 7, "_MODULE", 7) == 0) | 242 | if (str_ends_with(p, q - p, "_MODULE")) |
| 232 | r = q - 7; | 243 | r = q - 7; |
| 233 | else | 244 | else |
| 234 | r = q; | 245 | r = q; |
| @@ -238,17 +249,6 @@ static void parse_config_file(const char *p) | |||
| 238 | } | 249 | } |
| 239 | } | 250 | } |
| 240 | 251 | ||
| 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 | |||
| 252 | static void *read_file(const char *filename) | 252 | static void *read_file(const char *filename) |
| 253 | { | 253 | { |
| 254 | struct stat st; | 254 | struct stat st; |
