Checkpatch error on trace events macros
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
Joe Perches
maintainerQuoted 1 line · Sarah Sharp
Hi Andy and Joe,
Hi Sarah.
Quoted 7 lines
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.
Quoted 7 lines
ERROR: Macros with complex values should be enclosed in parenthesis #115: FILE:
drivers/usb/host/xhci-trace.h:44:
+#defineTRACE_INCLUDE_PATH.ERROR: Macros with complex values should be enclosed in parenthesis #118: FILE:
drivers/usb/host/xhci-trace.h:47:
+#defineTRACE_INCLUDE_FILExhci-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.
Quoted 13 lines · Joe Perches
Quoted 1 line · Sarah Sharp
Hi Andy and Joe,
Hi Sarah.
Quoted 7 lines
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
Quoted 4 lines
<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.
Quoted 2 lines
checkpatch sees this as a subtraction which really should have parentheses.
I see.
Quoted 10 lines
Quoted 7 lines
ERROR: Macros with complex values should be enclosed in parenthesis #115: FILE:
drivers/usb/host/xhci-trace.h:44:
+#defineTRACE_INCLUDE_PATH.ERROR: Macros with complex values should be enclosed in parenthesis #118: FILE:
drivers/usb/host/xhci-trace.h:47:
+#defineTRACE_INCLUDE_FILExhci-traceDon't expect to checkpatch to be perfect.
Quoted 7 lines
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
Joe Perches
maintainerQuoted 2 lines · Sarah Sharp
Quoted 1 line · Joe Perches
On Mon, 2013-07-29 at 12:52 -0700, Sarah Sharp wrote:
[]
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
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
12577closer 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
Quoted 1 line
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
177Quoted 1 line
there is no "should" here, just opinions.
Given the "I think", we agree!
Quoted 14 lines · Sarah Sharp
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-hcdERROR: Macros with complex values should be enclosed in parenthesis #115: FILE:
drivers/usb/host/xhci-trace.h:44:
+#defineTRACE_INCLUDE_PATH.
Quoted 8 lines
ERROR: Macros with complex values should be enclosed in parenthesis #118: FILE:
drivers/usb/host/xhci-trace.h:47:
+#defineTRACE_INCLUDE_FILExhci-tracetotal: 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.
Quoted 2 lines
Can you fix checkpatch not to complain about trace event macros?
Joe Perches
maintainerQuoted 19 lines · Li Zefan
Quoted 18 lines · Sarah Sharp
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-hcdERROR: Macros with complex values should be enclosed in parenthesis #115: FILE:
drivers/usb/host/xhci-trace.h:44:
+#defineTRACE_INCLUDE_PATH.ERROR: Macros with complex values should be enclosed in parenthesis #118: FILE:
drivers/usb/host/xhci-trace.h:47:
+#defineTRACE_INCLUDE_FILExhci-trace
Quoted 10 lines
Quoted 4 lines
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_EVENTmacros.Quoted 2 lines
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_SYSTEMTRACE_INCLUDE_FILETRACE_INCLUDE_PATH
?
samples/trace_events/trace-events-sample.h
only has those 3.
Quoted 36 lines · Joe Perches
Quoted 19 lines · Li Zefan
Quoted 18 lines · Sarah Sharp
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-hcdERROR: Macros with complex values should be enclosed in parenthesis #115: FILE:
drivers/usb/host/xhci-trace.h:44:
+#defineTRACE_INCLUDE_PATH.ERROR: Macros with complex values should be enclosed in parenthesis #118: FILE:
drivers/usb/host/xhci-trace.h:47:
+#defineTRACE_INCLUDE_FILExhci-traceQuoted 10 lines
Quoted 4 lines
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_EVENTmacros.Quoted 2 lines
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
Quoted 9 lines
TRACE_SYSTEMTRACE_INCLUDE_FILETRACE_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. :)
Joe Perches
maintainerQuoted 12 lines · Li Zefan
Quoted 11 lines · Joe Perches
So what are these TRACE_<FOO> defines that need
excluding from the "complex values" check?Anything other than
TRACE_SYSTEMTRACE_INCLUDE_FILETRACE_INCLUDE_PATH?
Quoted 8 lines
Quoted 3 lines
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.
Quoted 20 lines · Joe Perches
Quoted 19 lines · Li Zefan
Quoted 5 lines · Joe Perches
So what are these TRACE_<FOO> defines that need
excluding from the "complex values" check?Anything other than
Quoted 9 lines
TRACE_SYSTEMTRACE_INCLUDE_FILETRACE_INCLUDE_PATH?
samples/trace_events/trace-events-sample.h
only has those 3.Try:
# scripts/checkpatch.pl --file include/trace/events/*
Quoted 9 lines
Quoted 1 line
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. ;)
Quoted 2 lines
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.
Joe Perches
maintainerQuoted 26 lines · Li Zefan
Quoted 25 lines · Joe Perches
Quoted 12 lines · Li Zefan
Quoted 11 lines · Joe Perches
So what are these TRACE_<FOO> defines that need
excluding from the "complex values" check?Anything other than
TRACE_SYSTEMTRACE_INCLUDE_FILETRACE_INCLUDE_PATH?
Quoted 8 lines
Quoted 3 lines
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.
Quoted 6 lines
Quoted 4 lines
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.
Quoted 2 lines
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.
Quoted 39 lines · Joe Perches
Quoted 26 lines · Li Zefan
Quoted 25 lines · Joe Perches
Quoted 12 lines · Li Zefan
Quoted 11 lines · Joe Perches
So what are these TRACE_<FOO> defines that need
excluding from the "complex values" check?Anything other than
TRACE_SYSTEMTRACE_INCLUDE_FILETRACE_INCLUDE_PATH?
Quoted 8 lines
Quoted 3 lines
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.
Quoted 6 lines
Quoted 4 lines
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.
Quoted 6 lines
Quoted 2 lines
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.
Joe Perches
maintainerPATCH 1/1 checkpatch: Ignore #define TRACE_<foo> macros
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).
--- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
@@ -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";