DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [RFC PATCH v2 23/33] app/test-compress-perf: fix variable shadowing
Date: Fri,  7 Nov 2025 15:50:19 +0000	[thread overview]
Message-ID: <20251107155034.436809-24-bruce.richardson@intel.com> (raw)
In-Reply-To: <20251107155034.436809-1-bruce.richardson@intel.com>

Rename the parameter to 3 functions to avoid shadowing a global variable
of the same name.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test-compress-perf/main.c | 122 +++++++++++++++++-----------------
 1 file changed, 61 insertions(+), 61 deletions(-)

diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index 59af073f12..c9ead02cb4 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -53,33 +53,33 @@ static const struct cperf_test cperf_testmap[] = {
 static struct comp_test_data *test_data;
 
 static int
-comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)
+comp_perf_check_capabilities(struct comp_test_data *td, uint8_t cdev_id)
 {
 	const struct rte_compressdev_capabilities *cap;
 
-	cap = rte_compressdev_capability_get(cdev_id, test_data->test_algo);
+	cap = rte_compressdev_capability_get(cdev_id, td->test_algo);
 
 	if (cap == NULL) {
 		RTE_LOG(ERR, USER1,
 			"Compress device does not support %u algorithm\n",
-			test_data->test_algo);
+			td->test_algo);
 		return -1;
 	}
 
 	uint64_t comp_flags = cap->comp_feature_flags;
 
 	/* Algorithm type */
