[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230114000920.izp4tzfcn4cbciec@lion.mk-sys.cz>
Date: Sat, 14 Jan 2023 01:09:20 +0100
From: Michal Kubecek <mkubecek@...e.cz>
To: Florian Fainelli <f.fainelli@...il.com>
Cc: netdev@...r.kernel.org, Markus Mayer <mmayer@...adcom.com>,
Andrew Lunn <andrew@...n.ch>
Subject: Re: [PATCH ethtool 2/3] netlink: Fix maybe uninitialized 'meters'
variable
On Fri, Jan 13, 2023 at 03:31:47PM -0800, Florian Fainelli wrote:
> GCC12 warns that 'meters' may be uninitialized, initialize it
> accordingly.
>
> Fixes: 9561db9b76f4 ("Add cable test TDR support")
> Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
> ---
> netlink/parser.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/netlink/parser.c b/netlink/parser.c
> index f982f229a040..6f863610a490 100644
> --- a/netlink/parser.c
> +++ b/netlink/parser.c
> @@ -237,7 +237,7 @@ int nl_parse_direct_m2cm(struct nl_context *nlctx, uint16_t type,
> struct nl_msg_buff *msgbuff, void *dest)
> {
> const char *arg = *nlctx->argp;
> - float meters;
> + float meters = 0.0;
> uint32_t cm;
> int ret;
>
No problem here either but it's quite surprising as I check build with
gcc versions 7 and 11-13 (10-12 until recently) for each new commit and
I never saw this warning. As the warning is actually incorrect (either
parse_float() returns an error and we bail out or it assigns a value to
meters), it may be a gcc issue that was fixed in a later version. But
initializing the variable does no harm so let's do it.
Michal
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists