Re: constification and cocci / kernel build test robot ?

Julia Lawall
2016-08-28T09:41:02Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1732 bytes --]

On Sat, 27 Aug 2016, Joe Perches wrote:

> On Sat, 2016-08-27 at 20:59 +0200, Julia Lawall wrote:
> >  Make sure (of/i2c/platform)_device_id tables are NULL terminated
> > Generated by: scripts/coccinelle/misc/of_table.cocci
>
> Along the same lines, I submitted a manually generated
> patch to add const to some of these structs.
>
> https://lkml.org/lkml/2016/8/26/494
>
> Could cocci and/or the kbuild test robot check for structs
> that could or should be const?

Possibly. I have sent a lot of patches to constify things, but I used gcc
to verify that the constification was OK. I could also just send you a
list of the structures that I have constified, or better yet a list of the
structures that are currently always const in the kernel, and you could
perhaps just add them all to checkpatch. Many of them are not used very
often. If it would be better to only check for structures that are eg
referenced at least some number of times, or in some number of files, or
in more than one leaf subdirectory, all of that would be possible.

There are also now the "read only after init" annotations that we could be
encouraging people to add. Kees Cook talked about this at the security
summit last week. There is thus a need to be sure that things are
annotated as __init that should be as well.

julia

>
>
> > Please take the patch only if it's a positive warning. Thanks!
> []
> > +++ b/drivers/thermal/intel_bxt_pmic_thermal.c
> > @@ -281,6 +281,7 @@ static struct platform_device_id pmic_th
> >                 .name = "bxt_wcove_thermal",
> >                 .driver_data = (kernel_ulong_t)&bxtwc_thermal_data,
> >         },
> > +       {},
> >  };
> >
> >  static struct platform_driver pmic_thermal_driver = {
>