mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] modpost: add PATTERNS() helper macro
Date: Mon,  1 Aug 2022 18:39:00 +0900	[thread overview]
Message-ID: <20220801093902.1506297-2-masahiroy@kernel.org> (raw)
In-Reply-To: <20220801093902.1506297-1-masahiroy@kernel.org>

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>
---

 scripts/mod/modpost.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 9e8ae2636ec1..c2949a1a0d5e 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -746,6 +746,13 @@ static bool match(const char *string, const char *const patterns[])
 	return false;
 }
 
+/* useful to pass patterns to match() directly */
+#define PATTERNS(...) \
+	({ \
+		static const char *const patterns[] = {__VA_ARGS__, NULL}; \
+		patterns; \
+	})
+
 /* sections that we do not want to do full section mismatch check on */
 static const char *const section_white_list[] =
 {
-- 
2.34.1


  reply	other threads:[~2022-08-01  9:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01  9:38 [PATCH 1/4] modpost: shorten warning messages in report_sec_mismatch() Masahiro Yamada
2022-08-01  9:39 ` Masahiro Yamada [this message]
2022-08-01  9:39 ` [PATCH 3/4] modpost: remove unneeded .symbol_white_list initializers Masahiro Yamada
2022-08-01  9:39 ` [PATCH 4/4] modpost: remove .symbol_white_list field entirely Masahiro Yamada
2022-08-02 18:13 ` [PATCH 1/4] modpost: shorten warning messages in report_sec_mismatch() Nick Desaulniers
2022-08-03 16:35   ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220801093902.1506297-2-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®