* [PATCH RESEND v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning
[not found] <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcas5p1.samsung.com>
@ 2022-02-02 7:14 ` Maninder Singh
2022-02-02 9:16 ` Joe Perches
[not found] ` <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcms5p2>
0 siblings, 2 replies; 5+ messages in thread
From: Maninder Singh @ 2022-02-02 7:14 UTC (permalink / raw)
To: apw, joe, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, Maninder Singh, Vaneet Narang
printk_deferred and printk_deferred_once requires LOGLEVEL in argument,
but checkpatch.pl reports it as warning:
WARNING: Possible unnecessary KERN_ALERT
printk_deferred(KERN_ALERT "checking deferred\n");
As suggested by Andy, made 2 functions from logFunction.
1. logFunction: with all checks
2. logFunctionCore: without printk(?:_ratelimited|_once|_deferred) checking
and call logFunctionCore instead of logFunction for checking of loglevel,
which will exclude checking of printk(?:_ratelimited|_once|_deferred).
This way, there is no need to maintain same stanza at places for removing
printk flavours.
Co-developed-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
---
v1 -> v2: made 2 functions to remove _deferred and _deferred_once
as suggested by Andy Whitcroft.
scripts/checkpatch.pl | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b01c36a15d9d..a6fa0c7360be 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -584,8 +584,7 @@ our $typeTypedefs = qr{(?x:
our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};
-our $logFunctions = qr{(?x:
- printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
+our $logFunctionsCore = qr{(?x:
(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
TP_printk|
WARN(?:_RATELIMIT|_ONCE|)|
@@ -594,6 +593,11 @@ our $logFunctions = qr{(?x:
seq_vprintf|seq_printf|seq_puts
)};
+our $logFunctions = qr{(?x:
+ printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
+ $logFunctionsCore
+)};
+
our $allocFunctions = qr{(?x:
(?:(?:devm_)?
(?:kv|k|v)[czm]alloc(?:_array)?(?:_node)? |
@@ -6298,8 +6302,7 @@ sub process {
}
# check for logging functions with KERN_<LEVEL>
- if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ &&
- $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
+ if ($line =~ /\b$logFunctionsCore\s*\(.*\b(KERN_[A-Z]+)\b/) {
my $level = $1;
if (WARN("UNNECESSARY_KERN_LEVEL",
"Possible unnecessary $level\n" . $herecurr) &&
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning
2022-02-02 7:14 ` [PATCH RESEND v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning Maninder Singh
@ 2022-02-02 9:16 ` Joe Perches
[not found] ` <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcms5p2>
1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2022-02-02 9:16 UTC (permalink / raw)
To: Maninder Singh, apw, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, Vaneet Narang
On Wed, 2022-02-02 at 12:44 +0530, Maninder Singh wrote:
> printk_deferred and printk_deferred_once requires LOGLEVEL in argument,
> but checkpatch.pl reports it as warning:
When did that occur? Please reference the specific commit.
When printk_sched (now printk_deferred) was created it did not
allow KERN_<LEVEL>.
see commit 3ccf3e830615 ("printk/sched: Introduce special printk_sched() for those awkward moments")
There are many existing printk_deferred uses without KERN_<LEVEL>.
> WARNING: Possible unnecessary KERN_ALERT
> printk_deferred(KERN_ALERT "checking deferred\n");
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH RESEND v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning
[not found] ` <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcms5p2>
@ 2022-02-02 9:52 ` Maninder Singh
2022-02-02 9:59 ` Joe Perches
[not found] ` <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcms5p5>
0 siblings, 2 replies; 5+ messages in thread
From: Maninder Singh @ 2022-02-02 9:52 UTC (permalink / raw)
To: Joe Perches, apw, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, Vaneet Narang
Hi,
>> printk_deferred and printk_deferred_once requires LOGLEVEL in argument,
>> but checkpatch.pl reports it as warning:
> When did that occur? Please reference the specific commit.
> When printk_sched (now printk_deferred) was created it did not
> allow KERN_<LEVEL>.
> see commit 3ccf3e830615 ("printk/sched: Introduce special printk_sched() for those awkward moments")
I think with below commit:
98e35f5894cf208084688ec0c7bb7b713efc997f (printk: git rid of [sched_delayed] message for printk_deferred)
earlier it was passing hardcoded KERN_WARNING to all printk_deferred messages, but now it switched
to normal printk behavior.
- if (in_sched)
- text_len = scnprintf(text, sizeof(textbuf),
- KERN_WARNING "[sched_delayed] ");
-
- text_len += vscnprintf(text + text_len,
- sizeof(textbuf) - text_len, fmt, args);
+ text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
I did not search that earlier, because we were fixing some issue in our local module code with printk_deferred
and then checkatch reported the issues, so thought of fixing it, becaue without level
pritk_deferred messages was shifted to default loglevel as done by normal printk.
So I thought it was designed to pass loglevel from starting stage and checjpatch reports falsely.
but seems checkpatch needs to fixed with that commit itself, because earlier it was not required to pass loglevel.
> There are many existing printk_deferred uses without KERN_<LEVEL>.
Either that needs to be fixed after that commit(98e35f5894cf) or their purpose is to
use KERN_DEFAULT log level i think.
Thanks,
Maninder Singh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning
2022-02-02 9:52 ` Maninder Singh
@ 2022-02-02 9:59 ` Joe Perches
[not found] ` <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcms5p5>
1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2022-02-02 9:59 UTC (permalink / raw)
To: maninder1.s, apw, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, Vaneet Narang
On Wed, 2022-02-02 at 15:22 +0530, Maninder Singh wrote:
> Hi,
>
>
> > > printk_deferred and printk_deferred_once requires LOGLEVEL in argument,
> > > but checkpatch.pl reports it as warning:
>
> > When did that occur? Please reference the specific commit.
> > When printk_sched (now printk_deferred) was created it did not
> > allow KERN_<LEVEL>.
>
> > see commit 3ccf3e830615 ("printk/sched: Introduce special printk_sched() for those awkward moments")
>
> I think with below commit:
>
> 98e35f5894cf208084688ec0c7bb7b713efc997f (printk: git rid of [sched_delayed] message for printk_deferred)
>
> earlier it was passing hardcoded KERN_WARNING to all printk_deferred messages, but now it switched
> to normal printk behavior.
>
> - if (in_sched)
> - text_len = scnprintf(text, sizeof(textbuf),
> - KERN_WARNING "[sched_delayed] ");
> -
> - text_len += vscnprintf(text + text_len,
> - sizeof(textbuf) - text_len, fmt, args);
> + text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
>
>
> I did not search that earlier, because we were fixing some issue in our local module code with printk_deferred
> and then checkatch reported the issues, so thought of fixing it, becaue without level
> pritk_deferred messages was shifted to default loglevel as done by normal printk.
>
> So I thought it was designed to pass loglevel from starting stage and checjpatch reports falsely.
> but seems checkpatch needs to fixed with that commit itself, because earlier it was not required to pass loglevel.
Most of that should be in the commit message.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH RESEND v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning
[not found] ` <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcms5p5>
@ 2022-02-02 10:08 ` Maninder Singh
0 siblings, 0 replies; 5+ messages in thread
From: Maninder Singh @ 2022-02-02 10:08 UTC (permalink / raw)
To: Joe Perches, apw, dwaipayanray1, lukas.bulwahn
Cc: linux-kernel, Vaneet Narang
[-- Attachment #1: Type: text/plain, Size: 1836 bytes --]
Hi,
> > > > printk_deferred and printk_deferred_once requires LOGLEVEL in argument,
> > > > but checkpatch.pl reports it as warning:
> >
> > > When did that occur? Please reference the specific commit.
> > > When printk_sched (now printk_deferred) was created it did not
> > > allow KERN_<LEVEL>.
> >
> > > see commit 3ccf3e830615 ("printk/sched: Introduce special printk_sched() for those awkward moments")
> >
> > I think with below commit:
> >
> > 98e35f5894cf208084688ec0c7bb7b713efc997f (printk: git rid of [sched_delayed] message for printk_deferred)
> >
> > earlier it was passing hardcoded KERN_WARNING to all printk_deferred messages, but now it switched
> > to normal printk behavior.
> >
> > - if (in_sched)
> > - text_len = scnprintf(text, sizeof(textbuf),
> > - KERN_WARNING "[sched_delayed] ");
> > -
> > - text_len += vscnprintf(text + text_len,
> > - sizeof(textbuf) - text_len, fmt, args);
> > + text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
> >
> >
> > I did not search that earlier, because we were fixing some issue in our local module code with printk_deferred
> > and then checkatch reported the issues, so thought of fixing it, becaue without level
> > pritk_deferred messages was shifted to default loglevel as done by normal printk.
> >
> > So I thought it was designed to pass loglevel from starting stage and checjpatch reports falsely.
> > but seems checkpatch needs to fixed with that commit itself, because earlier it was not required to pass loglevel.
>
> Most of that should be in the commit message.
Yes, Initially I thought it's added in checkpatch by mistake,
I Should have checked history of printk_deferred also.
I will send new version with updated comit message.
Thanks
[-- Attachment #2: rcptInfo.txt --]
[-- Type: application/octet-stream, Size: 1313 bytes --]
=================================================================================================================================
Subject : Re: [PATCH RESEND v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning
From : null
Sent Date : 2022-02-02 15:29 GMT+5:30
=================================================================================================================================
Name Type Job Title Dept. Company
=================================================================================================================================
Maninder Singh TO Staff Engineer System S/W Group /SRI-Delhi Samsung Electronics
apw@canonical.com TO
dwaipayanray1@gmail.com TO
lukas.bulwahn@gmail.com TO
linux-kernel@vger.kernel.org CC
Vaneet Narang CC Associate Architect System S/W Group /SRI-Delhi Samsung Electronics
=================================================================================================================================
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-02 10:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcas5p1.samsung.com>
2022-02-02 7:14 ` [PATCH RESEND v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning Maninder Singh
2022-02-02 9:16 ` Joe Perches
[not found] ` <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcms5p2>
2022-02-02 9:52 ` Maninder Singh
2022-02-02 9:59 ` Joe Perches
[not found] ` <CGME20220202071414epcas5p1d329ae4f76c281c1f8f7f07bfb36a919@epcms5p5>
2022-02-02 10:08 ` Maninder Singh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.