From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Joe Perches <joe@perches.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Greg KH <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>,
Linux Media Mailing List <linux-media@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Randy Dunlap <rdunlap@infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] media: do not use C++ style comments in uapi headers
Date: Mon, 10 Jun 2019 02:19:49 +0900 [thread overview]
Message-ID: <CAK7LNAT3iKOX=0GxrB__m9haM=0L+MZQRq_OvFhW5N3iaaBAPA@mail.gmail.com> (raw)
In-Reply-To: <bd1ef99fc503fed492ad036f781963ca15a8596f.camel@perches.com>
On Sun, Jun 9, 2019 at 10:40 PM Joe Perches <joe@perches.com> wrote:
>
> On Sun, 2019-06-09 at 22:08 +0900, Masahiro Yamada wrote:
> > On Sun, Jun 9, 2019 at 8:57 PM Joe Perches <joe@perches.com> wrote:
> > > On Sun, 2019-06-09 at 16:14 +0900, Masahiro Yamada wrote:
> > > > Hi Joe,
> > > >
> > > > On Thu, Jun 6, 2019 at 2:06 AM Joe Perches <joe@perches.com> wrote:
> > > > > Perhaps a checkpatch change too:
> > > > >
> > > > > The first block updates unsigned only bitfields
> > > > > The second tests uapi definitions and suggests "__<kernel_types"
> > > >
> > > > Good.
> > > >
> > > > In addition,
> > > >
> > > > "warn if __u8, __u16, __u32, __u64 are used outside of uapi/"
> > > >
> > > > Lots of kernel-space headers use __u{8,16,32,64} instead of u{8,16,32,64}
> > > > just because developers often miss to understand when to use
> > > > the underscore-prefixed types.
> > >
> > > The problem there is that checkpatch can't know if the
> > > __<uapi_type> being used is for an actual uapi use or not.
> > >
> > > coccinelle could be much better at that.
> >
> > Why?
>
>
> Perhaps it's (somewhat) bad form to have a __uapi type in a
> structure, include that structure in a driver for something
> like a copy_to/from_user, and map the __<uapi_type> to a non
> underscore prefixed <kernel_type>
Linus Torvalds wrote 'sparse' to check this.
Any attempt to distinguish the address-space
by the presence of double-underscore-prefixes is pointless.
This is already checked by __kernel / __user.
It is absolutely correct to assign __u32 to u32, and vice versa.
If you think the following patch is wrong, please tell me why:
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 748ac489ef7e..24c1b73d9fbd 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1132,7 +1132,7 @@ static struct binder_node *binder_init_node_ilocked(
struct binder_node *node;
binder_uintptr_t ptr = fp ? fp->binder : 0;
binder_uintptr_t cookie = fp ? fp->cookie : 0;
- __u32 flags = fp ? fp->flags : 0;
+ u32 flags = fp ? fp->flags : 0;
assert_spin_locked(&proc->inner_lock);
@@ -4918,7 +4918,7 @@ static int
binder_ioctl_get_node_info_for_ref(struct binder_proc *proc,
{
struct binder_node *node;
struct binder_context *context = proc->context;
- __u32 handle = info->handle;
+ u32 handle = info->handle;
if (info->strong_count || info->weak_count || info->reserved1 ||
info->reserved2 || info->reserved3) {
>
> For instance
>
> struct flat_binder_object in drivers/android/binder.c
>
> How is checkpatch supposed to know that __u32 flags is
> inappropriate?
>
>
--
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2019-06-09 17:20 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 11:13 [PATCH] media: do not use C++ style comments in uapi headers Masahiro Yamada
2019-06-04 11:23 ` Joe Perches
2019-06-04 11:48 ` Masahiro Yamada
2019-06-04 12:04 ` Joe Perches
2019-06-04 11:54 ` Arnd Bergmann
2019-06-04 12:48 ` Masahiro Yamada
2019-06-04 13:32 ` Masahiro Yamada
2019-06-04 13:42 ` Greg KH
2019-06-04 15:27 ` Masahiro Yamada
2019-06-04 18:20 ` Arnd Bergmann
2019-06-05 4:10 ` Masahiro Yamada
2019-06-05 5:10 ` Greg KH
2019-06-05 5:22 ` Joe Perches
2019-06-05 6:02 ` Greg KH
2019-06-05 10:08 ` Masahiro Yamada
2019-06-05 10:14 ` Mauro Carvalho Chehab
2019-06-05 17:03 ` Joe Perches
2019-06-09 7:14 ` Masahiro Yamada
2019-06-09 11:55 ` Joe Perches
2019-06-09 13:08 ` Masahiro Yamada
2019-06-09 13:35 ` Joe Perches
2019-06-09 17:19 ` Masahiro Yamada [this message]
2019-06-09 17:42 ` Pavel Machek
2019-06-16 15:48 ` Pavel Machek
2019-06-04 14:42 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK7LNAT3iKOX=0GxrB__m9haM=0L+MZQRq_OvFhW5N3iaaBAPA@mail.gmail.com' \
--to=yamada.masahiro@socionext.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rdunlap@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).