2021-03-30 08:42:47

by Michal Koutný

[permalink] [raw]
Subject: Re: [PATCH 06/11] cgroup: fix -Wzero-length-bounds warnings

On Mon, Mar 22, 2021 at 05:02:44PM +0100, Arnd Bergmann <[email protected]> wrote:
> I'm not sure what is expected to happen for such a configuration,
> presumably these functions are never calls in that case.
Yes, the functions you patched would only be called from subsystems or
there should be no way to obtain a struct cgroup_subsys reference
anyway (hence it's ok to always branch as if ss==NULL).

I'd prefer a variant that wouldn't compile the affected codepaths when
there are no subsystems registered, however, I couldn't come up with a
way how to do it without some preprocessor ugliness.

Reviewed-by: Michal Koutn? <[email protected]>


Attachments:
(No filename) (656.00 B)
signature.asc (849.00 B)
Digital signature
Download all attachments

2021-03-30 09:02:16

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 06/11] cgroup: fix -Wzero-length-bounds warnings

On Tue, Mar 30, 2021 at 10:41 AM Michal Koutný <[email protected]> wrote:
>
> On Mon, Mar 22, 2021 at 05:02:44PM +0100, Arnd Bergmann <[email protected]> wrote:
> > I'm not sure what is expected to happen for such a configuration,
> > presumably these functions are never calls in that case.
> Yes, the functions you patched would only be called from subsystems or
> there should be no way to obtain a struct cgroup_subsys reference
> anyway (hence it's ok to always branch as if ss==NULL).
>
> I'd prefer a variant that wouldn't compile the affected codepaths when
> there are no subsystems registered, however, I couldn't come up with a
> way how to do it without some preprocessor ugliness.

Would it be possible to enclose most or all of kernel/cgroup/cgroup.c
in an #ifdef CGROUP_SUBSYS_COUNT block? I didn't try that
myself, but this might be a way to guarantee that there cannot
be any callers (it would cause a link error).

> Reviewed-by: Michal Koutný <[email protected]>

Thanks

Arnd

2021-03-30 14:46:14

by Michal Koutný

[permalink] [raw]
Subject: Re: [PATCH 06/11] cgroup: fix -Wzero-length-bounds warnings

On Tue, Mar 30, 2021 at 11:00:36AM +0200, Arnd Bergmann <[email protected]> wrote:
> Would it be possible to enclose most or all of kernel/cgroup/cgroup.c
> in an #ifdef CGROUP_SUBSYS_COUNT block?
Even without any controllers, there can still be named hierarchies (v1)
or the default hierarchy (v2) (for instance) for process tracking
purposes. So only parts of kernel/cgroup/cgroup.c could be ifdef'd.

Beware that CGROUP_SUBSYS_COUNT is not known at preprocessing stage (you
could have a macro alternative though).

> I didn't try that myself, but this might be a way to guarantee that
> there cannot be any callers (it would cause a link error).
Such a guarantee would be nicer, I agree. I tried a bit but anandoned it
when I saw macros proliferate (which I found less readable than your
current variant). But YMMV.

Michal


Attachments:
(No filename) (842.00 B)
signature.asc (849.00 B)
Digital signature
Download all attachments