All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@aj.id.au>
To: openbmc@lists.ozlabs.org
Subject: Re: [PATCH linux dev-4.10] i2c: fsi: Fix unused variable warning
Date: Thu, 01 Jun 2017 23:21:50 +0930	[thread overview]
Message-ID: <1496325110.2448422.995421856.4D7FC7AF@webmail.messagingengine.com> (raw)
In-Reply-To: <20170601063703.3083-1-joel@jms.id.au>



On Thu, Jun 1, 2017, at 16:07, Joel Stanley wrote:
> When there is no status bit to handle we return the uninitialised rc
> variable, causing this warning:
> 
> drivers/i2c/busses/i2c-fsi.c: In function ‘fsi_i2c_xfer’:
> drivers/i2c/busses/i2c-fsi.c:410:7: warning: ‘rc’ may be used
> uninitialized in
> this function [-Wmaybe-uninitialized]
>     if (rc < 0)
>        ^
> drivers/i2c/busses/i2c-fsi.c:358:6: note: ‘rc’ was declared here
>   int rc;
>       ^~
> 
> Instead return zero, but also print a warning as this looks like an
> error, as  we have checked the I2C_FSI_STAT register for
> I2C_STAT_ANY_RESP, but none of the status bits were set.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>

> ---
>  drivers/i2c/busses/i2c-fsi.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
> index 4689479acf5e..b4eb1028a2ae 100644
> --- a/drivers/i2c/busses/i2c-fsi.c
> +++ b/drivers/i2c/busses/i2c-fsi.c
> @@ -355,12 +355,12 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port
> *port, struct i2c_msg *msg,
>  static int fsi_i2c_handle_status(struct fsi_i2c_port *port,
>  				 struct i2c_msg *msg, u32 status)
>  {
> -       int rc;
> -       u8 fifo_count;
>  	struct fsi_i2c_master *i2c = port->master;
> -       u32 dummy = 0;
> +       u8 fifo_count;
> +       int rc;
>  
>  	if (status & I2C_STAT_ERR) {
> +               u32 dummy = 0;
>  		rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_ERR, &dummy);
>  		if (rc)
>  			return rc;
> @@ -387,9 +387,12 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port
> *port,
>  			rc = -ENODATA;
>  		else
>  			rc = msg->len;
> +               return rc;
>  	}
>  
> -       return rc;
> +       dev_warn(&port->adapter.dev, "no status to handle\n");
> +
> +       return 0;
>  }
>  
>  static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg,
> -- 
> 2.11.0
> 

  reply	other threads:[~2017-06-01 13:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01  6:37 [PATCH linux dev-4.10] i2c: fsi: Fix unused variable warning Joel Stanley
2017-06-01 13:51 ` Andrew Jeffery [this message]
2017-06-01 14:53 ` Eddie James

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=1496325110.2448422.995421856.4D7FC7AF@webmail.messagingengine.com \
    --to=andrew@aj.id.au \
    --cc=openbmc@lists.ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.