mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arkadi Sharshevsky <arkadis@mellanox.com>
To: Arnd Bergmann <arnd@arndb.de>, Jiri Pirko <jiri@mellanox.com>,
	Ido Schimmel <idosch@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Wei Yongjun <weiyongjun1@huawei.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [net-next PATCH 2/2] mlxsw: spectrum_kvdl: avoid uninitialized variable warning
Date: Sun, 25 Feb 2018 12:04:55 +0200	[thread overview]
Message-ID: <907aca10-130b-3f2f-3960-eca019af3664@mellanox.com> (raw)
In-Reply-To: <20180223131540.1065413-2-arnd@arndb.de>



On 02/23/2018 03:15 PM, Arnd Bergmann wrote:
> gcc warns that 'resource_id' is not initialized if we don't come though
> any of the three 'case' statements before:
> 
> drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c: In function 'mlxsw_sp_kvdl_part_init':
> drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:275:8: error: 'resource_id' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> In the current code, that won't happen, but it's more robust to explicitly
> handle this by returning a failure from mlxsw_sp_kvdl_part_init.
> 
> Fixes: 887839e6960d ("mlxsw: spectrum_kvdl: Add support for dynamic partition set")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
> index 6fd701db90c9..059eb3214328 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
> @@ -270,6 +270,8 @@ static int mlxsw_sp_kvdl_part_init(struct mlxsw_sp *mlxsw_sp,
>  	case MLXSW_SP_KVDL_PART_LARGE_CHUNKS:
>  		resource_id = MLXSW_SP_RESOURCE_KVD_LINEAR_LARGE_CHUNKS;
>  		break;
> +	default:
> +		return -EINVAL;
>  	}
>  
>  	err = devlink_resource_size_get(devlink, resource_id, &resource_size);
> 
Acked-by: Arkadi Sharshevsky <arkadis@mellanox.com>

  reply	other threads:[~2018-02-25 10:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 13:15 [net-next PATCH 1/2] mlxsw: spectrum_kvdl: use div_u64() for 64-bit division Arnd Bergmann
2018-02-23 13:15 ` [net-next PATCH 2/2] mlxsw: spectrum_kvdl: avoid uninitialized variable warning Arnd Bergmann
2018-02-25 10:04   ` Arkadi Sharshevsky [this message]
2018-02-26 16:33   ` David Miller
2018-02-25 10:04 ` [net-next PATCH 1/2] mlxsw: spectrum_kvdl: use div_u64() for 64-bit division Arkadi Sharshevsky
2018-02-26 16:33 ` David Miller

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=907aca10-130b-3f2f-3960-eca019af3664@mellanox.com \
    --to=arkadis@mellanox.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=weiyongjun1@huawei.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

all inboxes | Powered by JetHome®