Re: [RFC PATCH] checkpatch: Support __initconst combined with struct definition

From: Andy Shevchenko
Date: Tue Apr 11 2023 - 09:38:58 EST


On Wed, Mar 01, 2023 at 10:43:20AM +0100, Björn Töpel wrote:
> From: Björn Töpel <bjorn@xxxxxxxxxxxx>
>
> Checkpatch sometimes report a false positive for __initconst. E.g., for the
> following snippet:
>
> | static const struct strspn_test {
> | const char str[16];
> | const char accept[16];
> | const char reject[16];
> | unsigned a;
> | unsigned r;
> | } tests[] __initconst = {
> | { "foobar", "", "", 0, 6 },
> | { "abba", "abc", "ABBA", 4, 4 },
> | { "abba", "a", "b", 1, 1 },
> | { "", "abc", "abc", 0, 0},
> | };
>
> checkpatch would report:
>
> | ERROR: Use of __initconst requires a separate use of const
> | #190: FILE: ./test_string.c:190:
> | + } tests[] __initconst = {
>
> Improve the reporting by trying harder to find the 'const'.

Joe, what do you think about this?

--
With Best Regards,
Andy Shevchenko