[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bab3c83c-2ba8-4d23-b3cb-2f233898f7f2@roeck-us.net>
Date: Mon, 9 Oct 2023 10:19:04 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Max Kellermann <max.kellermann@...os.com>
Cc: Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/7] drivers/hwmon: add local variable for newly
allocated attribute_group**
On Mon, Oct 09, 2023 at 06:57:35PM +0200, Max Kellermann wrote:
> This allows the compiler to keep the pointer in a register and
> prepares for making the struct field "const".
>
> Signed-off-by: Max Kellermann <max.kellermann@...os.com>
I have no idea what this is about, and I don't see how that would
improve anything, but ...
> ---
> drivers/hwmon/hwmon.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index c7dd3f5b2bd5..e50ab229b27d 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -783,6 +783,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
> hdev = &hwdev->dev;
>
> if (chip) {
> + const struct attribute_group **new_groups;
> struct attribute **attrs;
> int ngroups = 2; /* terminating NULL plus &hwdev->groups */
>
> @@ -790,8 +791,8 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
> for (i = 0; groups[i]; i++)
> ngroups++;
>
> - hwdev->groups = kcalloc(ngroups, sizeof(*groups), GFP_KERNEL);
> - if (!hwdev->groups) {
> + hwdev->groups = new_groups = kcalloc(ngroups, sizeof(*new_groups), GFP_KERNEL);
CHECK: multiple assignments should be avoided
#101: FILE: drivers/hwmon/hwmon.c:794:
+ hwdev->groups = new_groups = kcalloc(ngroups, sizeof(*new_groups), GFP_KERNEL);
either case, this change is not acceptable.
Guenter
Powered by blists - more mailing lists