From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org, dmitry.baryshkov@linaro.org,
akpm@linux-foundation.org
Subject: [failures] container_ofh-make-container_of-const-aware.patch removed from -mm tree
Date: Fri, 11 Feb 2022 14:05:43 -0800 [thread overview]
Message-ID: <20220211220544.077A9C340E9@smtp.kernel.org> (raw)
The patch titled
Subject: container_of.h: make container_of const-aware
has been removed from the -mm tree. Its filename was
container_ofh-make-container_of-const-aware.patch
This patch was dropped because it had testing failures
------------------------------------------------------
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Subject: container_of.h: make container_of const-aware
container_of() macro has one major drawback. It does not check whether
the passed ptr has a const pointer, the result will always be a non-const
pointer. Use a _Generic() construct (supported since gcc 4.9 and Clang
3.0) to teach container_of that if converting a const pointer, the
returned pointer should also have the const modifier.
Link: https://lkml.kernel.org/r/20220210170434.3924169-1-dmitry.baryshkov@linaro.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
--- a/include/linux/container_of.h~container_ofh-make-container_of-const-aware
+++ a/include/linux/container_of.h
@@ -19,7 +19,11 @@
static_assert(__same_type(*(ptr), ((type *)0)->member) || \
__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
- ((type *)(__mptr - offsetof(type, member))); })
+ _Generic((ptr), \
+ const typeof(((type *)0)->member)*: \
+ ((const type *)(__mptr - offsetof(type, member))), \
+ default: ((type *)(__mptr - offsetof(type, member))) \
+ ); })
/**
* container_of_safe - cast a member of a structure out to the containing structure
@@ -35,6 +39,10 @@
__same_type(*(ptr), void), \
"pointer type mismatch in container_of_safe()"); \
IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \
- ((type *)(__mptr - offsetof(type, member))); })
+ _Generic((ptr), \
+ const typeof(((type *)0)->member)*: \
+ ((const type *)(__mptr - offsetof(type, member))), \
+ default: ((type *)(__mptr - offsetof(type, member))) \
+ ); })
#endif /* _LINUX_CONTAINER_OF_H */
_
Patches currently in -mm which might be from dmitry.baryshkov@linaro.org are
reply other threads:[~2022-02-11 22:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220211220544.077A9C340E9@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@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 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.