From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: Thomas Monjalon <thomas@monjalon.net>
Subject: [dpdk-dev] [PATCH] devtools: check logtype format
Date: Fri, 19 Mar 2021 21:37:37 +0100 [thread overview]
Message-ID: <20210319203737.13526-1-david.marchand@redhat.com> (raw)
Enforce that added logtypes follow the convention:
- for lib/librte_XXX: lib.XXX and lib.XXX.*
- for drivers/class/XXX: pmd.class.XXX and pmd.class.XXX.*
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
devtools/checkpatches.sh | 44 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 78a408ef98..11ad4bee8d 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -199,6 +199,42 @@ check_internal_tags() { # <patch>
return $res
}
+check_logtypes() { # <patch>
+ res=0
+
+ cat "$1" |awk '
+ BEGIN {
+ pattern = "";
+ ret = 0;
+ }
+ /^+++ b\// {
+ count = split($2, path, "/")
+ if (count >= 4 && path[2] == "lib") {
+ pattern = "lib\\." gensub(/librte_(.*)/, "\\1", "", path[3])
+ } else if (count >= 5 && path[2] == "drivers") {
+ pattern = "pmd\\." path[3] "\\." path[4]
+ } else {
+ pattern = "";
+ }
+ }
+ /^+.*RTE_LOG_REGISTER\([^,]+,[^,]+,/ {
+ if (pattern == "") {
+ next;
+ }
+ if (!($0 ~ "RTE_LOG_REGISTER\\([^,]+, " pattern "(|\\.[^,]+),")) {
+ print $0
+ print "Added logtype does not comply with pattern: " \
+ gensub(/\\/, "", "g", pattern)
+ ret = 1;
+ }
+ }
+ END {
+ exit ret;
+ }' || res=1
+
+ return $res
+}
+
number=0
range='origin/main..'
quiet=false
@@ -290,6 +326,14 @@ check () { # <patch> <commit> <title>
ret=1
fi
+ ! $verbose || printf '\nChecking RTE_LOG_REGISTER:\n'
+ report=$(check_logtypes "$tmpinput")
+ if [ $? -ne 0 ] ; then
+ $headline_printed || print_headline "$3"
+ printf '%s\n' "$report"
+ ret=1
+ fi
+
if [ "$tmpinput" != "$1" ]; then
rm -f "$tmpinput"
trap - INT
--
2.23.0
next reply other threads:[~2021-03-19 20:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 20:37 David Marchand [this message]
2021-03-20 7:26 ` Thomas Monjalon
2021-03-21 20:33 ` Andrew Rybchenko
2021-05-11 9:46 ` David Marchand
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=20210319203737.13526-1-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/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;
as well as URLs for NNTP newsgroup(s).