linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: rc-main: clean-up two warnings
@ 2019-05-23  9:27 Mauro Carvalho Chehab
  2019-05-23 10:43 ` Sean Young
  0 siblings, 1 reply; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2019-05-23  9:27 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Sean Young, Benjamin Valentin,
	Patrick Lerda, Matthias Reichl

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(-)

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: rc-main: clean-up two warnings
  2019-05-23  9:27 [PATCH] media: rc-main: clean-up two warnings Mauro Carvalho Chehab
@ 2019-05-23 10:43 ` Sean Young
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Young @ 2019-05-23 10:43 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab,
	Benjamin Valentin, Patrick Lerda, Matthias Reichl

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-23 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23  9:27 [PATCH] media: rc-main: clean-up two warnings Mauro Carvalho Chehab
2019-05-23 10:43 ` Sean Young

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).