Skip to content

Commit 1638161

Browse files
committed
Fix a false positive MACRO_ARG_PRECEDENCE case
Example which gives the FP: #define uptr_field_addr(obj, field) \ ({ \ (typeof(&((typeof(obj))0)->field)) \ ((char *)(obj) + (size_t)&((typeof(obj))0)->field); \ }) ERROR: Macro argument 'field' may be better as '(field)' to avoid precedence issues And using () around `field` won't compile. Closes tarantool#43
1 parent 0713d44 commit 1638161

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

checkpatch.pl

+2-1
Original file line numberDiff line numberDiff line change
@@ -4340,7 +4340,8 @@ sub process {
43404340
# check if any macro arguments may have other precedence issues
43414341
if ($tmp_stmt =~ m/($Operators)?\s*\b$arg\b\s*($Operators)?/m &&
43424342
((defined($1) && $1 ne ',') ||
4343-
(defined($2) && $2 ne ','))) {
4343+
(defined($2) && $2 ne ',')) &&
4344+
!(defined($1) && ($1 eq '->' || $1 eq '.'))) {
43444345
ERROR("MACRO_ARG_PRECEDENCE",
43454346
"Macro argument '$arg' may be better as '($arg)' to avoid precedence issues\n" . "$herectx");
43464347
}

0 commit comments

Comments
 (0)