Re: [PATCH 4/4] CPER: Remove unnecessary use of user-space types

From: Masahiro Yamada
Date: Sat Mar 30 2019 - 08:53:56 EST


On Tue, Mar 26, 2019 at 3:26 AM Bjorn Helgaas <helgaas@xxxxxxxxxx> wrote:
>
> On Mon, Mar 25, 2019 at 01:14:25PM -0500, helgaas@xxxxxxxxxx wrote:
> > From: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> >
> > "__u32" and similar types are intended for things exported to user-space,
> > including structs used in ioctls; see include/uapi/asm-generic/int-l64.h.
> >
> > They are not needed for the CPER struct definitions, which not exported to
> > user-space and not used in ioctls. Replace them with the typical "u32" and
> > similar types. No functional change intended.
> >
> > The reason for changing this is to remove the question of "why do we use
> > __u32 here instead of u32?" We should use __u32 when there's a reason for
> > it; otherwise, we should prefer u32 for consistency.
> >
> > Reference: Documentation/process/coding-style.rst
> > Signed-off-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> > CC: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
> > CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>
> I cc'd you folks because you were part of this conversation:
>
> https://lore.kernel.org/lkml/1526350925-14922-3-git-send-email-yamada.masahiro@xxxxxxxxxxxxx/T/#u
>
> I *think* the conclusion there was that this sort of change makes
> sense, but I want to make sure. If it does make sense, I'm surprised
> at how much stuff in include/linux/ still uses __u32 when it doesn't
> appear to need it.


This patch looks good to me.

I still fail to understand Greg's comment in
the referred URL, though.


"__u32" and similar types are intended for things exported to user-space.

This is clearly documented.

Documentation/process/coding-style.rst:

(e) Types safe for use in userspace.

In certain structures which are visible to userspace, we cannot
require C99 types and cannot use the ``u32`` form above. Thus, we
use __u32 and similar types in all structures which are shared
with userspace.



I'd be eager to see a document that suggests __u32 and similar types
in ioctl structures.




--
Best Regards
Masahiro Yamada