diff mbox series

media: rc-main: clean-up two warnings

Message ID eda16d66b830a1bb62129b4771b5ca8ca0ed0a9b.1558603642.git.mchehab+samsung@kernel.org (mailing list archive)
State New, archived
Headers show
Series media: rc-main: clean-up two warnings | expand

Commit Message

Mauro Carvalho Chehab May 23, 2019, 9:27 a.m. UTC
While correct, the code is too complex for smatch to undersdand
that protocol will always be initialized:

	drivers/media/rc/rc-main.c:1531 store_wakeup_protocols() error: uninitialized symbol 'protocol'.
	drivers/media/rc/rc-main.c:1541 store_wakeup_protocols() error: uninitialized symbol 'protocol'.

So, change it a little bit in order to avoid such warning.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/rc/rc-main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Sean Young May 23, 2019, 10:43 a.m. UTC | #1
On Thu, May 23, 2019 at 05:27:30AM -0400, Mauro Carvalho Chehab wrote:
> While correct, the code is too complex for smatch to undersdand
> that protocol will always be initialized:
> 
> 	drivers/media/rc/rc-main.c:1531 store_wakeup_protocols() error: uninitialized symbol 'protocol'.
> 	drivers/media/rc/rc-main.c:1541 store_wakeup_protocols() error: uninitialized symbol 'protocol'.
> 
> So, change it a little bit in order to avoid such warning.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

Acked-by: Sean Young <sean@mess.org>

> ---
>  drivers/media/rc/rc-main.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index be5fd129d728..13da4c5c7d17 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -1502,7 +1502,7 @@ static ssize_t store_wakeup_protocols(struct device *device,
>  				      const char *buf, size_t len)
>  {
>  	struct rc_dev *dev = to_rc_dev(device);
> -	enum rc_proto protocol;
> +	enum rc_proto protocol = RC_PROTO_UNKNOWN;
>  	ssize_t rc;
>  	u64 allowed;
>  	int i;
> @@ -1511,9 +1511,7 @@ static ssize_t store_wakeup_protocols(struct device *device,
>  
>  	allowed = dev->allowed_wakeup_protocols;
>  
> -	if (sysfs_streq(buf, "none")) {
> -		protocol = RC_PROTO_UNKNOWN;
> -	} else {
> +	if (!sysfs_streq(buf, "none")) {
>  		for (i = 0; i < ARRAY_SIZE(protocols); i++) {
>  			if ((allowed & (1ULL << i)) &&
>  			    sysfs_streq(buf, protocols[i].name)) {
> -- 
> 2.21.0
diff mbox series

Patch

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index be5fd129d728..13da4c5c7d17 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1502,7 +1502,7 @@  static ssize_t store_wakeup_protocols(struct device *device,
 				      const char *buf, size_t len)
 {
 	struct rc_dev *dev = to_rc_dev(device);
-	enum rc_proto protocol;
+	enum rc_proto protocol = RC_PROTO_UNKNOWN;
 	ssize_t rc;
 	u64 allowed;
 	int i;
@@ -1511,9 +1511,7 @@  static ssize_t store_wakeup_protocols(struct device *device,
 
 	allowed = dev->allowed_wakeup_protocols;
 
-	if (sysfs_streq(buf, "none")) {
-		protocol = RC_PROTO_UNKNOWN;
-	} else {
+	if (!sysfs_streq(buf, "none")) {
 		for (i = 0; i < ARRAY_SIZE(protocols); i++) {
 			if ((allowed & (1ULL << i)) &&
 			    sysfs_streq(buf, protocols[i].name)) {