Re: [PATCH 1/2] Move kfree_call_rcu() to slab_common.c

From: Joe Perches
Date: Fri Jan 05 2018 - 01:46:22 EST


On Thu, 2018-01-04 at 16:07 -0800, Matthew Wilcox wrote:
> On Thu, Jan 04, 2018 at 03:47:32PM -0800, Paul E. McKenney wrote:
> > I was under the impression that typeof did not actually evaluate its
> > argument, but rather only returned its type. And there are a few macros
> > with this pattern in mainline.
> >
> > Or am I confused about what typeof does?
>
> I think checkpatch is confused by the '*' in the typeof argument:
>
> $ git diff |./scripts/checkpatch.pl --strict
> CHECK: Macro argument reuse 'ptr' - possible side-effects?
> #29: FILE: include/linux/rcupdate.h:896:
> +#define kfree_rcu(ptr, rcu_head) \
> + __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
>
> If one removes the '*', the warning goes away.
>
> I'm no perlista, but Joe, would this regexp modification make sense?
>
> +++ b/scripts/checkpatch.pl
> @@ -4957,7 +4957,7 @@ sub process {
> next if ($arg =~ /\.\.\./);
> next if ($arg =~ /^type$/i);
> my $tmp_stmt = $define_stmt;
> - $tmp_stmt =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
> + $tmp_stmt =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\**\(*\s*$arg\s*\)*\b//g;

I supposed ideally it'd be more like

$tmp_stmt =~ s/\b(?:typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*(?:\s*\*\s*)*\s*\(*\s*$arg\s*\)*\b//g;

Adding ?: at the start to not capture and
(?:\s*\*\s*)* for any number of * with any
surrounding spacings.