From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ua1-f42.google.com (mail-ua1-f42.google.com [209.85.222.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF957126C17 for ; Mon, 29 Sep 2025 14:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759155546; cv=none; b=B0rJyCz2WAnu0enA9vCYunknzYaFItsSe4VQyI7MTfd/Dxo/5G1Xg4m9bFRYs0MmB5TZjqnLm5IfXJl2bC7hRsDiu+fgaos1locR7rDrAKvPXZlwfOfmZBWxiELRWCEMYhVasJq379gi9j8H/i/e7mNU84rwGGcOpPEsIc8+y+8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759155546; c=relaxed/simple; bh=Cqa9Uzqm9/s5VXEeXfESLlelcJ7lJBixKsxsE328zas=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=VDTnaZsTk4z/35yeQqjtVhrekRV2rH3deJmoxZ+nps+MAPtW2nKhIe7hQZMaAvDkWmTyD3hiXtg83bSI93EW5rJn4OJHYKR5DTQYc+yr6GnLfJJGS7uzrJP+x78ILqep6Jvd9mktgApnzbm0z9lXGvJsu4QaqP/LVudf0sWgrM8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SbxDFyue; arc=none smtp.client-ip=209.85.222.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SbxDFyue" Received: by mail-ua1-f42.google.com with SMTP id a1e0cc1a2514c-9231a251c01so722464241.1 for ; Mon, 29 Sep 2025 07:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759155543; x=1759760343; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=8f8mS2/PsiKtRfA+cy/Ijq5MGOVS0C89p6V4QtDT26M=; b=SbxDFyueq+KFFxSnkeFszRWccwAMQyhNg3Ea8luK9S9Y1BM1SnkRcFKJsj889eM4xa bk2pz2/GrRIOP3Szuuz/199N8jbKGx5AX5d8jQYNhk7eYEOOhmrlARwyakUvu52Uk/0s +ykcPzlLMdTEQbR01LvqtP15Kl9wEm2KrmzoiL2KIU4ztsjwYdSWMCRoFtBQflkDqxU3 F+m9pZL7zuqckzC+dNsrlYoMPVAkaZEHEx497NVmB+kLrvxZ+uFHM0TqygZ1XLwQhFIp UWGodqtaZge83fUexSHcJrmJ4M5epTko/U4SuXfRtg4H2+lVPpvZ3tA9laP/eSMgLsQD EiGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759155543; x=1759760343; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=8f8mS2/PsiKtRfA+cy/Ijq5MGOVS0C89p6V4QtDT26M=; b=P8mg7Qo8PcGwAsFxU/4ott1m6V04zbgE9CPUh39SLvlqog5ixwsK1HUjIR/UHy/i7O HYQUok+M8pXXce/loVqwSMTbrAj77O5yJNLFgFUeq/+rdnwFmH89tSSXkROFXUDXejjj ywHvxmtnFwl8pmGtJVp2x7RDNpqYTegcfLBaM5E8l7a4nC4/9vSWrGb54c08qbdpKpt2 BnNECwwpbkOhMx0FRgYTDWeiK2cJJhJB5MOImnzeFTc4aOlG/lRVZPRpmiI9ECCWo8YV OQO/L/gL8/r0v3yXzA2jkoMoXldnpGhTqlAOUB4gmom2NJxZTK4g7vqZfNZr6m5PePSv uuNw== X-Forwarded-Encrypted: i=1; AJvYcCUp716kkdI8DepK/4Idzi47q8A3gZ9Va4JVbFMHemtumC0UwaJD2nUOfriupHV4erWG/5Ied1gdrW3LZtk=@vger.kernel.org X-Gm-Message-State: AOJu0Ywz5eYN807Mum0PcsaS9p1EzOjY5ES/yNZH0SR3+WzBdBLl5yEf 7+odrt8WdVTV0Bc6m6WMsRsy/21tjC5khhpwQvqaActvBslFfPEPYUYA X-Gm-Gg: ASbGncvTlUvFy+1k6DQndaOKTp9n+fbhc4rjU98gHg/OAmLehR0Vf6EGXWRKJsGtrDD QcGMlVnQvc+BSW3uWUBneOYDwHt6eGhIosmeVGGPIhrDiU8Ai/zMZA2B2FCiw5UunFnBc+uvXxc Kf2sOVPDmLPRg6ipkbv4oH49S4d6mFx1PIUHwz8eDJ0/j5x0/22hXS68PgAXuinVSfJlEei3VEq zTdGBr3e/bZ0VRWbw1XOZjQD50BdCdlEgUK73YJX+zAaKXZJMhewxUgRivwQTaD0bsTFELjiCqV yATeGRMQ5G20o7zQ4nzJFnm9JG2NDnprCLlXYHR3epz+ygm495HVqbhXp8t0133HEyTdNVrjdIz S3AJS7EnP4G9oeC8TRvgt+7/R3aTznd6ahvP4krRDLxIqLSPG85ZtXmlHvquvym7OfXk1YYhuDy 57B/sO X-Google-Smtp-Source: AGHT+IHbGRPyI3TBsvsm/JH3bGpt2g5z5CYtKK6z0SBXiM2oKnumeml9UIrNcgYboy1D+yW+DlMLlA== X-Received: by 2002:a05:6122:3117:b0:545:eb6c:c6bb with SMTP id 71dfb90a1353d-54bea300520mr5569540e0c.12.1759155543420; Mon, 29 Sep 2025 07:19:03 -0700 (PDT) Received: from gmail.com (21.33.48.34.bc.googleusercontent.com. [34.48.33.21]) by smtp.gmail.com with UTF8SMTPSA id 71dfb90a1353d-54c0c1ff0c0sm1330558e0c.11.2025.09.29.07.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Sep 2025 07:19:01 -0700 (PDT) Date: Mon, 29 Sep 2025 10:19:01 -0400 From: Willem de Bruijn To: Sidharth Seela , antonio@openvpn.net, sd@queasysnail.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, willemdebruijn.kernel@gmail.com, kernelxing@tencent.com, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Sidharth Seela Message-ID: In-Reply-To: <20250929114356.25261-2-sidharthseela@gmail.com> References: <20250929114356.25261-2-sidharthseela@gmail.com> Subject: Re: [PATCH] selftest:net: Fix uninit pointers and return values Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit [PATCH net] and a Fixes tag Sidharth Seela wrote: > Fix uninitialized character pointers, and functions that return > undefined values. These issues were caught by running clang using LLVM=1 > option; and are as follows: > -- > ovpn-cli.c:1587:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] > 1587 | if (!sock) { > | ^~~~~ > ovpn-cli.c:1635:9: note: uninitialized use occurs here > 1635 | return ret; > | ^~~ > ovpn-cli.c:1587:2: note: remove the 'if' if its condition is always false > 1587 | if (!sock) { > | ^~~~~~~~~~~~ > 1588 | fprintf(stderr, "cannot allocate netlink socket\n"); > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 1589 | goto err_free; > | ~~~~~~~~~~~~~~ > 1590 | } > | ~ > ovpn-cli.c:1584:15: note: initialize the variable 'ret' to silence this warning > 1584 | int mcid, ret; > | ^ > | = 0 > ovpn-cli.c:2107:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized] > 2107 | case CMD_INVALID: > | ^~~~~~~~~~~ > ovpn-cli.c:2111:9: note: uninitialized use occurs here > 2111 | return ret; > | ^~~ > ovpn-cli.c:1939:12: note: initialize the variable 'ret' to silence this warning > 1939 | int n, ret; > | ^ These two look legitimate. > | > -- > txtimestamp.c:240:2: warning: variable 'tsname' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized] > 240 | default: Does not need a fix. The default statement calls error() which exits the program. > | ^~~~~~~ > txtimestamp.c:244:20: note: uninitialized use occurs here > 244 | __print_timestamp(tsname, &tss->ts[0], tskey, payload_len); > | ^~~~~~ > txtimestamp.c:220:20: note: initialize the variable 'tsname' to silence this warning > 220 | const char *tsname; > | ^ > | = NULL > -- > so_txtime.c:210:3: warning: variable 'reason' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized] > 210 | default: > | ^~~~~~~ Same. > so_txtime.c:219:27: note: uninitialized use occurs here > 219 | data[ret - 1], tstamp, reason); > | ^~~~~~ > so_txtime.c:177:21: note: initialize the variable 'reason' to silence this warning > 177 | const char *reason; > | ^ > | > -- > > Signed-off-by: Sidharth Seela Agreed on all the occurrences and the ovpn fixes. > --- > > diff --git a/tools/testing/selftests/net/ovpn/ovpn-cli.c b/tools/testing/selftests/net/ovpn/ovpn-cli.c > index 9201f2905f2c..20d00378f34a 100644 > --- a/tools/testing/selftests/net/ovpn/ovpn-cli.c > +++ b/tools/testing/selftests/net/ovpn/ovpn-cli.c > @@ -1581,7 +1581,7 @@ static int ovpn_listen_mcast(void) > { > struct nl_sock *sock; > struct nl_cb *cb; > - int mcid, ret; > + int mcid, ret = -1; > > sock = nl_socket_alloc(); > if (!sock) { > @@ -1936,7 +1936,7 @@ static int ovpn_run_cmd(struct ovpn_ctx *ovpn) > { > char peer_id[10], vpnip[INET6_ADDRSTRLEN], laddr[128], lport[10]; > char raddr[128], rport[10]; > - int n, ret; > + int n, ret = -1; > FILE *fp; > > switch (ovpn->cmd) { > diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c > index 8457b7ccbc09..b76df1efc2ef 100644 > --- a/tools/testing/selftests/net/so_txtime.c > +++ b/tools/testing/selftests/net/so_txtime.c > @@ -174,7 +174,7 @@ static int do_recv_errqueue_timeout(int fdt) > msg.msg_controllen = sizeof(control); > > while (1) { > - const char *reason; > + const char *reason = NULL; Since reason is a string that's printed, better to initialize it to a string. Preferably in the case statement, e.g., "unknown errno". > > ret = recvmsg(fdt, &msg, MSG_ERRQUEUE); > if (ret == -1 && errno == EAGAIN) > diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c > index dae91eb97d69..bcc14688661d 100644 > --- a/tools/testing/selftests/net/txtimestamp.c > +++ b/tools/testing/selftests/net/txtimestamp.c > @@ -217,7 +217,7 @@ static void print_timestamp_usr(void) > static void print_timestamp(struct scm_timestamping *tss, int tstype, > int tskey, int payload_len) > { > - const char *tsname; > + const char *tsname = NULL; > > validate_key(tskey, tstype); > > -- > 2.47.3 >