From patchwork Fri Nov 24 17:15:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willem de Bruijn X-Patchwork-Id: 13468028 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X9Av2luZ" Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 439481701; Fri, 24 Nov 2023 09:16:51 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-67a18ee7d3bso4219786d6.2; Fri, 24 Nov 2023 09:16:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700846210; x=1701451010; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NUWoPAOl1iJX4r4aM7k3dDQXfTGNs77R3n9G2uEeCSg=; b=X9Av2luZrM4Z7rlJTElxVMSfCKEnpEl5uuQMfWILYdWS65pSWE2tt+E2QPMXUt11fj N8KQb0IEXB7S4oKNgd2CQUNeBvyxWR1QQZ8jodmgb7okxBUzssxwBo+dzYhLgCvQ495p yN2sK43H/BAM40ogt35I7+2+LhoazP41YkVKKp9YskB0dmFY4Ovr6l5rT7AX5CFsQtce +BgXhjC9wsH9LTWwWp53Ra5753jm/7uXUROOjUKtR3Qc9IS7B5XDVRQ/HX7Xjsz0kX/O 4UX09NLsstIO6eeCJ9PtmXDcybKsczlw98EcfGwOi9sfeFowld0qKr4GNzvVMNsT/Mf2 eelg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700846210; x=1701451010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NUWoPAOl1iJX4r4aM7k3dDQXfTGNs77R3n9G2uEeCSg=; b=h+oJDSdzDdX679BBa/PgfowFedUWKA4DPH8OYY1WFf0gf3IfckONpcaSTYdYE8tt91 QDPgp1cuSXvASQFzfdf0xeouWxGNmso6SC8K1FyYmyzB7QiZlEKMgBjsEgWSmzuB/+GE 4Bfly5fOdJ+5BW/TiawXjqn5dfUH3tovRJW2mMXiKt494BIaKGaFO1B8Jpcxle/5BOcc jQRb9Lv60xcogBac8BnzGTaYzTCTEiugxj6+R/M7FKu/s+d9yFfYAeNt6GqhJFa7YZOL A0kA6WqwxBz7rGOdM5ts5rWQeJb0GENa7v0OQfcVZ17LR7HP3ljMcrcowMQjQUc7N47U OeMA== X-Gm-Message-State: AOJu0YxIjtoKwfJQl5me+Rk8R5PvIBjiQAWMVTupxQCKcryuh9hArHGN th6xcr51FiRSdM4U+BRD8j3BL6tFoso= X-Google-Smtp-Source: AGHT+IEv5AJRDQ656srmGqdHzN2UVuwAvbeUiL51GPC3+xU/kpFQQzUrQST9y1V7rSWB7ap05L11cQ== X-Received: by 2002:a05:6214:5c9:b0:67a:1806:5c81 with SMTP id t9-20020a05621405c900b0067a18065c81mr3181506qvz.6.1700846210313; Fri, 24 Nov 2023 09:16:50 -0800 (PST) Received: from willemb.c.googlers.com.com (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id mn23-20020a0562145ed700b0067a0a00b24csm1389278qvb.73.2023.11.24.09.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 09:16:50 -0800 (PST) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kselftest@vger.kernel.org, Willem de Bruijn , Dmitry Safonov <0x7f454c46@gmail.com> Subject: [PATCH net 1/4] selftests/net: ipsec: fix constant out of range Date: Fri, 24 Nov 2023 12:15:19 -0500 Message-ID: <20231124171645.1011043-2-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231124171645.1011043-1-willemdebruijn.kernel@gmail.com> References: <20231124171645.1011043-1-willemdebruijn.kernel@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Willem de Bruijn Fix a small compiler warning. nr_process must be a signed long: it is assigned a signed long by strtol() and is compared against LONG_MIN and LONG_MAX. ipsec.c:2280:65: error: result of comparison of constant -9223372036854775808 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare] if ((errno == ERANGE && (nr_process == LONG_MAX || nr_process == LONG_MIN)) Fixes: bc2652b7ae1e ("selftest/net/xfrm: Add test for ipsec tunnel") Cc: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: Willem de Bruijn Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> --- tools/testing/selftests/net/ipsec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c index 9a8229abfa026..be4a30a0d02ae 100644 --- a/tools/testing/selftests/net/ipsec.c +++ b/tools/testing/selftests/net/ipsec.c @@ -2263,7 +2263,7 @@ static int check_results(void) int main(int argc, char **argv) { - unsigned int nr_process = 1; + long nr_process = 1; int route_sock = -1, ret = KSFT_SKIP; int test_desc_fd[2]; uint32_t route_seq; @@ -2284,7 +2284,7 @@ int main(int argc, char **argv) exit_usage(argv); } - if (nr_process > MAX_PROCESSES || !nr_process) { + if (nr_process > MAX_PROCESSES || nr_process < 1) { printk("nr_process should be between [1; %u]", MAX_PROCESSES); exit_usage(argv); From patchwork Fri Nov 24 17:15:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willem de Bruijn X-Patchwork-Id: 13468029 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jy0nuGGd" Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A2E1718; Fri, 24 Nov 2023 09:16:51 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-41cc535cd5cso10202281cf.2; Fri, 24 Nov 2023 09:16:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700846211; x=1701451011; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=af1+2koe7V56mmURceKREPPaIe6SUwS89TrLZExIq8o=; b=Jy0nuGGd/TjVtWvMD0DPR+7658ft96W23ujyUaBknAe8jJIH+dH0OhIxUOdtT7ydmE D8b/aKH2CusSkPhd+dv4NHjxIQOXCBSmuobUDuYWDuhxhX15cwOADn1qdy1wlKqkbBn/ /i/USzC7EILHK4s6YFYZqF/CPQZYAz2HnEtswGp0TTEXfehZ5QLRzoJolR6wJRQVkvZx C9tpqyY385zyBF3aBbA3YwicWKQUvSEYMhsCyd1MYz4PRdeb+vDjpwW7AUWRd98gByRY e8QvCrlbnB9yc24vx6Z8siDLLbXkdLxCl8RiXJWkxoU4sYSCJnzomI1NqR2LzmHZVSwr 3fzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700846211; x=1701451011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=af1+2koe7V56mmURceKREPPaIe6SUwS89TrLZExIq8o=; b=uegHy9C6W7LO8qSrJ74UiVjn7VABRmHG7La5avts5VPVjxbZUdA8wAK1a2WUWjEn3g FK9ICaxnnuHPERTw6ya26X1REBcNwc26akY9QTofpcWlB9ClmgkNFKY9Lwjra9h4+coE N8bF2zbO/ivddQNE0ZqBb34eOYRQqOsvqZL1Tb4srUG3UfdlR9Egp5UqL/51pAcm/pRN p/DMeZxNJhreTuQJT1gzpFx816AebTMNdbqzz1tzZhKpoR2/ZMXc+PLijNk0TTeZkTRF V5OTtF0iLUPFqlIQhZFWtzRXPEQu9dxzrsVMHLb3GjqFFK4Q4i1rKoDJBztdiAGdr+9z 0Dvg== X-Gm-Message-State: AOJu0YzeqBJscMjqxXZNWwEVT2sOR8rENxQwALH3byfWbEukWSIT88TH kacjWiJzPCc9FIEhFzlfBqxx4wHiDbM= X-Google-Smtp-Source: AGHT+IHfWRqp0G5GAIhgLsja5PYY9aE/hq9PcYJ5RqZ17mhhd1LspLh6byXAL/qHWyBiv3Ff0xdVag== X-Received: by 2002:a05:6214:1fd0:b0:66d:1ae6:2a5a with SMTP id jh16-20020a0562141fd000b0066d1ae62a5amr3618105qvb.7.1700846210686; Fri, 24 Nov 2023 09:16:50 -0800 (PST) Received: from willemb.c.googlers.com.com (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id mn23-20020a0562145ed700b0067a0a00b24csm1389278qvb.73.2023.11.24.09.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 09:16:50 -0800 (PST) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kselftest@vger.kernel.org, Willem de Bruijn Subject: [PATCH net 2/4] selftests/net: fix a char signedness issue Date: Fri, 24 Nov 2023 12:15:20 -0500 Message-ID: <20231124171645.1011043-3-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231124171645.1011043-1-willemdebruijn.kernel@gmail.com> References: <20231124171645.1011043-1-willemdebruijn.kernel@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Willem de Bruijn Signedness of char is signed on x86_64, but unsigned on arm64. Fix the warning building cmsg_sender.c on signed platforms or forced with -fsigned-char: msg_sender.c:455:12: error: implicit conversion from 'int' to 'char' changes value from 128 to -128 [-Werror,-Wconstant-conversion] buf[0] = ICMPV6_ECHO_REQUEST; constant ICMPV6_ECHO_REQUEST is 128. Link: https://lwn.net/Articles/911914 Fixes: de17e305a810 ("selftests: net: cmsg_sender: support icmp and raw sockets") Signed-off-by: Willem de Bruijn --- tools/testing/selftests/net/cmsg_sender.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/cmsg_sender.c b/tools/testing/selftests/net/cmsg_sender.c index 24b21b15ed3fb..6ff3e732f449f 100644 --- a/tools/testing/selftests/net/cmsg_sender.c +++ b/tools/testing/selftests/net/cmsg_sender.c @@ -416,9 +416,9 @@ int main(int argc, char *argv[]) { struct addrinfo hints, *ai; struct iovec iov[1]; + unsigned char *buf; struct msghdr msg; char cbuf[1024]; - char *buf; int err; int fd; From patchwork Fri Nov 24 17:15:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willem de Bruijn X-Patchwork-Id: 13468027 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lgpyujTu" Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6FD1725; Fri, 24 Nov 2023 09:16:51 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-66d264e67d8so11138306d6.1; Fri, 24 Nov 2023 09:16:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700846211; x=1701451011; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=065lvx7Qel1Qqzgxc2Lf3Xry0KnOsZoE16eEGlBVdZs=; b=lgpyujTu9/WkIUwT/xiID7O/PR6uulVpF8ve43VHrotYmc0VE4G2NyCF20xptQA+Tm X0+J/m3qCiUWI03rFWchbPkA6FfTet/hm4ufX6h1N7faWqZ0dpilX/XPkwHWIadc9gO0 dY0MX1Qr7VqVx5V/FLeUnfhxetOVRRI2v8qzGybhBMAguAJoKQtRplYo6XyF9dKXaZjb QYRoh2oV6CQ4bh0k3tTzzWwRALX88RyMa3k7GV4Oh9sZKiUN/V+1p9AodzpPnO4eULmD NT34eE9hJ3XpxmhAFa60XEnOzB+pi+ZuWeV9I5VKn6rXyTH3woizFnjbRsDJkVRiZPf0 Rbbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700846211; x=1701451011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=065lvx7Qel1Qqzgxc2Lf3Xry0KnOsZoE16eEGlBVdZs=; b=lu4SC16LJJCq91O/k1bUcIaOxWZlkgr5hUsOHsIpvS0+2AYgGzleukoAtgL5F5W9qu NRYq/ObftW9bMjekK0bWwhyege1pVQOCIdqN1I5uuoHHE4dUdCck5lCXBdFaou7aPsVN bWy95Zo+ERhvNH7wElZkNW1R4C0ez00Yeh7kEoHZMHb5qaPr3ng1ghPhUND41F/SdlSx u7xOedVaY3q2g8JRgO/CCUE2PQ/SJm74ybpJtAR58dgEA3kktvVU4a5i00hkr0RpSHoR 34BKx51rLCFiguTaDJoD87pR4DTzy0Ef+2mAQ/XIy3tRDMrFBLiOMUSKoO5SuQVLpuQi 2Rpg== X-Gm-Message-State: AOJu0YzxHnd0+Xs1gEi9N64QjhBgXslHBzqMkr6BlgTOi+3cd8/c1KxF EV/8i7Ul6bQjb4WvZZfa/w5YhHOLu50= X-Google-Smtp-Source: AGHT+IFu95tKs6mBRzoxVROwtpSYCNufscR1FnyQdDBw8jxCr6QFF63d6wwzGqK4SvsOhcvK9e4ChA== X-Received: by 2002:ad4:44ab:0:b0:67a:19d0:4b6c with SMTP id n11-20020ad444ab000000b0067a19d04b6cmr2297271qvt.13.1700846211119; Fri, 24 Nov 2023 09:16:51 -0800 (PST) Received: from willemb.c.googlers.com.com (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id mn23-20020a0562145ed700b0067a0a00b24csm1389278qvb.73.2023.11.24.09.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 09:16:50 -0800 (PST) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kselftest@vger.kernel.org, Willem de Bruijn Subject: [PATCH net 3/4] selftests/net: unix: fix unused variable compiler warning Date: Fri, 24 Nov 2023 12:15:21 -0500 Message-ID: <20231124171645.1011043-4-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231124171645.1011043-1-willemdebruijn.kernel@gmail.com> References: <20231124171645.1011043-1-willemdebruijn.kernel@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Willem de Bruijn Remove an unused variable. diag_uid.c:151:24: error: unused variable 'udr' [-Werror,-Wunused-variable] Fixes: ac011361bd4f ("af_unix: Add test for sock_diag and UDIAG_SHOW_UID.") Signed-off-by: Willem de Bruijn --- tools/testing/selftests/net/af_unix/diag_uid.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/net/af_unix/diag_uid.c b/tools/testing/selftests/net/af_unix/diag_uid.c index 5b88f7129fea4..79a3dd75590e8 100644 --- a/tools/testing/selftests/net/af_unix/diag_uid.c +++ b/tools/testing/selftests/net/af_unix/diag_uid.c @@ -148,7 +148,6 @@ void receive_response(struct __test_metadata *_metadata, .msg_iov = &iov, .msg_iovlen = 1 }; - struct unix_diag_req *udr; struct nlmsghdr *nlh; int ret; From patchwork Fri Nov 24 17:15:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willem de Bruijn X-Patchwork-Id: 13468030 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZYM3NfMz" Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A24E51987; Fri, 24 Nov 2023 09:16:52 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-4239f5c1ec2so2152221cf.0; Fri, 24 Nov 2023 09:16:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700846212; x=1701451012; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+a865Y5eccV4NEfBYguXGSbwXwv2AQMyNfi8KVk866g=; b=ZYM3NfMzU2IKiRXqt4cUkA/vadUGPGLwgNHdEUH/Dr9AVQtJ1plcIwaVPk9KMrP4UU +wj4FXU8Coi18yXCdxWf/uQatMIAEZP5qyRy9XUn4AJLHkZdLQA+EC/G6+5Y93QZ8/8c 30TUJcqJpi/4rvBm1gTWMEIMJUpKm1vy/AhyDlYtSc6XCtHFIKHlpBtwQEU7jgrylCl3 u10ee/ZTUarzjK5+aAy5M145vDER9ye1Cgf5La2vvSGWSC1VMQEhQTWuV7LmxuYhUwp4 DJ73xpYIL2qma5J42fp5W5Hb+Wt0LX2n+EAAhXPkdofFbCiepZONIt6i+uP8OcsUp1cZ TuCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700846212; x=1701451012; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+a865Y5eccV4NEfBYguXGSbwXwv2AQMyNfi8KVk866g=; b=mNBF6nooZQSnovhEF9wLIowriQG97vC4E2gvkdqwogVjBvos6JGLGiaEacu9Vn8J3m Ydi35wxlSGQwaR6nrj7T2CnIxOkqy1kJubzqCbM/XIrTFmkQQLQSVcCibuByrvCB7lh8 nlQ2Sncotk2Dxu4vCTiEsFVZT4wXcgMKzw6vWkKFn7mycEKWpGkX3vr8XaGe/TdnIQ55 lnJEPb0ahiSyMlPr3HSZ/DlQa01mc8WO6PwSc6Yqn6Z2H7Z6xL1CqhFUXXlyZrAAro/R Pu6Xgq8Yja20mwlP2ZAHiUr1bqWxUFvXojldDbVZlJT7kq7madU5NRxJ5jweqNZ9f6vS df/A== X-Gm-Message-State: AOJu0YwGXNeH8fBs+9I/e5gYoAzwTAcfHZ9C2DhHxi7LjYNE1KeUD+0X 25OujaRzvYsuiw/NwM4cpwlckJsEmm0= X-Google-Smtp-Source: AGHT+IE0HeRN63PBpoyZcTtaUbo3vRuh7mcI/BW0ogR+qmamwWOEmndqelPnTfRrMrvrl5t7uNRNPQ== X-Received: by 2002:a05:6214:4991:b0:671:dac1:c856 with SMTP id pf17-20020a056214499100b00671dac1c856mr5300384qvb.53.1700846211723; Fri, 24 Nov 2023 09:16:51 -0800 (PST) Received: from willemb.c.googlers.com.com (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id mn23-20020a0562145ed700b0067a0a00b24csm1389278qvb.73.2023.11.24.09.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 09:16:51 -0800 (PST) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, linux-kselftest@vger.kernel.org, Willem de Bruijn , Florian Westphal Subject: [PATCH net 4/4] selftests/net: mptcp: fix uninitialized variable warnings Date: Fri, 24 Nov 2023 12:15:22 -0500 Message-ID: <20231124171645.1011043-5-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231124171645.1011043-1-willemdebruijn.kernel@gmail.com> References: <20231124171645.1011043-1-willemdebruijn.kernel@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Willem de Bruijn Same init_rng() in both tests. The function reads /dev/urandom to initialize srand(). In case of failure, it falls back onto the entropy in the uninitialized variable. Not sure if this is on purpose. But failure reading urandom should be rare, so just fail hard. While at it, convert to getrandom(). Which man 4 random suggests is simpler and more robust. mptcp_inq.c:525:6: mptcp_connect.c:1131:6: error: variable 'foo' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp") Fixes: b51880568f20 ("selftests: mptcp: add inq test case") Cc: Florian Westphal Signed-off-by: Willem de Bruijn ---- When input is randomized because this is expected to meaningfully explore edge cases, should we also add 1. logging the random seed to stdout and 2. adding a command line argument to replay from a specific seed I can do this in net-next, if authors find it useful in this case. Reviewed-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/mptcp_connect.c | 11 ++++------- tools/testing/selftests/net/mptcp/mptcp_inq.c | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c index c7f9ebeebc2c5..d2043ec3bf6d6 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -1125,15 +1126,11 @@ int main_loop_s(int listensock) static void init_rng(void) { - int fd = open("/dev/urandom", O_RDONLY); unsigned int foo; - if (fd > 0) { - int ret = read(fd, &foo, sizeof(foo)); - - if (ret < 0) - srand(fd + foo); - close(fd); + if (getrandom(&foo, sizeof(foo), 0) == -1) { + perror("getrandom"); + exit(1); } srand(foo); diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/selftests/net/mptcp/mptcp_inq.c index 8672d898f8cda..218aac4673212 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_inq.c +++ b/tools/testing/selftests/net/mptcp/mptcp_inq.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -519,15 +520,11 @@ static int client(int unixfd) static void init_rng(void) { - int fd = open("/dev/urandom", O_RDONLY); unsigned int foo; - if (fd > 0) { - int ret = read(fd, &foo, sizeof(foo)); - - if (ret < 0) - srand(fd + foo); - close(fd); + if (getrandom(&foo, sizeof(foo), 0) == -1) { + perror("getrandom"); + exit(1); } srand(foo);