Hi Andy and Joe,
Checkpatch is complaining when code adds new trace events macros:
sarah@xanatos:~/git/kernels/xhci$ git am -s ~/Maildir.fetchmail/.to-apply
Applying: xhci: add traces for debug messages in xhci_address_device()
ERROR: Macros with complex values should be enclosed in parenthesis
#86: FILE: drivers/usb/host/xhci-trace.h:15:
+#define TRACE_SYSTEM xhci-hcd
ERROR: Macros with complex values should be enclosed in parenthesis
#115: FILE: drivers/usb/host/xhci-trace.h:44:
+#define TRACE_INCLUDE_PATH .
ERROR: Macros with complex values should be enclosed in parenthesis
#118: FILE: drivers/usb/host/xhci-trace.h:47:
+#define TRACE_INCLUDE_FILE xhci-trace
total: 3 errors, 0 warnings, 169 lines checked
The macros have to be defined that way for trace events to work.
Can you fix checkpatch not to complain about trace event macros?
Thanks,
Sarah Sharp
On Mon, 2013-07-29 at 12:52 -0700, Sarah Sharp wrote:
> Hi Andy and Joe,
Hi Sarah.
> Checkpatch is complaining when code adds new trace events macros:
>
> sarah@xanatos:~/git/kernels/xhci$ git am -s ~/Maildir.fetchmail/.to-apply
> Applying: xhci: add traces for debug messages in xhci_address_device()
> ERROR: Macros with complex values should be enclosed in parenthesis
> #86: FILE: drivers/usb/host/xhci-trace.h:15:
> +#define TRACE_SYSTEM xhci-hcd
<shrug>
I think these are suboptimal as the files should use
underscores rather than dashes.
checkpatch sees this as a subtraction which really
should have parentheses.
> ERROR: Macros with complex values should be enclosed in parenthesis
> #115: FILE: drivers/usb/host/xhci-trace.h:44:
> +#define TRACE_INCLUDE_PATH .
>
> ERROR: Macros with complex values should be enclosed in parenthesis
> #118: FILE: drivers/usb/host/xhci-trace.h:47:
> +#define TRACE_INCLUDE_FILE xhci-trace
Don't expect to checkpatch to be perfect.
It's not.
It's a stupid little tool good for some things
and good for highlighting areas that might need
another look.
Use your judgment about everything it spews.
On Mon, Jul 29, 2013 at 01:02:44PM -0700, Joe Perches wrote:
> On Mon, 2013-07-29 at 12:52 -0700, Sarah Sharp wrote:
> > Hi Andy and Joe,
>
> Hi Sarah.
>
> > Checkpatch is complaining when code adds new trace events macros:
> >
> > sarah@xanatos:~/git/kernels/xhci$ git am -s ~/Maildir.fetchmail/.to-apply
> > Applying: xhci: add traces for debug messages in xhci_address_device()
> > ERROR: Macros with complex values should be enclosed in parenthesis
> > #86: FILE: drivers/usb/host/xhci-trace.h:15:
> > +#define TRACE_SYSTEM xhci-hcd
>
> <shrug>
>
> I think these are suboptimal as the files should use
> underscores rather than dashes.
The norm in the USB subsystem is to use dashes in filenames. I think
it's suboptimal to have to use the shift key at all when typing
filenames. We have different preferences here, and different reasons
for those preferences, but there is no "should" here, just opinions.
> checkpatch sees this as a subtraction which really
> should have parentheses.
I see.
> > ERROR: Macros with complex values should be enclosed in parenthesis
> > #115: FILE: drivers/usb/host/xhci-trace.h:44:
> > +#define TRACE_INCLUDE_PATH .
> >
> > ERROR: Macros with complex values should be enclosed in parenthesis
> > #118: FILE: drivers/usb/host/xhci-trace.h:47:
> > +#define TRACE_INCLUDE_FILE xhci-trace
>
> Don't expect to checkpatch to be perfect.
>
> It's not.
>
> It's a stupid little tool good for some things
> and good for highlighting areas that might need
> another look.
>
> Use your judgment about everything it spews.
If checkpatch spews warnings and errors, that makes it basically
useless as a git pre-commit hook.
Sigh, I suppose I'll just add a '|| true' to the end of the line and
deal with it.
Sarah Sharp
On Mon, 2013-07-29 at 14:23 -0700, Sarah Sharp wrote:
> On Mon, Jul 29, 2013 at 01:02:44PM -0700, Joe Perches wrote:
> > On Mon, 2013-07-29 at 12:52 -0700, Sarah Sharp wrote:
[]
> > > sarah@xanatos:~/git/kernels/xhci$ git am -s ~/Maildir.fetchmail/.to-apply
> > > Applying: xhci: add traces for debug messages in xhci_address_device()
> > > ERROR: Macros with complex values should be enclosed in parenthesis
> > > #86: FILE: drivers/usb/host/xhci-trace.h:15:
> > > +#define TRACE_SYSTEM xhci-hcd
> >
> > <shrug>
> >
> > I think these are suboptimal as the files should use
> > underscores rather than dashes.
It's ~3:2 in favor of _ in the tree.
$ git ls-files | awk -F"/" '{print $NF;}' | grep "-" | wc -l
8078
$ git ls-files | awk -F"/" '{print $NF;}' | grep "_" | wc -l
12577
closer to 1:1 if you include all the directory names too.
$ git ls-files | grep "-" | wc -l
11821
$ git ls-files | grep "_" | wc -l
13005
> The norm in the USB subsystem is to use dashes in filenames.
Not really.
$ git ls-files drivers/usb | awk -F"/" '{print $NF;}' | grep "-" | wc -l
168
$ git ls-files drivers/usb | awk -F"/" '{print $NF;}' | grep "_" | wc -l
177
> there is no "should" here, just opinions.
Given the "I think", we agree!
On 2013/7/30 3:52, Sarah Sharp wrote:
> Hi Andy and Joe,
>
> Checkpatch is complaining when code adds new trace events macros:
>
> sarah@xanatos:~/git/kernels/xhci$ git am -s ~/Maildir.fetchmail/.to-apply
> Applying: xhci: add traces for debug messages in xhci_address_device()
> ERROR: Macros with complex values should be enclosed in parenthesis
> #86: FILE: drivers/usb/host/xhci-trace.h:15:
> +#define TRACE_SYSTEM xhci-hcd
>
> ERROR: Macros with complex values should be enclosed in parenthesis
> #115: FILE: drivers/usb/host/xhci-trace.h:44:
> +#define TRACE_INCLUDE_PATH .
>
> ERROR: Macros with complex values should be enclosed in parenthesis
> #118: FILE: drivers/usb/host/xhci-trace.h:47:
> +#define TRACE_INCLUDE_FILE xhci-trace
>
> total: 3 errors, 0 warnings, 169 lines checked
>
>
> The macros have to be defined that way for trace events to work.
yeah, that's true, and we always just ignore chechpatch complaints
when it comes to TRACE_EVENT macros.
> Can you fix checkpatch not to complain about trace event macros?
>
On Tue, 2013-07-30 at 09:30 +0800, Li Zefan wrote:
> On 2013/7/30 3:52, Sarah Sharp wrote:
> > Hi Andy and Joe,
> >
> > Checkpatch is complaining when code adds new trace events macros:
> >
> > sarah@xanatos:~/git/kernels/xhci$ git am -s ~/Maildir.fetchmail/.to-apply
> > Applying: xhci: add traces for debug messages in xhci_address_device()
> > ERROR: Macros with complex values should be enclosed in parenthesis
> > #86: FILE: drivers/usb/host/xhci-trace.h:15:
> > +#define TRACE_SYSTEM xhci-hcd
> >
> > ERROR: Macros with complex values should be enclosed in parenthesis
> > #115: FILE: drivers/usb/host/xhci-trace.h:44:
> > +#define TRACE_INCLUDE_PATH .
> >
> > ERROR: Macros with complex values should be enclosed in parenthesis
> > #118: FILE: drivers/usb/host/xhci-trace.h:47:
> > +#define TRACE_INCLUDE_FILE xhci-trace
> >
> > total: 3 errors, 0 warnings, 169 lines checked
> >
> >
> > The macros have to be defined that way for trace events to work.
>
> yeah, that's true, and we always just ignore chechpatch complaints
> when it comes to TRACE_EVENT macros.
>
> > Can you fix checkpatch not to complain about trace event macros?
> >
So what are these TRACE_<FOO> defines that need
excluding from the "complex values" check?
Anything other than
TRACE_SYSTEM
TRACE_INCLUDE_FILE
TRACE_INCLUDE_PATH
?
samples/trace_events/trace-events-sample.h
only has those 3.
On 2013/7/30 9:58, Joe Perches wrote:
> On Tue, 2013-07-30 at 09:30 +0800, Li Zefan wrote:
>> On 2013/7/30 3:52, Sarah Sharp wrote:
>>> Hi Andy and Joe,
>>>
>>> Checkpatch is complaining when code adds new trace events macros:
>>>
>>> sarah@xanatos:~/git/kernels/xhci$ git am -s ~/Maildir.fetchmail/.to-apply
>>> Applying: xhci: add traces for debug messages in xhci_address_device()
>>> ERROR: Macros with complex values should be enclosed in parenthesis
>>> #86: FILE: drivers/usb/host/xhci-trace.h:15:
>>> +#define TRACE_SYSTEM xhci-hcd
>>>
>>> ERROR: Macros with complex values should be enclosed in parenthesis
>>> #115: FILE: drivers/usb/host/xhci-trace.h:44:
>>> +#define TRACE_INCLUDE_PATH .
>>>
>>> ERROR: Macros with complex values should be enclosed in parenthesis
>>> #118: FILE: drivers/usb/host/xhci-trace.h:47:
>>> +#define TRACE_INCLUDE_FILE xhci-trace
>>>
>>> total: 3 errors, 0 warnings, 169 lines checked
>>>
>>>
>>> The macros have to be defined that way for trace events to work.
>>
>> yeah, that's true, and we always just ignore chechpatch complaints
>> when it comes to TRACE_EVENT macros.
>>
>>> Can you fix checkpatch not to complain about trace event macros?
>>>
>
> So what are these TRACE_<FOO> defines that need
> excluding from the "complex values" check?
>
> Anything other than
>
> TRACE_SYSTEM
> TRACE_INCLUDE_FILE
> TRACE_INCLUDE_PATH
>
> ?
>
> samples/trace_events/trace-events-sample.h
> only has those 3.
>
Try:
# scripts/checkpatch.pl --file include/trace/events/*
You'll see numerous errors. :)
On Tue, 2013-07-30 at 10:06 +0800, Li Zefan wrote:
> On 2013/7/30 9:58, Joe Perches wrote:
> > So what are these TRACE_<FOO> defines that need
> > excluding from the "complex values" check?
> >
> > Anything other than
> >
> > TRACE_SYSTEM
> > TRACE_INCLUDE_FILE
> > TRACE_INCLUDE_PATH
> >
> > ?
> >
> > samples/trace_events/trace-events-sample.h
> > only has those 3.
> >
>
> Try:
> # scripts/checkpatch.pl --file include/trace/events/*
>
> You'll see numerous errors. :)
Nope, you'll see numerous whitespace defects, but no
actual errors.
If you run with:
--ignore=spacing,long_line,code_indent,leading_space,printf_l,split_string,space_before_tab,trailing_whitespace,line_continuations
it's flawless.
On 2013/7/30 10:36, Joe Perches wrote:
> On Tue, 2013-07-30 at 10:06 +0800, Li Zefan wrote:
>> On 2013/7/30 9:58, Joe Perches wrote:
>>> So what are these TRACE_<FOO> defines that need
>>> excluding from the "complex values" check?
>>>
>>> Anything other than
>>>
>>> TRACE_SYSTEM
>>> TRACE_INCLUDE_FILE
>>> TRACE_INCLUDE_PATH
>>>
>>> ?
>>>
>>> samples/trace_events/trace-events-sample.h
>>> only has those 3.
>>>
>>
>> Try:
>> # scripts/checkpatch.pl --file include/trace/events/*
>>
>> You'll see numerous errors. :)
>
> Nope, you'll see numerous whitespace defects, but no
> actual errors.
>
> If you run with:
>
> --ignore=spacing,long_line,code_indent,leading_space,printf_l,split_string,space_before_tab,trailing_whitespace,line_continuations
>
Serious? I'd just not run checkpatch.pl. ;)
> it's flawless.
>
The "complex values" check complaints come from many places in include/trace/events/*,
and I'm not going to check where and why.
On Tue, 2013-07-30 at 11:04 +0800, Li Zefan wrote:
> On 2013/7/30 10:36, Joe Perches wrote:
> > On Tue, 2013-07-30 at 10:06 +0800, Li Zefan wrote:
> >> On 2013/7/30 9:58, Joe Perches wrote:
> >>> So what are these TRACE_<FOO> defines that need
> >>> excluding from the "complex values" check?
> >>>
> >>> Anything other than
> >>>
> >>> TRACE_SYSTEM
> >>> TRACE_INCLUDE_FILE
> >>> TRACE_INCLUDE_PATH
> >>>
> >>> ?
> >>>
> >>> samples/trace_events/trace-events-sample.h
> >>> only has those 3.
> >>>
> >>
> >> Try:
> >> # scripts/checkpatch.pl --file include/trace/events/*
> >>
> >> You'll see numerous errors. :)
> >
> > Nope, you'll see numerous whitespace defects, but no
> > actual errors.
> >
> > If you run with:
> >
> > --ignore=spacing,long_line,code_indent,leading_space,printf_l,split_string,space_before_tab,trailing_whitespace,line_continuations
> >
>
> Serious? I'd just not run checkpatch.pl. ;)
Your choice. It's all whitespace and %Lx stuff.
I think the reports are actual style defects.
The line continuations and split strings uses are
pretty poor there too.
> The "complex values" check complaints come from many places in include/trace/events/*,
> and I'm not going to check where and why.
Nor I.
You haven't answered my question either.
On 2013/7/30 11:10, Joe Perches wrote:
> On Tue, 2013-07-30 at 11:04 +0800, Li Zefan wrote:
>> On 2013/7/30 10:36, Joe Perches wrote:
>>> On Tue, 2013-07-30 at 10:06 +0800, Li Zefan wrote:
>>>> On 2013/7/30 9:58, Joe Perches wrote:
>>>>> So what are these TRACE_<FOO> defines that need
>>>>> excluding from the "complex values" check?
>>>>>
>>>>> Anything other than
>>>>>
>>>>> TRACE_SYSTEM
>>>>> TRACE_INCLUDE_FILE
>>>>> TRACE_INCLUDE_PATH
>>>>>
>>>>> ?
>>>>>
>>>>> samples/trace_events/trace-events-sample.h
>>>>> only has those 3.
>>>>>
>>>>
>>>> Try:
>>>> # scripts/checkpatch.pl --file include/trace/events/*
>>>>
>>>> You'll see numerous errors. :)
>>>
>>> Nope, you'll see numerous whitespace defects, but no
>>> actual errors.
>>>
>>> If you run with:
>>>
>>> --ignore=spacing,long_line,code_indent,leading_space,printf_l,split_string,space_before_tab,trailing_whitespace,line_continuations
>>>
>>
>> Serious? I'd just not run checkpatch.pl. ;)
>
> Your choice. It's all whitespace and %Lx stuff.
> I think the reports are actual style defects.
> The line continuations and split strings uses are
> pretty poor there too.
>
>> The "complex values" check complaints come from many places in include/trace/events/*,
>> and I'm not going to check where and why.
>
> Nor I.
> You haven't answered my question either.
>
Oh, I overlooked it.
TRACE_SYSTEM defines the directory name in /sys/kernel/debug/tracing/events. A trace
event belongs to a trace system:
# cat /sys/kernel/debug/tracing/available_events
ext3:ext3_free_inode
ext3:ext3_request_inode
...
ext3 is the SYSTEM name.
TRACE_INCLUDE_FILE is needed if the .h filename is different than the SYSTEM name.
If the .h file is not in include/trace/events, then you must use TRACE_INCLUDE_PATH
to specify where the file is.
I'm not sure if there're any other maros need special treatment.
The tracing subsystem uses slightly odd #defines
to set path/directory locations for include files.
These #defines can cause false positives for the
complex macro tests so add exclusions for these
specific #defines (TRACE_SYSTEM, TRACE_INCLUDE_FILE,
TRACE_INCLUDE_PATH).
Signed-off-by: Joe Perches <[email protected]>
---
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2ee9eb7..998ad8f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3374,7 +3374,8 @@ sub process {
$dstat !~ /^for\s*$Constant$/ && # for (...)
$dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar()
$dstat !~ /^do\s*{/ && # do {...
- $dstat !~ /^\({/) # ({...
+ $dstat !~ /^\({/ && # ({...
+ $ctx !~ /^.\s*#\s*define\s+TRACE_(?:SYSTEM|INCLUDE_FILE|INCLUDE_PATH)\b/)
{
$ctx =~ s/\n*$//;
my $herectx = $here . "\n";