diff options
| author | David Marchand <[email protected]> | 2024-09-05 15:29:09 +0200 |
|---|---|---|
| committer | David Marchand <[email protected]> | 2024-10-03 16:18:26 +0200 |
| commit | 84cf9b71fc2d6baf1869ef213daee7ec9f8880bc (patch) | |
| tree | dd64f787031c4e992822342442321057238119dd /devtools | |
| parent | fd1bcb6c58b0752f408beaedfdb83a2e82173129 (diff) | |
devtools: fix forbidden token check with multiple files
If a patch contains multiple files, it is possible to pass through the
check because the count of token mentions is not reset between file
evaluation.
Example with a fake patch:
$ cat toto.patch
--- a/drivers/plop1
+++ b/drivers/plop1
- RTE_LOG(
- RTE_LOG(
+ RTE_LOG(
--- a/drivers/plop2
+++ b/drivers/plop2
+ RTE_LOG(
$ awk -v FOLDERS='drivers' -v EXPRESSIONS='RTE_LOG\\('
-v MESSAGE='Prefer RTE_LOG_LINE'
-f devtools/check-forbidden-tokens.awk toto.patch
Besides, the expressions[] array is not used since commit
b467d38284b1 ("devtools: add explicit warnings for forbidden tokens").
Fixes: 42f4d724ec27 ("devtools: move awk script ckecking forbidden tokens")
Signed-off-by: David Marchand <[email protected]>
Acked-by: Thomas Monjalon <[email protected]>
Diffstat (limited to 'devtools')
| -rwxr-xr-x | devtools/check-forbidden-tokens.awk | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/devtools/check-forbidden-tokens.awk b/devtools/check-forbidden-tokens.awk index 90d3a64f8e..8d64e99570 100755 --- a/devtools/check-forbidden-tokens.awk +++ b/devtools/check-forbidden-tokens.awk @@ -32,14 +32,11 @@ BEGIN { for (i in deny_expr) { forbidden_added = "^\\+.*" deny_expr[i]; forbidden_removed="^-.*" deny_expr[i]; - current = expressions[deny_expr[i]] if ($0 ~ forbidden_added) { - count = count + 1; - expressions[deny_expr[i]] = current + 1 + count = count + 1 } if ($0 ~ forbidden_removed) { - count = count - 1; - expressions[deny_expr[i]] = current - 1 + count = count - 1 } } } @@ -49,12 +46,13 @@ BEGIN { } } # switch to next file , check if the balance of add/remove -# of previous filehad new additions +# of previous file had new additions ($0 ~ "^\\+\\+\\+ b/") { in_file = 0; if (count > 0) { exit; } + count = 0 for (i in deny_folders) { re = "^\\+\\+\\+ b/" deny_folders[i]; if ($0 ~ re) { |
