From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A5FB43E83; Tue, 16 Apr 2024 17:21:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3DD614067E; Tue, 16 Apr 2024 17:21:33 +0200 (CEST) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 0AE3F4028B for ; Tue, 16 Apr 2024 17:21:30 +0200 (CEST) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1e36b7e7dd2so36423785ad.1 for ; Tue, 16 Apr 2024 08:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713280889; x=1713885689; darn=dpdk.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=SXf8rsNlxTg2W7+ABh5D0c+4+ybfcOuKiyiT8vTpnzs=; b=KdvOpikWXenNLfG42RXHFtDv/xH1qwf1/JVnyL1J6LOlvKWt2ORI6SbGXPUNZejr5G ZeF//l5FKBByskKTPMy9P8rDmaQ8RJL5LTaPt3BwWRJALN+y37D0hpeC7vNOw0G4EPBc mrRnYnbvf/XMRGATf5KoXFkfcWzV+vrzLrH7DfRvoN6/Xqp3IRLpJJngyW69AEwEdAR8 tlcXlp74d/L04lfXznJcjZyMdZ4U+s8tD17yg3sXlQ9gXlqCUDAIysx0Rc5zei/qfPZr XYWqXJI1YNigsf+GwCROIzXvEyYl++28U9DalvBrVC0QaCBQ7g0BuArgAVao76sKcdqP 1H5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713280889; x=1713885689; 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=SXf8rsNlxTg2W7+ABh5D0c+4+ybfcOuKiyiT8vTpnzs=; b=gJFTPDh7rdiOQZv/atMzlgoIvjorAtjR13e8GCdVl9dim7nX0rEpK3snBr2l1e2pm0 bgu34/w/0II5WWYp+/vGiWkVw4MLoqsNszMNRRP+x+Os5qxL7oE6r5j2xYXvKNhFu2rA vxPa9qfs+LfRjpvkRXp7CnwJA/n6w1Wg66zqc+lTJMlIuITqzEMyPMZgJjTpzKKXqOP6 rUCxoeb5XiYT6FHxSOLtzI9NoaEBwGgjqM6GfUBT8O/95bQN7lGTF8sj5aREu0k4HUVA SwTgIP+1rXyCPgHSiEZIgwIAQKMy+jaGt37NZCvPekYpCVSv2hDDsVopGXdMAZ7a368D t6zw== X-Gm-Message-State: AOJu0YyqUHLaPfZtQSkjeCOBNVRS7CidGh9/neet3o3YP9ePxH1uneoA 5PdD9qLbC6hVoQYoL4+y0QopW8hTRUuBnWGlMyy1Vj2AIhs3G/vjDs0RfXD0paps6pC+U8Bvo0e N X-Google-Smtp-Source: AGHT+IEmu1MPAYs31frjDXDcqX7oeXbghW4k2rZFPUqk+Tl8kcKlei7pwxzjYSu96mnorR2oqgC7gA== X-Received: by 2002:a17:902:d50a:b0:1e5:b82:3c24 with SMTP id b10-20020a170902d50a00b001e50b823c24mr13677225plg.53.1713280889183; Tue, 16 Apr 2024 08:21:29 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id l17-20020a170903245100b001e80154a400sm213348pls.126.2024.04.16.08.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 08:21:28 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Wisam Jaddo , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Akhil Goyal , Anoob Joseph Subject: [PATCH 2/5] app: use RTE_DIM Date: Tue, 16 Apr 2024 08:19:28 -0700 Message-ID: <20240416152124.69590-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416152124.69590-1-stephen@networkplumber.org> References: <20240416152124.69590-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Use RTE_DIM instead of computing directly with sizeof. Patch automatically generated via cocci/rte_dim.cocci. Signed-off-by: Stephen Hemminger --- app/test-flow-perf/main.c | 4 +-- app/test/test_ethdev_link.c | 3 +- app/test/test_security_inline_macsec.c | 47 +++++++++++++------------- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index e224ef6798..e9ef1ae04c 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -965,9 +965,7 @@ args_parse(int argc, char **argv) "meter-profile") == 0) { i = 0; token = strsep(&optarg, ",\0"); - while (token != NULL && i < sizeof( - meter_profile_values) / - sizeof(uint64_t)) { + while (token != NULL && i < RTE_DIM(meter_profile_values)) { meter_profile_values[i++] = atol(token); token = strsep(&optarg, ",\0"); } diff --git a/app/test/test_ethdev_link.c b/app/test/test_ethdev_link.c index f063a5fe26..e305df71be 100644 --- a/app/test/test_ethdev_link.c +++ b/app/test/test_ethdev_link.c @@ -135,8 +135,7 @@ test_link_speed_all_values(void) { "Invalid", 50505 } }; - for (i = 0; i < sizeof(speed_str_map) / sizeof(struct link_speed_t); - i++) { + for (i = 0; i < RTE_DIM(speed_str_map); i++) { speed = rte_eth_link_speed_to_str(speed_str_map[i].link_speed); TEST_ASSERT_BUFFERS_ARE_EQUAL(speed_str_map[i].value, speed, strlen(speed_str_map[i].value), diff --git a/app/test/test_security_inline_macsec.c b/app/test/test_security_inline_macsec.c index f11e9da8c3..26f7504dc2 100644 --- a/app/test/test_security_inline_macsec.c +++ b/app/test/test_security_inline_macsec.c @@ -1294,7 +1294,7 @@ test_inline_macsec_encap_all(void) opts.sectag_insert_mode = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_cipher_vectors[i]; err = test_macsec(&cur_td, MCS_ENCAP, &opts); @@ -1332,7 +1332,7 @@ test_inline_macsec_decap_all(void) opts.sectag_insert_mode = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_cipher_vectors[i]; err = test_macsec(&cur_td, MCS_DECAP, &opts); @@ -1371,7 +1371,7 @@ test_inline_macsec_auth_only_all(void) opts.sectag_insert_mode = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); + size = RTE_DIM(list_mcs_integrity_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_integrity_vectors[i]; @@ -1410,7 +1410,7 @@ test_inline_macsec_verify_only_all(void) opts.sectag_insert_mode = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); + size = RTE_DIM(list_mcs_integrity_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_integrity_vectors[i]; @@ -1451,7 +1451,7 @@ test_inline_macsec_encap_decap_all(void) opts.sectag_insert_mode = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_cipher_vectors[i]; @@ -1492,7 +1492,7 @@ test_inline_macsec_auth_verify_all(void) opts.sectag_insert_mode = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); + size = RTE_DIM(list_mcs_integrity_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_integrity_vectors[i]; @@ -1578,7 +1578,7 @@ test_inline_macsec_with_vlan(void) opts.nb_td = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_vlan_vectors) / sizeof((list_mcs_vlan_vectors)[0])); + size = RTE_DIM(list_mcs_vlan_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_vlan_vectors[i]; @@ -1653,7 +1653,7 @@ test_inline_macsec_pkt_drop(void) opts.sectag_insert_mode = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_err_cipher_vectors) / sizeof((list_mcs_err_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_err_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_err_cipher_vectors[i]; @@ -1693,8 +1693,7 @@ test_inline_macsec_untagged_rx(void) opts.mtu = RTE_ETHER_MTU; opts.check_untagged_rx = 1; - size = (sizeof(list_mcs_untagged_cipher_vectors) / - sizeof((list_mcs_untagged_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_untagged_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_untagged_cipher_vectors[i]; @@ -1747,7 +1746,7 @@ test_inline_macsec_bad_tag_rx(void) opts.mtu = RTE_ETHER_MTU; opts.check_bad_tag_cnt = 1; - size = (sizeof(list_mcs_bad_tag_vectors) / sizeof((list_mcs_bad_tag_vectors)[0])); + size = RTE_DIM(list_mcs_bad_tag_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_bad_tag_vectors[i]; @@ -1786,7 +1785,7 @@ test_inline_macsec_sa_not_in_use(void) opts.mtu = RTE_ETHER_MTU; opts.check_sa_not_in_use = 1; - size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_cipher_vectors[i]; @@ -1825,7 +1824,7 @@ test_inline_macsec_decap_stats(void) opts.mtu = RTE_ETHER_MTU; opts.check_decap_stats = 1; - size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_cipher_vectors[i]; @@ -1866,7 +1865,7 @@ test_inline_macsec_verify_only_stats(void) opts.mtu = RTE_ETHER_MTU; opts.check_verify_only_stats = 1; - size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); + size = RTE_DIM(list_mcs_integrity_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_integrity_vectors[i]; @@ -1906,7 +1905,7 @@ test_inline_macsec_pkts_invalid_stats(void) opts.sectag_insert_mode = 1; opts.mtu = RTE_ETHER_MTU; - size = (sizeof(list_mcs_err_cipher_vectors) / sizeof((list_mcs_err_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_err_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_err_cipher_vectors[i]; @@ -1943,7 +1942,7 @@ test_inline_macsec_pkts_unchecked_stats(void) opts.mtu = RTE_ETHER_MTU; opts.check_pkts_unchecked_stats = 1; - size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); + size = RTE_DIM(list_mcs_integrity_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_integrity_vectors[i]; @@ -1982,7 +1981,7 @@ test_inline_macsec_out_pkts_untagged(void) opts.mtu = RTE_ETHER_MTU; opts.check_out_pkts_untagged = 1; - size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_cipher_vectors[i]; err = test_macsec(&cur_td, MCS_ENCAP, &opts); @@ -2020,7 +2019,7 @@ test_inline_macsec_out_pkts_toolong(void) opts.mtu = 50; opts.check_out_pkts_toolong = 1; - size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_cipher_vectors[i]; err = test_macsec(&cur_td, MCS_ENCAP, &opts); @@ -2058,7 +2057,7 @@ test_inline_macsec_encap_stats(void) opts.mtu = RTE_ETHER_MTU; opts.check_encap_stats = 1; - size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0])); + size = RTE_DIM(list_mcs_cipher_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_cipher_vectors[i]; err = test_macsec(&cur_td, MCS_ENCAP, &opts); @@ -2095,7 +2094,7 @@ test_inline_macsec_auth_only_stats(void) opts.mtu = RTE_ETHER_MTU; opts.check_auth_only_stats = 1; - size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0])); + size = RTE_DIM(list_mcs_integrity_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_integrity_vectors[i]; @@ -2146,7 +2145,7 @@ test_inline_macsec_interrupts_all(void) rte_eth_dev_callback_register(port_id, RTE_ETH_EVENT_MACSEC, test_macsec_event_callback, &err_vector); - size = (sizeof(list_mcs_intr_test_vectors) / sizeof((list_mcs_intr_test_vectors)[0])); + size = RTE_DIM(list_mcs_intr_test_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_intr_test_vectors[i]; @@ -2194,7 +2193,7 @@ test_inline_macsec_rekey_tx(void) opts.mtu = RTE_ETHER_MTU; opts.rekey_en = 1; - size = (sizeof(list_mcs_rekey_vectors) / sizeof((list_mcs_rekey_vectors)[0])); + size = RTE_DIM(list_mcs_rekey_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_rekey_vectors[i]; @@ -2236,7 +2235,7 @@ test_inline_macsec_rekey_rx(void) opts.mtu = RTE_ETHER_MTU; opts.rekey_en = 1; - size = (sizeof(list_mcs_rekey_vectors) / sizeof((list_mcs_rekey_vectors)[0])); + size = RTE_DIM(list_mcs_rekey_vectors); for (i = 0; i < size; i++) { cur_td = &list_mcs_rekey_vectors[i]; opts.rekey_td = &list_mcs_rekey_vectors[++i]; @@ -2277,7 +2276,7 @@ test_inline_macsec_anti_replay(void) opts.sectag_insert_mode = 1; opts.replay_protect = 1; - size = (sizeof(list_mcs_anti_replay_vectors) / sizeof((list_mcs_anti_replay_vectors)[0])); + size = RTE_DIM(list_mcs_anti_replay_vectors); for (j = 0; j < 2; j++) { opts.replay_win_sz = replay_win_sz[j]; -- 2.43.0