From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: Christian Brauner <brauner@kernel.org>
Cc: amir73il@gmail.com, hu1.chen@intel.com, miklos@szeredi.hu,
malini.bhandaru@intel.com, tim.c.chen@intel.com,
mikko.ylinen@intel.com, lizhen.you@intel.com,
linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC v3 1/5] cleanup: Fix discarded const warning when defining lock guard
Date: Mon, 18 Mar 2024 14:54:56 -0700 [thread overview]
Message-ID: <875xxjp5n3.fsf@intel.com> (raw)
In-Reply-To: <20240318-flocken-nagetiere-1e027955d06e@brauner>
Christian Brauner <brauner@kernel.org> writes:
> On Thu, Feb 15, 2024 at 09:16:36PM -0800, Vinicius Costa Gomes wrote:
>> Fix the following warning when defining a cleanup guard for a "const"
>> pointer type:
>>
>> ./include/linux/cleanup.h:211:18: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
>> 211 | return _T->lock; \
>> | ~~^~~~~~
>> ./include/linux/cleanup.h:233:1: note: in expansion of macro ‘__DEFINE_UNLOCK_GUARD’
>> 233 | __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, __VA_ARGS__) \
>> | ^~~~~~~~~~~~~~~~~~~~~
>> ./include/linux/cred.h:193:1: note: in expansion of macro ‘DEFINE_LOCK_GUARD_1’
>> 193 | DEFINE_LOCK_GUARD_1(cred, const struct cred, _T->lock = override_creds_light(_T->lock),
>> | ^~~~~~~~~~~~~~~~~~~
>>
>> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>> ---
>> include/linux/cleanup.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h
>> index c2d09bc4f976..085482ef46c8 100644
>> --- a/include/linux/cleanup.h
>> +++ b/include/linux/cleanup.h
>> @@ -208,7 +208,7 @@ static inline void class_##_name##_destructor(class_##_name##_t *_T) \
>> \
>> static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \
>> { \
>> - return _T->lock; \
>> + return (void *)_T->lock; \
>> }
>
> I think both of these patches are a bit ugly as we burden the generic
> cleanup code with casting to void which could cause actual issues.
Fair point.
>
> Casting from const to non-const is rather specific to the cred code so I
> would rather like to put the burden on the cred code instead of the
> generic code if possible.
For what it's worth, I liked your changes, will remove these two "fixes"
from the series and use your suggestions in the next version.
Thank you,
--
Vinicius
next prev parent reply other threads:[~2024-03-18 21:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 5:16 [RFC v3 0/5] overlayfs: Optimize override/revert creds Vinicius Costa Gomes
2024-02-16 5:16 ` [RFC v3 1/5] cleanup: Fix discarded const warning when defining lock guard Vinicius Costa Gomes
2024-03-18 15:13 ` Christian Brauner
2024-03-18 15:57 ` Christian Brauner
2024-03-26 0:50 ` Vinicius Costa Gomes
2024-03-26 10:53 ` Christian Brauner
2024-03-26 13:19 ` Christian Brauner
2024-03-26 16:23 ` Vinicius Costa Gomes
2024-03-18 21:54 ` Vinicius Costa Gomes [this message]
2024-02-16 5:16 ` [RFC v3 2/5] cleanup: Fix discarded const warning when defining guard Vinicius Costa Gomes
2024-02-16 5:16 ` [RFC v3 3/5] cred: Add a light version of override/revert_creds() Vinicius Costa Gomes
2024-02-16 5:16 ` [RFC v3 4/5] fs: Optimize credentials reference count for backing file ops Vinicius Costa Gomes
2024-02-16 5:16 ` [RFC v3 5/5] overlayfs: Optimize credentials usage Vinicius Costa Gomes
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=875xxjp5n3.fsf@intel.com \
--to=vinicius.gomes@intel.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=hu1.chen@intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=lizhen.you@intel.com \
--cc=malini.bhandaru@intel.com \
--cc=mikko.ylinen@intel.com \
--cc=miklos@szeredi.hu \
--cc=tim.c.chen@intel.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 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).