Adrian Moreno <[email protected]> writes:

> Current regexp used to check whitespaces around operators does not
> consider that there can be more than one "*" together to express pointer
> to pointer.
>
> As a result, false positive warnings are raised when the
> patch contains a simple list of pointers, e.g: "char **errrp").
>
> Fix the regexp to allow more than one consecutive "+" characters.
>
> Signed-off-by: Adrian Moreno <[email protected]>
> ---

I'm not quite sure about the functionality of this patch.  For example,
this seems to pass just fine:

    **** list = * *bar;

BUT I think the coding style shouldn't allow it.  There's a question of
how much / where we want to get the errors (after all, it's the same
state we are in today of accepting these kinds of lines even when the
checkpatch script gets it wrong).  Obviously, the line above is a pretty
extreme case, but I think there must be a better regex / matching
criteria we can do for the asterisk rather than modifying this existing
one.

Maybe Ilya / Eelco feel different about it or have opinions.

>  tests/checkpatch.at     | 25 +++++++++++++++++++++++++
>  utilities/checkpatch.py |  2 +-
>  2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/tests/checkpatch.at b/tests/checkpatch.at
> index caab2817b..34971c514 100755
> --- a/tests/checkpatch.at
> +++ b/tests/checkpatch.at
> @@ -353,6 +353,31 @@ try_checkpatch \
>           if (--mcs->n_refs==0) {
>  "
>  
> +try_checkpatch \
> +   "COMMON_PATCH_HEADER
> +    +char *string;
> +    +char **list;
> +    +char ***ptr_list;
> +    "
> +
> +try_checkpatch \
> +   "COMMON_PATCH_HEADER
> +    +char** list;
> +    " \
> +    "WARNING: Line lacks whitespace around operator
> +    #8 FILE: A.c:1:
> +    char** list;
> +    "
> +
> +try_checkpatch \
> +   "COMMON_PATCH_HEADER
> +    +char*** list;
> +    " \
> +    "WARNING: Line lacks whitespace around operator
> +    #8 FILE: A.c:1:
> +    char*** list;
> +    "
> +
>  AT_CLEANUP
>  
>  AT_SETUP([checkpatch - check misuse APIs])
> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
> index 6b293770d..742a0bc47 100755
> --- a/utilities/checkpatch.py
> +++ b/utilities/checkpatch.py
> @@ -739,7 +739,7 @@ infix_operators = \
>              '&=', '^=', '|=', '<<=', '>>=']] \
>      + [r'[^<" ]<[^=" ]',
>         r'[^\->" ]>[^=" ]',
> -       r'[^ !()/"]\*[^/]',
> +       r'[^ !()/"\*]\*+[^/]',
>         r'[^ !&()"]&',
>         r'[^" +(]\+[^"+;]',
>         r'[^" \-(]\-[^"\->;]',

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to