From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Zijun Hu <zijun_hu@icloud.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jason Gunthorpe <jgg@ziepe.ca>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-kernel@vger.kernel.org, Zijun Hu <quic_zijuhu@quicinc.com>
Subject: Re: [PATCH] linux/container_of.h: Remove redundant type cast in container_of_const()
Date: Mon, 12 Aug 2024 14:17:30 +0000 [thread overview]
Message-ID: <ZroZelxS_ddHwH30@kekkonen.localdomain> (raw)
In-Reply-To: <ZrX9G2Ol2jt4o-s7@smile.fi.intel.com>
Hi Andy, Zijun,
On Fri, Aug 09, 2024 at 02:27:23PM +0300, Andy Shevchenko wrote:
> On Fri, Aug 02, 2024 at 11:15:15PM +0800, Zijun Hu wrote:
> > From: Zijun Hu <quic_zijuhu@quicinc.com>
> >
> > Remove redundant (type *) cast for default branch in container_of_const()
> > since the cast has been done by container_of().
>
> While it might have same effect, the below is explicitly clear about both
> cases. With your patch it will become inconsistent.
In the const case it's actually required whereas container_of() already
does exactly the same cast, rendering the cast done below redundant.
There's nothing inconsistent in removing a needless cast.
Removing it is my preference as well.
>
> ...
>
> > #define container_of_const(ptr, type, member) \
> > _Generic(ptr, \
> > const typeof(*(ptr)) *: ((const type *)container_of(ptr, type, member)),\
>
> (see, in the above line the cast is still present / required)
>
> > - default: ((type *)container_of(ptr, type, member)) \
> > + default: container_of(ptr, type, member) \
> > )
>
--
Kind regards,
Sakari Ailus
next prev parent reply other threads:[~2024-08-12 14:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 15:15 [PATCH] linux/container_of.h: Remove redundant type cast in container_of_const() Zijun Hu
2024-08-09 11:27 ` Andy Shevchenko
2024-08-09 12:04 ` Zijun Hu
2024-08-12 14:17 ` Sakari Ailus [this message]
2024-08-13 9:17 ` Greg Kroah-Hartman
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=ZroZelxS_ddHwH30@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_zijuhu@quicinc.com \
--cc=rafael@kernel.org \
--cc=willy@infradead.org \
--cc=zijun_hu@icloud.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.