mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com
Subject: [PATCH] simplify container_of_const()
Date: Fri, 19 Jul 2024 22:19:37 +0300	[thread overview]
Message-ID: <a088c95b-53d2-42ea-9eb3-ae81fbd07c1b@p183> (raw)

* add necessary parenthesis so that

	container_of_const((expr1, expr2), T, member)

  compiles without warnings,

* delete unnecessary parenthesis,

* delete unnecessary cast:

	container_of(ptr, T, member)

  has type "T*" and doesn't need any more casts.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 include/linux/container_of.h |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/include/linux/container_of.h
+++ b/include/linux/container_of.h
@@ -30,9 +30,9 @@
  * @member:		the name of the member within the struct.
  */
 #define container_of_const(ptr, type, member)				\
-	_Generic(ptr,							\
-		const typeof(*(ptr)) *: ((const type *)container_of(ptr, type, member)),\
-		default: ((type *)container_of(ptr, type, member))	\
+	_Generic((ptr),							\
+		const typeof(*(ptr)) *: (const type *)container_of(ptr, type, member),\
+		default: container_of(ptr, type, member)		\
 	)
 
 #endif	/* _LINUX_CONTAINER_OF_H */

             reply	other threads:[~2024-07-19 19:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 19:19 Alexey Dobriyan [this message]
2024-07-19 19:29 ` Alexey Dobriyan

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=a088c95b-53d2-42ea-9eb3-ae81fbd07c1b@p183 \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®