Skip to content

Commit 7452dd2

Browse files
committed
modpost: add PATTERNS() helper macro
This will be useful to define a NULL-terminated array inside a function call. Currently, string arrays passed to match() are defined in separate places: static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL }; static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL }; static const char *const optim_symbols[] = { "*.constprop.*", NULL }; ... /* Check for pattern 5 */ if (match(fromsec, text_sections) && match(tosec, init_sections) && match(fromsym, optim_symbols)) return 0; With the new helper macro, you can list the patterns directly in the function call, like this: /* Check for pattern 5 */ if (match(fromsec, PATTERNS(ALL_TEXT_SECTIONS)) && match(tosec, PATTERNS(ALL_INIT_SECTIONS)) && match(fromsym, PATTERNS("*.contprop.*"))) return 0; Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 072dd2c commit 7452dd2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scripts/mod/modpost.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,13 @@ static bool match(const char *string, const char *const patterns[])
746746
return false;
747747
}
748748

749+
/* useful to pass patterns to match() directly */
750+
#define PATTERNS(...) \
751+
({ \
752+
static const char *const patterns[] = {__VA_ARGS__, NULL}; \
753+
patterns; \
754+
})
755+
749756
/* sections that we do not want to do full section mismatch check on */
750757
static const char *const section_white_list[] =
751758
{

0 commit comments

Comments
 (0)