From nobody Sat Oct 4 11:13:49 2025 Received: from smtp1.iitb.ac.in (smtpd9.iitb.ac.in [103.21.126.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 392B3317719 for ; Sun, 17 Aug 2025 09:36:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.21.126.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755423389; cv=none; b=MGzvdDADqjjskai69d0haAAfRJD9qSHu7Az3OKmgjYkpQKwwGNN+dCagky9EJrtAgmRZv0Il9U5Ypse+pPgm05mrraS0X3J5ZUPJQDZy8Qij0eaEmVUjPzZb8qPTQGHBwaPhmOu/zibdT72uMe1TSsM18EbxmuEqgSNdTEDbZ1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755423389; c=relaxed/simple; bh=QUVIStTkAQtgw3rORRQT/eO6z9COm4pxchQ0/kMZ11U=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=UslwIjv6cNxjDohcuHwOPPPGuH5ClS9pbd5ezew30v+GV3vWd2PXLyCp9L82cb8XwFJ4AENUPs0ESlEC4L5CFIeV/CfSnpA29Zhd2HhZwUlf5hJMag83N0+VXVKMaJ1AXM2RT1SuIPVRSbn1odU75K9lkCKZt4AiCSoR06d+k5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ee.iitb.ac.in; spf=pass smtp.mailfrom=ee.iitb.ac.in; dkim=pass (1024-bit key) header.d=iitb.ac.in header.i=@iitb.ac.in header.b=KnWO6qx+; arc=none smtp.client-ip=103.21.126.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ee.iitb.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ee.iitb.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iitb.ac.in header.i=@iitb.ac.in header.b="KnWO6qx+" Received: from ldns1.iitb.ac.in (ldns1.iitb.ac.in [10.200.12.1]) by smtp1.iitb.ac.in (Postfix) with SMTP id EF69A104CFE3 for ; Sun, 17 Aug 2025 15:06:13 +0530 (IST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.iitb.ac.in EF69A104CFE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iitb.ac.in; s=mail; t=1755423373; bh=QUVIStTkAQtgw3rORRQT/eO6z9COm4pxchQ0/kMZ11U=; h=Date:From:To:Cc:Subject:From; b=KnWO6qx+3Omav/kQlEIbycpae23KbLgMyA2EFv9K2qZ9vJAtFXy7YxgYqR/tXlik0 Wqa4pnhpBPmE67nb+13+G8BdzF9Y3qJq6QMlrmWoOW2fZ1MaWfrJDN+KS2gbYGZo8n evRHblvmZl0u9LstCebco9g3mI6Q+Z5/sA5tH760= Received: (qmail 9060 invoked by uid 510); 17 Aug 2025 15:06:13 +0530 X-Qmail-Scanner-Diagnostics: from 10.200.1.25 by ldns1 (envelope-from , uid 501) with qmail-scanner-2.11 spamassassin: 3.4.1. mhr: 1.0. {clamdscan: 0.101.4/26439} Clear:RC:1(10.200.1.25):SA:0(0.0/7.0):. Processed in 2.131342 secs; 17 Aug 2025 15:06:13 +0530 X-Spam-Level: X-Spam-Pyzor: Reported 0 times. X-Envelope-From: akhilesh@ee.iitb.ac.in X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received: from unknown (HELO ldns1.iitb.ac.in) (10.200.1.25) by ldns1.iitb.ac.in with SMTP; 17 Aug 2025 15:06:11 +0530 Received: from bhairav.ee.iitb.ac.in (bhairav.ee.iitb.ac.in [10.107.1.1]) by ldns1.iitb.ac.in (Postfix) with ESMTP id 5FC76360040; Sun, 17 Aug 2025 15:06:11 +0530 (IST) Received: from bhairav-test.ee.iitb.ac.in (bhairav.ee.iitb.ac.in [10.107.1.1]) (Authenticated sender: akhilesh) by bhairav.ee.iitb.ac.in (Postfix) with ESMTPSA id 4AF6E1E812D4; Sun, 17 Aug 2025 15:06:11 +0530 (IST) Date: Sun, 17 Aug 2025 15:06:05 +0530 From: Akhilesh Patil To: ming.lei@redhat.com, shuah@kernel.org, axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, akhileshpatilvnit@gmail.com Subject: [PATCH] selftests: ublk: Use ARRAY_SIZE() macro to improve code Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use ARRAY_SIZE() macro while calculating size of an array to improve code readability and reduce potential sizing errors. Implement this suggestion given by spatch tool by running coccinelle script - scripts/coccinelle/misc/array_size.cocci Follow ARRAY_SIZE() macro usage pattern in ublk.c introduced by, commit ec120093180b9 ("selftests: ublk: fix ublk_find_tgt()") wherever appropriate to maintain consistency. Signed-off-by: Akhilesh Patil Reviewed-by: Ming Lei --- Testing: * build checked for testing/selftests/ublk * tested by running=20 $ ./kublk --help Which exercises the impacted code path. tools/testing/selftests/ublk/kublk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests= /ublk/kublk.c index 95188065b2e9..6512dfbdbce3 100644 --- a/tools/testing/selftests/ublk/kublk.c +++ b/tools/testing/selftests/ublk/kublk.c @@ -1400,7 +1400,7 @@ static int cmd_dev_get_features(void) =20 if (!((1ULL << i) & features)) continue; - if (i < sizeof(feat_map) / sizeof(feat_map[0])) + if (i < ARRAY_SIZE(feat_map)) feat =3D feat_map[i]; else feat =3D "unknown"; @@ -1477,7 +1477,7 @@ static void __cmd_create_help(char *exe, bool recover= y) printf("\tdefault: nr_queues=3D2(max 32), depth=3D128(max 1024), dev_id= =3D-1(auto allocation)\n"); printf("\tdefault: nthreads=3Dnr_queues"); =20 - for (i =3D 0; i < sizeof(tgt_ops_list) / sizeof(tgt_ops_list[0]); i++) { + for (i =3D 0; i < ARRAY_SIZE(tgt_ops_list); i++) { const struct ublk_tgt_ops *ops =3D tgt_ops_list[i]; =20 if (ops->usage) --=20 2.34.1