Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

Re: checkpatch and kernel/sched.c

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


mingo at elte

Sep 30, 2007, 11:44 PM

Post #1 of 10 (1739 views)
Permalink
Re: checkpatch and kernel/sched.c

(lkml Cc:-ed - this might be of interest to others too)

* Andy Whitcroft <apw [at] shadowen> wrote:

> WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
> #411: FILE: home/apw/git/linux-2.6/kernel/sched.c:408:
> +EXPORT_SYMBOL_GPL(cpu_clock);

yes, this is a legit warning and i fix it every time i see it. (I cannot
fix this one now because mainline does not have an EXPORT_SYMBOL_GPL for
cpu_clock(), it's added in -mm? But i cannot find it in mm either. I'll
fix it once i find the patch :)

> WARNING: printk() should include KERN_ facility level
> #4838: FILE: home/apw/git/linux-2.6/kernel/sched.c:4835:
> + printk("%-13.13s %c", p->comm,
>
> WARNING: printk() should include KERN_ facility level
> #5622: FILE: home/apw/git/linux-2.6/kernel/sched.c:5619:
> + printk("\n");
>
> WARNING: printk() should include KERN_ facility level
> #5633: FILE: home/apw/git/linux-2.6/kernel/sched.c:5630:
> + printk("\n");
>
> WARNING: printk() should include KERN_ facility level
> #5640: FILE: home/apw/git/linux-2.6/kernel/sched.c:5637:
> + printk(" %s", str);
>
> These are actually only in debug code and so are unimportant, but
> technically they are wrong. This check is a very difficult one in the
> face of these constructs. But in this case I think it has got the
> report right.

this is actually a false positive - as the debug code constructs a
printk output _without_ \n. So the script should check whether there's
any \n in the printk string - if there is none, do not emit a warning.
(if you implement that then i think it can remain a warning and does not
need to move to CHECK.)

> At this point _if_ we took an error we would not have _DEBUG open and so
> a start would be required, otherwise not.
>
> printk(" %s", str);
>
> To be 100% correct I assume it would need to have a
> printk(KERN_DEBUG); after each of the KERN_ERR printk's.

i've fixed this in my tree. But i dont think checkpatch.pl notices this
level of bug - it just detects the missing KERN_ prefix in printk(),
right?

> WARNING: braces {} are not necessary for single statement blocks
> #5706: FILE: home/apw/git/linux-2.6/kernel/sched.c:5703:
> + if (parent->groups == parent->groups->next) {
> + pflags &= ~(SD_LOAD_BALANCE |
> + SD_BALANCE_NEWIDLE |
> + SD_BALANCE_FORK |
> + SD_BALANCE_EXEC |
> + SD_SHARE_CPUPOWER |
> + SD_SHARE_PKG_RESOURCES);
> + }
>
> Ok, this one is "correct" at least for the rules as I have them.
> Perhaps the message should not be emitted for very long blocks?

If a statement is not single-line, then braces _are_ fine. Where does
CodingStyle say that it's not fine?

> WARNING: no space between function name and open parenthesis '('
> #5768: FILE: home/apw/git/linux-2.6/kernel/sched.c:5765:
> +__setup ("isolcpus=", isolated_cpu_setup);
>
> Almost all other instances of __setup do not have a space, so I assume
> this is a reasonable report.

yes. I have just fixed it in my tree.

> WARNING: externs should be avoided in .c files
> #6545: FILE: home/apw/git/linux-2.6/kernel/sched.c:6542:
> + extern char __sched_text_start[], __sched_text_end[];
>
> That one ... dunno. This check is a difficult one. Should it be a
> CHECK?

no, this is a legitimate warning - externs in .c files should move into
the proper .h file. So i'd suggest to keep this a WARNING.

there are a few other valid warnings that checkpatch.pl emits: such as
the kfree one - i fixed that too in sched.c.

(Could you send me the v11-to-be version of checkpatch.pl so that i can
check the remaining issues?)

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


akpm at linux-foundation

Oct 1, 2007, 12:30 AM

Post #2 of 10 (1644 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

On Mon, 1 Oct 2007 08:44:48 +0200 Ingo Molnar <mingo [at] elte> wrote:

>
> (lkml Cc:-ed - this might be of interest to others too)
>
> * Andy Whitcroft <apw [at] shadowen> wrote:
>
> > WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
> > #411: FILE: home/apw/git/linux-2.6/kernel/sched.c:408:
> > +EXPORT_SYMBOL_GPL(cpu_clock);
>
> yes, this is a legit warning and i fix it every time i see it. (I cannot
> fix this one now because mainline does not have an EXPORT_SYMBOL_GPL for
> cpu_clock(), it's added in -mm? But i cannot find it in mm either. I'll
> fix it once i find the patch :)

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.23-rc8/2.6.23-rc8-mm2/broken-out/make-rcutorture-rng-use-temporal-entropy.patch

> > WARNING: printk() should include KERN_ facility level
> > #4838: FILE: home/apw/git/linux-2.6/kernel/sched.c:4835:
> > + printk("%-13.13s %c", p->comm,
> >
> > WARNING: printk() should include KERN_ facility level
> > #5622: FILE: home/apw/git/linux-2.6/kernel/sched.c:5619:
> > + printk("\n");
> >
> > WARNING: printk() should include KERN_ facility level
> > #5633: FILE: home/apw/git/linux-2.6/kernel/sched.c:5630:
> > + printk("\n");
> >
> > WARNING: printk() should include KERN_ facility level
> > #5640: FILE: home/apw/git/linux-2.6/kernel/sched.c:5637:
> > + printk(" %s", str);
> >
> > These are actually only in debug code and so are unimportant, but
> > technically they are wrong. This check is a very difficult one in the
> > face of these constructs. But in this case I think it has got the
> > report right.
>
> this is actually a false positive - as the debug code constructs a
> printk output _without_ \n. So the script should check whether there's
> any \n in the printk string - if there is none, do not emit a warning.
> (if you implement that then i think it can remain a warning and does not
> need to move to CHECK.)

Yeah, it does that sometimes. I don't think it's fixable within the scope
of checkpatch. It needs to check whether some preceding printk which might
not even be in the patch has a \n:

printk(KERN_ERR "foo");
<100 lines of whatever>
+ printk("bar\n");

we're screwed...

> > At this point _if_ we took an error we would not have _DEBUG open and so
> > a start would be required, otherwise not.
> >
> > printk(" %s", str);
> >
> > To be 100% correct I assume it would need to have a
> > printk(KERN_DEBUG); after each of the KERN_ERR printk's.
>
> i've fixed this in my tree. But i dont think checkpatch.pl notices this
> level of bug - it just detects the missing KERN_ prefix in printk(),
> right?
>
> > WARNING: braces {} are not necessary for single statement blocks
> > #5706: FILE: home/apw/git/linux-2.6/kernel/sched.c:5703:
> > + if (parent->groups == parent->groups->next) {
> > + pflags &= ~(SD_LOAD_BALANCE |
> > + SD_BALANCE_NEWIDLE |
> > + SD_BALANCE_FORK |
> > + SD_BALANCE_EXEC |
> > + SD_SHARE_CPUPOWER |
> > + SD_SHARE_PKG_RESOURCES);
> > + }
> >
> > Ok, this one is "correct" at least for the rules as I have them.
> > Perhaps the message should not be emitted for very long blocks?
>
> If a statement is not single-line, then braces _are_ fine. Where does
> CodingStyle say that it's not fine?

I'd disagree with checkpatch there. Again, it might be hard to fix. Wanna
rename it to checkpatch-and-suggest-stuff-to-think-about.pl?

> > WARNING: no space between function name and open parenthesis '('
> > #5768: FILE: home/apw/git/linux-2.6/kernel/sched.c:5765:
> > +__setup ("isolcpus=", isolated_cpu_setup);
> >
> > Almost all other instances of __setup do not have a space, so I assume
> > this is a reasonable report.
>
> yes. I have just fixed it in my tree.
>
> > WARNING: externs should be avoided in .c files
> > #6545: FILE: home/apw/git/linux-2.6/kernel/sched.c:6542:
> > + extern char __sched_text_start[], __sched_text_end[];
> >
> > That one ... dunno. This check is a difficult one. Should it be a
> > CHECK?
>
> no, this is a legitimate warning - externs in .c files should move into
> the proper .h file. So i'd suggest to keep this a WARNING.

Yes. When the symbol is defined in .S or vmlinux.lds we have
traditionally declared it in .c.

But why? It _is_ a global symbol. We might as well declare it in .h.
That's consistent, and prevents duplicated declarations from popping up
later on.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


akpm at linux-foundation

Oct 1, 2007, 12:39 AM

Post #3 of 10 (1649 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

On Mon, 01 Oct 2007 09:48:25 +0200 Avi Kivity <avi [at] qumranet> wrote:

> Andrew Morton wrote:
> >> this is actually a false positive - as the debug code constructs a
> >> printk output _without_ \n. So the script should check whether there's
> >> any \n in the printk string - if there is none, do not emit a warning.
> >> (if you implement that then i think it can remain a warning and does not
> >> need to move to CHECK.)
> >>
> >
> > Yeah, it does that sometimes. I don't think it's fixable within the scope
> > of checkpatch. It needs to check whether some preceding printk which might
> > not even be in the patch has a \n:
> >
> > printk(KERN_ERR "foo");
> > <100 lines of whatever>
> > + printk("bar\n");
> >
> > we're screwed...
> >
> >
>
> Isn't that broken on SMP (or with preemption) anyway?

Yep. Or with interrupts...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


avi at qumranet

Oct 1, 2007, 12:48 AM

Post #4 of 10 (1646 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

Andrew Morton wrote:
>> this is actually a false positive - as the debug code constructs a
>> printk output _without_ \n. So the script should check whether there's
>> any \n in the printk string - if there is none, do not emit a warning.
>> (if you implement that then i think it can remain a warning and does not
>> need to move to CHECK.)
>>
>
> Yeah, it does that sometimes. I don't think it's fixable within the scope
> of checkpatch. It needs to check whether some preceding printk which might
> not even be in the patch has a \n:
>
> printk(KERN_ERR "foo");
> <100 lines of whatever>
> + printk("bar\n");
>
> we're screwed...
>
>

Isn't that broken on SMP (or with preemption) anyway?

--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


sam at ravnborg

Oct 1, 2007, 12:50 AM

Post #5 of 10 (1639 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

> >
> > > WARNING: externs should be avoided in .c files
> > > #6545: FILE: home/apw/git/linux-2.6/kernel/sched.c:6542:
> > > + extern char __sched_text_start[], __sched_text_end[];
> > >
> > > That one ... dunno. This check is a difficult one. Should it be a
> > > CHECK?
> >
> > no, this is a legitimate warning - externs in .c files should move into
> > the proper .h file. So i'd suggest to keep this a WARNING.
>
> Yes. When the symbol is defined in .S or vmlinux.lds we have
> traditionally declared it in .c.
>
> But why? It _is_ a global symbol. We might as well declare it in .h.
> That's consistent, and prevents duplicated declarations from popping up
> later on.
It would be nice to collect all linker symbol externs in one place..
asm-$(ARCH)/???.h

We could even auto-generate it but thats not worth it I think.

Sam
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


mingo at elte

Oct 1, 2007, 3:37 AM

Post #6 of 10 (1635 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

* Andrew Morton <akpm [at] linux-foundation> wrote:

> > > WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
> > > #411: FILE: home/apw/git/linux-2.6/kernel/sched.c:408:
> > > +EXPORT_SYMBOL_GPL(cpu_clock);
> >
> > yes, this is a legit warning and i fix it every time i see it. (I
> > cannot fix this one now because mainline does not have an
> > EXPORT_SYMBOL_GPL for cpu_clock(), it's added in -mm? But i cannot
> > find it in mm either. I'll fix it once i find the patch :)
>
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.23-rc8/2.6.23-rc8-mm2/broken-out/make-rcutorture-rng-use-temporal-entropy.patch

ok - i have picked up the sched.c bit for sched-devel.git. (see below)

Ingo

---------------->
Subject: sched: export cpu_clock()
From: "Paul E. McKenney" <paulmck [at] linux>

export cpu_clock() - the preferred API instead of sched_clock().

Signed-off-by: Paul E. McKenney <paulmck [at] linux>
Signed-off-by: Andrew Morton <akpm [at] linux-foundation>
Signed-off-by: Ingo Molnar <mingo [at] elte>
---
kernel/sched.c | 1 +
1 file changed, 1 insertion(+)

Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c
+++ linux/kernel/sched.c
@@ -469,6 +469,7 @@ unsigned long long cpu_clock(int cpu)

return now;
}
+EXPORT_SYMBOL_GPL(cpu_clock);

#ifndef prepare_arch_switch
# define prepare_arch_switch(next) do { } while (0)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


mingo at elte

Oct 1, 2007, 3:39 AM

Post #7 of 10 (1644 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

* Andrew Morton <akpm [at] linux-foundation> wrote:

> On Mon, 01 Oct 2007 09:48:25 +0200 Avi Kivity <avi [at] qumranet> wrote:
>
> > Andrew Morton wrote:
> > >> this is actually a false positive - as the debug code constructs a
> > >> printk output _without_ \n. So the script should check whether there's
> > >> any \n in the printk string - if there is none, do not emit a warning.
> > >> (if you implement that then i think it can remain a warning and does not
> > >> need to move to CHECK.)
> > >>
> > >
> > > Yeah, it does that sometimes. I don't think it's fixable within the scope
> > > of checkpatch. It needs to check whether some preceding printk which might
> > > not even be in the patch has a \n:
> > >
> > > printk(KERN_ERR "foo");
> > > <100 lines of whatever>
> > > + printk("bar\n");
> > >
> > > we're screwed...
> > >
> > >
> >
> > Isn't that broken on SMP (or with preemption) anyway?
>
> Yep. Or with interrupts...

not if it's a boot-time only debug check before SMP bringup. (as it is
in sched.c) We could make this intention explicit via a simple
raw_printk() wrapper to printk, which could be used without KERN_.

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


mingo at elte

Oct 1, 2007, 3:44 AM

Post #8 of 10 (1634 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

* Andrew Morton <akpm [at] linux-foundation> wrote:

> > > WARNING: braces {} are not necessary for single statement blocks
> > > #5706: FILE: home/apw/git/linux-2.6/kernel/sched.c:5703:
> > > + if (parent->groups == parent->groups->next) {
> > > + pflags &= ~(SD_LOAD_BALANCE |
> > > + SD_BALANCE_NEWIDLE |
> > > + SD_BALANCE_FORK |
> > > + SD_BALANCE_EXEC |
> > > + SD_SHARE_CPUPOWER |
> > > + SD_SHARE_PKG_RESOURCES);
> > > + }
> > >
> > > Ok, this one is "correct" at least for the rules as I have them.
> > > Perhaps the message should not be emitted for very long blocks?
> >
> > If a statement is not single-line, then braces _are_ fine. Where does
> > CodingStyle say that it's not fine?
>
> I'd disagree with checkpatch there. Again, it might be hard to fix.
> Wanna rename it to checkpatch-and-suggest-stuff-to-think-about.pl?

i think checkpatch.pl is quite close to its most useful purpose and
role: that of a reliable tool that i can use in an automated fashion
too, with only very rare false positive - and not the current 50%-80%
false positives rate. (And i'm fighting hard for Andy to realize the
true scope and purpose of this script ;-)

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


apw at shadowen

Oct 1, 2007, 5:34 AM

Post #9 of 10 (1629 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

On Mon, Oct 01, 2007 at 12:30:07AM -0700, Andrew Morton wrote:
> On Mon, 1 Oct 2007 08:44:48 +0200 Ingo Molnar <mingo [at] elte> wrote:
>
> >
> > (lkml Cc:-ed - this might be of interest to others too)
> >
> > * Andy Whitcroft <apw [at] shadowen> wrote:
> >
> > > WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
> > > #411: FILE: home/apw/git/linux-2.6/kernel/sched.c:408:
> > > +EXPORT_SYMBOL_GPL(cpu_clock);
> >
> > yes, this is a legit warning and i fix it every time i see it. (I cannot
> > fix this one now because mainline does not have an EXPORT_SYMBOL_GPL for
> > cpu_clock(), it's added in -mm? But i cannot find it in mm either. I'll
> > fix it once i find the patch :)
>
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.23-rc8/2.6.23-rc8-mm2/broken-out/make-rcutorture-rng-use-temporal-entropy.patch
>
> > > WARNING: printk() should include KERN_ facility level
> > > #4838: FILE: home/apw/git/linux-2.6/kernel/sched.c:4835:
> > > + printk("%-13.13s %c", p->comm,
> > >
> > > WARNING: printk() should include KERN_ facility level
> > > #5622: FILE: home/apw/git/linux-2.6/kernel/sched.c:5619:
> > > + printk("\n");
> > >
> > > WARNING: printk() should include KERN_ facility level
> > > #5633: FILE: home/apw/git/linux-2.6/kernel/sched.c:5630:
> > > + printk("\n");
> > >
> > > WARNING: printk() should include KERN_ facility level
> > > #5640: FILE: home/apw/git/linux-2.6/kernel/sched.c:5637:
> > > + printk(" %s", str);
> > >
> > > These are actually only in debug code and so are unimportant, but
> > > technically they are wrong. This check is a very difficult one in the
> > > face of these constructs. But in this case I think it has got the
> > > report right.
> >
> > this is actually a false positive - as the debug code constructs a
> > printk output _without_ \n. So the script should check whether there's
> > any \n in the printk string - if there is none, do not emit a warning.
> > (if you implement that then i think it can remain a warning and does not
> > need to move to CHECK.)
>
> Yeah, it does that sometimes. I don't think it's fixable within the scope
> of checkpatch. It needs to check whether some preceding printk which might
> not even be in the patch has a \n:
>
> printk(KERN_ERR "foo");
> <100 lines of whatever>
> + printk("bar\n");
>
> we're screwed...

Actually checkpatch does take that into account. If the printk has no
precceding printk ending in a newline, within the scope of the diff
then the warning is suppressed.

However, in this mm/sched.c case there are paths through the code which
do violate the "every line starts with KERN_" mantra. Now checkpatch is
actually not clever enough to spot that these are conditional, but in
this case there is an error. Its not important as it is debug. But I
contend there is an erorr. When an error is thrown we close the
unfinished line, emit a line at KERN_ERR and then continue to emit the
previous line without switching to KERN_DEBUG again.

> > > At this point _if_ we took an error we would not have _DEBUG open and so
> > > a start would be required, otherwise not.
> > >
> > > printk(" %s", str);
> > >
> > > To be 100% correct I assume it would need to have a
> > > printk(KERN_DEBUG); after each of the KERN_ERR printk's.
> >
> > i've fixed this in my tree. But i dont think checkpatch.pl notices this
> > level of bug - it just detects the missing KERN_ prefix in printk(),
> > right?
> >
> > > WARNING: braces {} are not necessary for single statement blocks
> > > #5706: FILE: home/apw/git/linux-2.6/kernel/sched.c:5703:
> > > + if (parent->groups == parent->groups->next) {
> > > + pflags &= ~(SD_LOAD_BALANCE |
> > > + SD_BALANCE_NEWIDLE |
> > > + SD_BALANCE_FORK |
> > > + SD_BALANCE_EXEC |
> > > + SD_SHARE_CPUPOWER |
> > > + SD_SHARE_PKG_RESOURCES);
> > > + }
> > >
> > > Ok, this one is "correct" at least for the rules as I have them.
> > > Perhaps the message should not be emitted for very long blocks?
> >
> > If a statement is not single-line, then braces _are_ fine. Where does
> > CodingStyle say that it's not fine?
>
> I'd disagree with checkpatch there. Again, it might be hard to fix. Wanna
> rename it to checkpatch-and-suggest-stuff-to-think-about.pl?

Checkpatch is capable of making the determination as at the time we
emit the warning we have all of the block in question. We already allow
a number of other exceptions. Just I think what I think the "rule" is
and its actuallity are not the same.

Are we saying the rule is "braces are not required for single _line_
blocks?

> > > WARNING: no space between function name and open parenthesis '('
> > > #5768: FILE: home/apw/git/linux-2.6/kernel/sched.c:5765:
> > > +__setup ("isolcpus=", isolated_cpu_setup);
> > >
> > > Almost all other instances of __setup do not have a space, so I assume
> > > this is a reasonable report.
> >
> > yes. I have just fixed it in my tree.
> >
> > > WARNING: externs should be avoided in .c files
> > > #6545: FILE: home/apw/git/linux-2.6/kernel/sched.c:6542:
> > > + extern char __sched_text_start[], __sched_text_end[];
> > >
> > > That one ... dunno. This check is a difficult one. Should it be a
> > > CHECK?
> >
> > no, this is a legitimate warning - externs in .c files should move into
> > the proper .h file. So i'd suggest to keep this a WARNING.
>
> Yes. When the symbol is defined in .S or vmlinux.lds we have
> traditionally declared it in .c.
>
> But why? It _is_ a global symbol. We might as well declare it in .h.
> That's consistent, and prevents duplicated declarations from popping up
> later on.

-apw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


w at 1wt

Oct 1, 2007, 9:34 PM

Post #10 of 10 (1636 views)
Permalink
Re: checkpatch and kernel/sched.c [In reply to]

On Mon, Oct 01, 2007 at 12:30:07AM -0700, Andrew Morton wrote:
> On Mon, 1 Oct 2007 08:44:48 +0200 Ingo Molnar <mingo [at] elte> wrote:
>
> >
> > (lkml Cc:-ed - this might be of interest to others too)
> >
> > * Andy Whitcroft <apw [at] shadowen> wrote:
> >
> > > WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
> > > #411: FILE: home/apw/git/linux-2.6/kernel/sched.c:408:
> > > +EXPORT_SYMBOL_GPL(cpu_clock);
> >
> > yes, this is a legit warning and i fix it every time i see it. (I cannot
> > fix this one now because mainline does not have an EXPORT_SYMBOL_GPL for
> > cpu_clock(), it's added in -mm? But i cannot find it in mm either. I'll
> > fix it once i find the patch :)
>
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.23-rc8/2.6.23-rc8-mm2/broken-out/make-rcutorture-rng-use-temporal-entropy.patch
>
> > > WARNING: printk() should include KERN_ facility level
> > > #4838: FILE: home/apw/git/linux-2.6/kernel/sched.c:4835:
> > > + printk("%-13.13s %c", p->comm,
> > >
> > > WARNING: printk() should include KERN_ facility level
> > > #5622: FILE: home/apw/git/linux-2.6/kernel/sched.c:5619:
> > > + printk("\n");
> > >
> > > WARNING: printk() should include KERN_ facility level
> > > #5633: FILE: home/apw/git/linux-2.6/kernel/sched.c:5630:
> > > + printk("\n");
> > >
> > > WARNING: printk() should include KERN_ facility level
> > > #5640: FILE: home/apw/git/linux-2.6/kernel/sched.c:5637:
> > > + printk(" %s", str);
> > >
> > > These are actually only in debug code and so are unimportant, but
> > > technically they are wrong. This check is a very difficult one in the
> > > face of these constructs. But in this case I think it has got the
> > > report right.
> >
> > this is actually a false positive - as the debug code constructs a
> > printk output _without_ \n. So the script should check whether there's
> > any \n in the printk string - if there is none, do not emit a warning.
> > (if you implement that then i think it can remain a warning and does not
> > need to move to CHECK.)
>
> Yeah, it does that sometimes. I don't think it's fixable within the scope
> of checkpatch. It needs to check whether some preceding printk which might
> not even be in the patch has a \n:
>
> printk(KERN_ERR "foo");
> <100 lines of whatever>
> + printk("bar\n");
>
> we're screwed...

Well, I think that we could do something like this :

#define KERN_CONT ""
...
printk(KERN_ERR "foo");
<100 lines of whatever>
printk(KERN_CONT "bar\n");

It would indicate the author's *intent* which is to continue a line which
has already been started. It would both permit us to remove false positives
from automated scripts, and to read the code more easily. And this is not a
big constaint for the author, given that such constructs are quite rare.

Regards,
Willy

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.