[PATCH 1/6] staging:android_pmem.h: Fixes the space and other formating issues pointed out by checkpatch.pl

Andy Whitcroft apw at canonical.com
Fri Jan 20 12:18:45 UTC 2012


On Fri, Jan 20, 2012 at 11:54 AM, Dan Carpenter
<dan.carpenter at oracle.com> wrote:
> It still complains about the following macros where parenthesis are
> not needed.
>
> ERROR: Macros with complex values should be enclosed in parenthesis
> #156: FILE: staging/android/pmem.c:156:
> +#define PMEM_IS_FREE(id, index) !(pmem[id].bitmap[index].allocated)
>
> Let's just make the check look for an operator with a low
> precedence.
> http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages
>
> Otherwise the submitters are going to change it to:
>
> #define PMEM_IS_FREE(id, index) (!(pmem[id].bitmap[index].allocated))
>
> That has two pairs of unneeded paranthesis and we run the risk of
> reprogramming the kernel in lisp, by mistake.

Yep we want to avoid that.  As -> binds tighter than many of the
operators in these bands we can only safely avoid the ()'s if the
operator does not potentially make a pointer, so for now I have added
unary minus and the two unary not operators.  I think I want to see
some examples of other operators before I would be keen to have any
further exceptions.

Anyhow how does this work for you:

    http://people.canonical.com/~apw/checkpatch/checkpatch-next.pl

-apw



More information about the devel mailing list