From: trix@redhat.com
To: vilhelm.gray@gmail.com, nathan@kernel.org,
ndesaulniers@google.com, Jonathan.Cameron@huawei.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Tom Rix <trix@redhat.com>
Subject: [PATCH] counter: add defaults to switch-statements
Date: Sun, 27 Feb 2022 08:17:46 -0800 [thread overview]
Message-ID: <20220227161746.82776-1-trix@redhat.com> (raw)
From: Tom Rix <trix@redhat.com>
Clang static analysis reports this representative problem
counter-chrdev.c:482:3: warning: Undefined or garbage value
returned to caller
return ret;
^~~~~~~~~~
counter_get_data() has a multilevel switches, some without
defaults, so ret is sometimes not set.
Add returning -EINVAL similar to other defaults.
Fixes: b6c50affda59 ("counter: Add character device interface")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/counter/counter-chrdev.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
index b7c62f957a6a8..69d340be9c93f 100644
--- a/drivers/counter/counter-chrdev.c
+++ b/drivers/counter/counter-chrdev.c
@@ -477,6 +477,8 @@ static int counter_get_data(struct counter_device *const counter,
case COUNTER_SCOPE_COUNT:
ret = comp->count_u8_read(counter, parent, &value_u8);
break;
+ default:
+ return -EINVAL;
}
*value = value_u8;
return ret;
@@ -496,6 +498,8 @@ static int counter_get_data(struct counter_device *const counter,
case COUNTER_SCOPE_COUNT:
ret = comp->count_u32_read(counter, parent, &value_u32);
break;
+ default:
+ return -EINVAL;
}
*value = value_u32;
return ret;
--
2.26.3
next reply other threads:[~2022-02-27 16:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-27 16:17 trix [this message]
2022-02-27 17:46 ` [PATCH] counter: add defaults to switch-statements Jonathan Cameron
2022-02-28 13:03 ` William Breathitt Gray
2022-02-28 13:18 ` Tom Rix
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=20220227161746.82776-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=vilhelm.gray@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