All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: linux-kernel@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [PATCH] container_of.h: make container_of const-aware
Date: Fri, 11 Feb 2022 14:05:23 -0800	[thread overview]
Message-ID: <20220211140523.738c14327b03647f535c4df8@linux-foundation.org> (raw)
In-Reply-To: <20220210170434.3924169-1-dmitry.baryshkov@linaro.org>

On Thu, 10 Feb 2022 20:04:34 +0300 Dmitry Baryshkov <dmitry.baryshkov@linaro.org> wrote:

> 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.
> 

Nice idea, but my x86_64 allnoconfig build explodes with zillions of
warnings.

In file included from ./include/linux/list.h:5,
                 from ./include/linux/module.h:12,
                 from init/do_mounts.c:2:
./include/net/sock.h: In function 'sk_entry':
./include/linux/container_of.h:17:42: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]


  reply	other threads:[~2022-02-11 22:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 17:04 [PATCH] container_of.h: make container_of const-aware Dmitry Baryshkov
2022-02-11 22:05 ` Andrew Morton [this message]
2022-02-11 22:10   ` Dmitry Baryshkov
2022-02-11 22:18     ` Andrew Morton

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=20220211140523.738c14327b03647f535c4df8@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dmitry.baryshkov@linaro.org \
    --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 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.