-	switch (test_data->test_algo) {
+	switch (td->test_algo) {
 	case RTE_COMP_ALGO_DEFLATE:
 		/* Huffman encoding */
-		if (test_data->huffman_enc == RTE_COMP_HUFFMAN_FIXED &&
+		if (td->huffman_enc == RTE_COMP_HUFFMAN_FIXED &&
 		    (comp_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0) {
 			RTE_LOG(ERR, USER1,
 				"Compress device does not supported Fixed Huffman\n");
 			return -1;
 		}
 
-		if (test_data->huffman_enc == RTE_COMP_HUFFMAN_DYNAMIC &&
+		if (td->huffman_enc == RTE_COMP_HUFFMAN_DYNAMIC &&
 		    (comp_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0) {
 			RTE_LOG(ERR, USER1,
 				"Compress device does not supported Dynamic Huffman\n");
@@ -88,14 +88,14 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)
 		break;
 	case RTE_COMP_ALGO_LZ4:
 		/* LZ4 flags */
-		if ((test_data->lz4_flags & RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM) &&
+		if ((td->lz4_flags & RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM) &&
 		    (comp_flags & RTE_COMP_FF_LZ4_BLOCK_WITH_CHECKSUM) == 0) {
 			RTE_LOG(ERR, USER1,
 				"Compress device does not support LZ4 block with checksum\n");
 			return -1;
 		}
 
-		if ((test_data->lz4_flags &
+		if ((td->lz4_flags &
 		     RTE_COMP_LZ4_FLAG_BLOCK_INDEPENDENCE) &&
 		    (comp_flags & RTE_COMP_FF_LZ4_BLOCK_INDEPENDENCE) == 0) {
 			RTE_LOG(ERR, USER1,
@@ -111,8 +111,8 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)
 	}
 
 	/* Window size */
-	if (test_data->window_sz != -1) {
-		if (param_range_check(test_data->window_sz, &cap->window_size)
+	if (td->window_sz != -1) {
+		if (param_range_check(td->window_sz, &cap->window_size)
 				< 0) {
 			RTE_LOG(ERR, USER1,
 				"Compress device does not support "
@@ -121,18 +121,18 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)
 		}
 	} else
 		/* Set window size to PMD maximum if none was specified */
-		test_data->window_sz = cap->window_size.max;
+		td->window_sz = cap->window_size.max;
 
 	/* Check if chained mbufs is supported */
-	if (test_data->max_sgl_segs > 1  &&
+	if (td->max_sgl_segs > 1  &&
 			(comp_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0) {
 		RTE_LOG(INFO, USER1, "Compress device does not support "
 				"chained mbufs. Max SGL segments set to 1\n");
-		test_data->max_sgl_segs = 1;
+		td->max_sgl_segs = 1;
 	}
 
 	/* Level 0 support */
-	if (test_data->level_lst.min == 0 &&
+	if (td->level_lst.min == 0 &&
 			(comp_flags & RTE_COMP_FF_NONCOMPRESSED_BLOCKS) == 0) {
 		RTE_LOG(ERR, USER1, "Compress device does not support "
 				"level 0 (no compression)\n");
@@ -143,19 +143,19 @@ comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)
 }
 
 static int
-comp_perf_initialize_compressdev(struct comp_test_data *test_data,
+comp_perf_initialize_compressdev(struct comp_test_data *td,
 				 uint8_t *enabled_cdevs)
 {
 	uint8_t enabled_cdev_count, nb_lcores, cdev_id;
 	unsigned int i, j;
 	int ret;
 
-	enabled_cdev_count = rte_compressdev_devices_get(test_data->driver_name,
+	enabled_cdev_count = rte_compressdev_devices_get(td->driver_name,
 			enabled_cdevs, RTE_COMPRESS_MAX_DEVS);
 	if (enabled_cdev_count == 0) {
 		RTE_LOG(ERR, USER1, "No compress devices type %s available,"
 				    " please check the list of specified devices in EAL section\n",
-				test_data->driver_name);
+				td->driver_name);
 		return -EINVAL;
 	}
 
@@ -186,13 +186,13 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,
 	 * 2 queue pairs will be set up per device but one queue pair
 	 * will left unused in the last one device
 	 */
-	test_data->nb_qps = (nb_lcores % enabled_cdev_count) ?
+	td->nb_qps = (nb_lcores % enabled_cdev_count) ?
 				(nb_lcores / enabled_cdev_count) + 1 :
 				nb_lcores / enabled_cdev_count;
 
 	for (i = 0; i < enabled_cdev_count &&
 			i < RTE_COMPRESS_MAX_DEVS; i++,
-					nb_lcores -= test_data->nb_qps) {
+					nb_lcores -= td->nb_qps) {
 		cdev_id = enabled_cdevs[i];
 
 		struct rte_compressdev_info cdev_info;
@@ -200,7 +200,7 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,
 
 		rte_compressdev_info_get(cdev_id, &cdev_info);
 		if (cdev_info.max_nb_queue_pairs &&
-			test_data->nb_qps > cdev_info.max_nb_queue_pairs) {
+			td->nb_qps > cdev_info.max_nb_queue_pairs) {
 			RTE_LOG(ERR, USER1,
 				"Number of needed queue pairs is higher "
 				"than the maximum number of queue pairs "
@@ -211,25 +211,25 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,
 			return -EINVAL;
 		}
 
-		if (comp_perf_check_capabilities(test_data, cdev_id) < 0)
+		if (comp_perf_check_capabilities(td, cdev_id) < 0)
 			return -EINVAL;
 
 		/* Configure compressdev */
 		struct rte_compressdev_config config = {
 			.socket_id = socket_id,
-			.nb_queue_pairs = nb_lcores > test_data->nb_qps
-					? test_data->nb_qps : nb_lcores,
+			.nb_queue_pairs = nb_lcores > td->nb_qps
+					? td->nb_qps : nb_lcores,
 			.max_nb_priv_xforms = NUM_MAX_XFORMS,
 			.max_nb_streams = 0
 		};
-		test_data->nb_qps = config.nb_queue_pairs;
+		td->nb_qps = config.nb_queue_pairs;
 
 		if (rte_compressdev_configure(cdev_id, &config) < 0) {
 			RTE_LOG(ERR, USER1, "Device configuration failed\n");
 			return -EINVAL;
 		}
 
-		for (j = 0; j < test_data->nb_qps; j++) {
+		for (j = 0; j < td->nb_qps; j++) {
 			ret = rte_compressdev_queue_pair_setup(cdev_id, j,
 					NUM_MAX_INFLIGHT_OPS, socket_id);
 			if (ret < 0) {
@@ -253,9 +253,9 @@ comp_perf_initialize_compressdev(struct comp_test_data *test_data,
 }
 
 static int
-comp_perf_dump_input_data(struct comp_test_data *test_data)
+comp_perf_dump_input_data(struct comp_test_data *td)
 {
-	FILE *f = fopen(test_data->input_file, "r");
+	FILE *f = fopen(td->input_file, "r");
 	int ret = -1;
 	size_t actual_file_sz, remaining_data;
 	uint8_t *data = NULL;
@@ -274,34 +274,34 @@ comp_perf_dump_input_data(struct comp_test_data *test_data)
 	 * input data size = file size
 	 */
 
-	if (test_data->input_data_sz == 0)
-		test_data->input_data_sz = actual_file_sz;
+	if (td->input_data_sz == 0)
+		td->input_data_sz = actual_file_sz;
 
-	if (test_data->input_data_sz <= 0 || actual_file_sz <= 0 ||
+	if (td->input_data_sz <= 0 || actual_file_sz <= 0 ||
 			fseek(f, 0, SEEK_SET) != 0) {
 		RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
 		goto end;
 	}
 
-	if (!(test_data->test_op & COMPRESS) &&
-	    test_data->input_data_sz >
-	    (size_t) test_data->seg_sz * (size_t) test_data->max_sgl_segs) {
+	if (!(td->test_op & COMPRESS) &&
+	    td->input_data_sz >
+	    (size_t) td->seg_sz * (size_t) td->max_sgl_segs) {
 		RTE_LOG(ERR, USER1,
 			"Size of input must be less than total segments\n");
 		goto end;
 	}
 
-	test_data->input_data = rte_zmalloc_socket(NULL,
-				test_data->input_data_sz, 0, rte_socket_id());
+	td->input_data = rte_zmalloc_socket(NULL,
+				td->input_data_sz, 0, rte_socket_id());
 
-	if (test_data->input_data == NULL) {
+	if (td->input_data == NULL) {
 		RTE_LOG(ERR, USER1, "Memory to hold the data from the input "
 				"file could not be allocated\n");
 		goto end;
 	}
 
-	remaining_data = test_data->input_data_sz;
-	data = test_data->input_data;
+	remaining_data = td->input_data_sz;
+	data = td->input_data;
 
 	while (remaining_data > 0) {
 		size_t data_to_read = RTE_MIN(remaining_data, actual_file_sz);
@@ -320,15 +320,15 @@ comp_perf_dump_input_data(struct comp_test_data *test_data)
 	}
 
 	printf("\n");
-	if (test_data->input_data_sz > actual_file_sz)
+	if (td->input_data_sz > actual_file_sz)
 		RTE_LOG(INFO, USER1,
 		  "%zu bytes read from file %s, extending the file %.2f times\n",
-			test_data->input_data_sz, test_data->input_file,
-			(double)test_data->input_data_sz/actual_file_sz);
+			td->input_data_sz, td->input_file,
+			(double)td->input_data_sz/actual_file_sz);
 	else
 		RTE_LOG(INFO, USER1,
 			"%zu bytes read from file %s\n",
-			test_data->input_data_sz, test_data->input_file);
+			td->input_data_sz, td->input_file);
 
 	ret = 0;
 
@@ -338,15 +338,15 @@ comp_perf_dump_input_data(struct comp_test_data *test_data)
 }
 
 static int
-comp_perf_dump_dictionary_data(struct comp_test_data *test_data)
+comp_perf_dump_dictionary_data(struct comp_test_data *td)
 {
-	FILE *f = fopen(test_data->dictionary_file, "r");
+	FILE *f = fopen(td->dictionary_file, "r");
 	int ret = -1;
 
 	if (f == NULL) {
 		RTE_LOG(ERR, USER1, "Dictionary file not specified\n");
-		test_data->dictionary_data_sz = 0;
-		test_data->dictionary_data = NULL;
+		td->dictionary_data_sz = 0;
+		td->dictionary_data = NULL;
 		ret = 0;
 		goto end;
 	}
@@ -367,40 +367,40 @@ comp_perf_dump_dictionary_data(struct comp_test_data *test_data)
 
 	size_t actual_file_sz = (size_t)file_sz;
 
-	if (test_data->dictionary_data_sz == 0)
-		test_data->dictionary_data_sz = actual_file_sz;
+	if (td->dictionary_data_sz == 0)
+		td->dictionary_data_sz = actual_file_sz;
 
 	if (fseek(f, 0, SEEK_SET) != 0) {
 		RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
 		goto end;
 	}
 
-	test_data->dictionary_data = rte_zmalloc_socket(NULL,
-				test_data->dictionary_data_sz, 0, rte_socket_id());
+	td->dictionary_data = rte_zmalloc_socket(NULL,
+				td->dictionary_data_sz, 0, rte_socket_id());
 
-	if (test_data->dictionary_data == NULL) {
+	if (td->dictionary_data == NULL) {
 		RTE_LOG(ERR, USER1, "Memory to hold the data from the dictionary "
 				"file could not be allocated\n");
 		goto end;
 	}
 
-	size_t remaining_data = test_data->dictionary_data_sz;
-	uint8_t *data = test_data->dictionary_data;
+	size_t remaining_data = td->dictionary_data_sz;
+	uint8_t *data = td->dictionary_data;
 
 	while (remaining_data > 0) {
 		size_t data_to_read = RTE_MIN(remaining_data, actual_file_sz);
 
 		if (fread(data, data_to_read, 1, f) != 1) {
 			RTE_LOG(ERR, USER1, "Input file could not be read\n");
-			if (test_data->dictionary_data)
-				rte_free(test_data->dictionary_data);
+			if (td->dictionary_data)
+				rte_free(td->dictionary_data);
 			goto end;
 		}
 		if (fseek(f, 0, SEEK_SET) != 0) {
 			RTE_LOG(ERR, USER1,
 				"Size of input could not be calculated\n");
-			if (test_data->dictionary_data)
-				rte_free(test_data->dictionary_data);
+			if (td->dictionary_data)
+				rte_free(td->dictionary_data);
 			goto end;
 		}
 		remaining_data -= data_to_read;
@@ -408,15 +408,15 @@ comp_perf_dump_dictionary_data(struct comp_test_data *test_data)
 	}
 
 	printf("\n");
-	if (test_data->dictionary_data_sz > actual_file_sz)
+	if (td->dictionary_data_sz > actual_file_sz)
 		RTE_LOG(INFO, USER1,
 		  "%zu bytes read from file %s, extending the file %.2f times\n",
-			test_data->dictionary_data_sz, test_data->dictionary_file,
-			(double)test_data->dictionary_data_sz/actual_file_sz);
+			td->dictionary_data_sz, td->dictionary_file,
+			(double)td->dictionary_data_sz/actual_file_sz);
 	else
 		RTE_LOG(INFO, USER1,
 			"%zu bytes read from file %s\n",
-			test_data->dictionary_data_sz, test_data->dictionary_file);
+			td->dictionary_data_sz, td->dictionary_file);
 
 	ret = 0;
 
-- 
2.48.1


  parent reply	other threads:[~2025-11-07 15:53 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 14:09 [RFC PATCH 00/19] Fix building much of DPDK with -Wshadow Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 01/19] eal: fix variable shadowing Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 02/19] ethdev: fix variable shadowing issues Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 03/19] eventdev: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 04/19] net: remove shadowed variable Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 05/19] graph: fix variable shadowing errors Bruce Richardson
2025-11-06 15:50   ` Stephen Hemminger
2025-11-06 16:33     ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 06/19] pipeline: fix variable shadowing Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 07/19] table: fix issues with " Bruce Richardson
2025-11-06 19:37   ` Stephen Hemminger
2025-11-06 19:58     ` Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 08/19] power: rename variable to eliminate shadowing Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 09/19] pcapng: rename variable to fix shadowing Bruce Richardson
2025-11-06 15:51   ` Stephen Hemminger
2025-11-06 14:09 ` [RFC PATCH 10/19] telemetry: make socket handler typedef private Bruce Richardson
2025-11-07  2:43   ` fengchengwen
2025-11-06 14:09 ` [RFC PATCH 11/19] bbdev: fix variable shadowing Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 12/19] bus/pci: remove shadowed variables Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 13/19] net/intel: rename function param to avoid shadow warnings Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 14/19] net/e1000: fix build with shadow warnings enabled Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 15/19] net/i40e: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 16/19] net/ice: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 17/19] net/cpfl: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 18/19] net/ixgbe: " Bruce Richardson
2025-11-06 14:09 ` [RFC PATCH 19/19] app/test-pmd: " Bruce Richardson
2025-11-07 15:49 ` [RFC PATCH v2 00/33] build DPDK with -Wshadow Bruce Richardson
2025-11-07 15:49   ` [RFC PATCH v2 01/33] eal: add more min/max helpers Bruce Richardson
2025-11-07 15:49   ` [RFC PATCH v2 02/33] eal: fix variable shadowing Bruce Richardson
2025-11-07 15:49   ` [RFC PATCH v2 03/33] ethdev: fix variable shadowing issues Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 04/33] eventdev: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 05/33] net: remove shadowed variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 06/33] pipeline: fix variable shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 07/33] table: fix issues with " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 08/33] power: rename variable to eliminate shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 09/33] pcapng: rename variable to fix shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 10/33] telemetry: make socket handler typedef private Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 11/33] bbdev: fix variable shadowing Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 12/33] bus/pci: remove shadowed variables Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 13/33] net/intel: rename function param to avoid shadow warnings Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 14/33] net/e1000: fix build with shadow warnings enabled Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 15/33] net/i40e: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 16/33] net/ice: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 17/33] net/cpfl: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 18/33] net/ixgbe: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 19/33] app/test-pmd: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 20/33] app/graph: " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 21/33] app/pdump: fix warning about shadowed variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 22/33] app/test-bbdev: use RTE_MAX3 to remove variable shadowing Bruce Richardson
2025-11-07 15:50   ` Bruce Richardson [this message]
2025-11-07 15:50   ` [RFC PATCH v2 24/33] app/test-crypto-perf: fix shadowed variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 25/33] app/test-dma-perf: renamed " Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 26/33] app/test-eventdev: fix build with shadow warnings enabled Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 27/33] app/test-flow-perf: remove unneeded variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 28/33] app/test-security-perf: fix build with shadow warnings Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 29/33] app/test-pipeline: remove unnecessary variable Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 30/33] drivers: disable variable shadowing warnings for drivers Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 31/33] app/test: disable shadowing warnings for unit tests Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 32/33] examples: ignore variable shadowing warnings Bruce Richardson
2025-11-07 15:50   ` [RFC PATCH v2 33/33] build: enable shadowed variable warnings Bruce Richardson
2025-11-07 16:02   ` [RFC PATCH v2 00/33] build DPDK with -Wshadow Stephen Hemminger
2025-11-07 16:13     ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251107155034.436809-24-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).