From: Guenter Roeck <linux@roeck-us.net>
To: Ranganath V N <vnranganath.20@gmail.com>
Cc: Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com,
khalid@kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [PATCH] hwmon: sht3x: initialize variable 'ret' in update_interval_write().
Date: Sun, 12 Oct 2025 11:07:23 -0700 [thread overview]
Message-ID: <e2ae44a3-b3c8-4f90-a180-c619e1854317@roeck-us.net> (raw)
In-Reply-To: <20251012-my_driver_work-v1-1-9e5fe6de51f4@gmail.com>
On Sun, Oct 12, 2025 at 05:13:27PM +0530, Ranganath V N wrote:
> fix for the smatch errors:
> drivers/hwmon/sht3x.c:606 update_interval_write() error: uninitialized symbol 'ret'.
>
> The warning can occur when both the data->mode and mode which is
> derived from get_mode_from_update_interval() are zero.
> In this case, no i2c command is sent and ret remains undefined
> before reaching the coman return path.
>
> When both data->mode and mode are zero, the device remains in
> single shot mode and no configuration change is required.
> In such cases, it is correct to treat the operation as successful
> without issuing any i2c transfer.
Actually, in this case, the code enters
if (mode == data->mode) {
mutex_unlock(&data->data_lock);
return 0;
}
meaning the problem does not actually exist because 'ret' will be
initialized if either 'mode' or 'data->mode' is != 0. That means
the smatch report is a false positive, and this patch is not required.
Guenter
prev parent reply other threads:[~2025-10-12 18:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-12 11:43 Ranganath V N
2025-10-12 11:57 ` Markus Elfring
2025-10-12 17:59 ` Guenter Roeck
2025-10-12 18:07 ` Guenter Roeck [this message]
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=e2ae44a3-b3c8-4f90-a180-c619e1854317@roeck-us.net \
--to=linux@roeck-us.net \
--cc=david.hunter.linux@gmail.com \
--cc=jdelvare@suse.com \
--cc=khalid@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=vnranganath.20@gmail.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®