Re: [PATCH ethtool 2/3] netlink: Fix maybe uninitialized 'meters' variable
From: Michal Kubecek <hidden>
Date: 2023-01-14 00:09:27
Attachments
- signature.asc [application/pgp-signature] 488 bytes
From: Michal Kubecek <hidden>
Date: 2023-01-14 00:09:27
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@gmail.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