From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
To: XU pengfei <xupengfei@nfschina.com>, Guenter Roeck <linux@roeck-us.net>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 1/1] hwmon: remove unnecessary (void*) conversions
Date: Wed, 11 Jan 2023 13:09:35 +0700 [thread overview]
Message-ID: <dada9a9c-32fd-9d8c-b692-5efb8a94c20f@gnuweeb.org> (raw)
In-Reply-To: <423fcac8-97cc-88b7-19d8-f93baddea3cd@gnuweeb.org>
On 1/11/23 1:03 PM, Ammar Faizi wrote:
> On 1/11/23 10:29 AM, Guenter Roeck wrote:
>> On 1/10/23 18:07, XU pengfei wrote:
>>> diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
>>> index f77dc6db31ac..501337ee5aa3 100644
>>> --- a/drivers/hwmon/powr1220.c
>>> +++ b/drivers/hwmon/powr1220.c
>>> @@ -174,7 +174,7 @@ static umode_t
>>> powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
>>> attr, int channel)
>>> {
>>> - struct powr1220_data *chip_data = (struct powr1220_data *)data;
>>> + struct powr1220_data *chip_data = data;
>
> This is wrong. That cast is needed to discard the "const".
>
> CC [M] drivers/hwmon/powr1220.o
> drivers/hwmon/powr1220.c: In function ‘powr1220_is_visible’:
> drivers/hwmon/powr1220.c:177:43: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
> 177 | struct powr1220_data *chip_data = data;
> | ^~~~
> cc1: all warnings being treated as errors
Anyway, powr1220_is_visible() doesn't write via that pointer, but
the local variable needs to be a const as well.
diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
index f77dc6db31ac..7cbbed5a6f5e 100644
--- a/drivers/hwmon/powr1220.c
+++ b/drivers/hwmon/powr1220.c
@@ -174,7 +174,7 @@ static umode_t
powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
attr, int channel)
{
- struct powr1220_data *chip_data = (struct powr1220_data *)data;
+ const struct powr1220_data *chip_data = data;
if (channel >= chip_data->max_channels)
return 0;
--
Ammar Faizi
next prev parent reply other threads:[~2023-01-11 6:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 2:07 XU pengfei
2023-01-11 3:29 ` Guenter Roeck
2023-01-11 6:03 ` Ammar Faizi
2023-01-11 6:09 ` Ammar Faizi [this message]
2023-01-11 7:24 ` kernel test robot
2023-01-11 7:54 ` kernel test robot
2023-01-11 8:55 ` kernel test robot
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=dada9a9c-32fd-9d8c-b692-5efb8a94c20f@gnuweeb.org \
--to=ammarfaizi2@gnuweeb.org \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=xupengfei@nfschina.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
all inboxes | Powered by JetHome®