Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: ublk: Use ARRAY_SIZE() macro to improve code

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 <akhilesh@ee.iitb.ac.in>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/aKGihYui6/Pcijbk@bhairav-test.ee.iitb.ac.in
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Akhilesh Patil and committed by
Jens Axboe
0227af35 8f5845e0

+2 -2
+2 -2
tools/testing/selftests/ublk/kublk.c
··· 1400 1400 1401 1401 if (!((1ULL << i) & features)) 1402 1402 continue; 1403 - if (i < sizeof(feat_map) / sizeof(feat_map[0])) 1403 + if (i < ARRAY_SIZE(feat_map)) 1404 1404 feat = feat_map[i]; 1405 1405 else 1406 1406 feat = "unknown"; ··· 1477 1477 printf("\tdefault: nr_queues=2(max 32), depth=128(max 1024), dev_id=-1(auto allocation)\n"); 1478 1478 printf("\tdefault: nthreads=nr_queues"); 1479 1479 1480 - for (i = 0; i < sizeof(tgt_ops_list) / sizeof(tgt_ops_list[0]); i++) { 1480 + for (i = 0; i < ARRAY_SIZE(tgt_ops_list); i++) { 1481 1481 const struct ublk_tgt_ops *ops = tgt_ops_list[i]; 1482 1482 1483 1483 if (ops->usage)