From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Subject: [PATCHv2 3/3] dvb-frontends/drxk_hard.c: fix uninitialized variable warning
Date: Thu, 8 Oct 2020 13:59:13 +0200 [thread overview]
Message-ID: <20201008115913.3579973-4-hverkuil-cisco@xs4all.nl> (raw)
In-Reply-To: <20201008115913.3579973-1-hverkuil-cisco@xs4all.nl>
drxk_hard.c: In function 'hi_command.constprop':
drxk_hard.c:1016:5: warning: 'wait_cmd' may be used uninitialized in this function [-Wmaybe-uninitialized]
1015 | } while ((status < 0) && (retry_count < DRXK_MAX_RETRIES)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1016 | && (wait_cmd != 0));
| ^~~~~~~~~~~~~~~~~~
The underlying cause is that the while condition is wrong. It should be:
(status < 0 || wait_cmd) && (retry_count < DRXK_MAX_RETRIES)
'wait_cmd' is only valid if '!(status < 0)'.
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
drivers/media/dvb-frontends/drxk_hard.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index 32f9346deb3e..a57470bf71bf 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -1011,8 +1011,7 @@ static int hi_command(struct drxk_state *state, u16 cmd, u16 *p_result)
retry_count += 1;
status = read16(state, SIO_HI_RA_RAM_CMD__A,
&wait_cmd);
- } while ((status < 0) && (retry_count < DRXK_MAX_RETRIES)
- && (wait_cmd != 0));
+ } while ((status < 0 || wait_cmd) && (retry_count < DRXK_MAX_RETRIES));
if (status < 0)
goto error;
status = read16(state, SIO_HI_RA_RAM_RES__A, p_result);
--
2.28.0
prev parent reply other threads:[~2020-10-08 11:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 11:59 [PATCHv2 0/3] Three fixes to clean up daily build warnings Hans Verkuil
2020-10-08 11:59 ` [PATCHv2 1/3] s5k5baf: drop 'data' field in struct s5k5baf_fw Hans Verkuil
2020-10-08 12:58 ` Philipp Zabel
2020-10-08 14:01 ` Philipp Zabel
2020-10-08 11:59 ` [PATCHv2 2/3] tvp7002: fix uninitialized variable warning Hans Verkuil
2020-10-08 11:59 ` Hans Verkuil [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=20201008115913.3579973-4-hverkuil-cisco@xs4all.nl \
--to=hverkuil-cisco@xs4all.nl \
--cc=linux-media@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 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).