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: [PATCH 1/3] app: use cross-platform basename function
Date: Wed,  6 Aug 2025 13:38:31 +0000	[thread overview]
Message-ID: <20250806133833.3236170-2-bruce.richardson@intel.com> (raw)
In-Reply-To: <20250806133833.3236170-1-bruce.richardson@intel.com>

Replace use of the Linux/BSD-only basename function with "rte_basename".
Since the DPDK basename function is guaranteed to do a copy into the
destination buffer of known length, we can sometimes simplify the code,
or make it safer, as part of this change.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test-dma-perf/main.c | 6 +++---
 app/test/process.h       | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c
index 0586b3e1d0..3ad66637e6 100644
--- a/app/test-dma-perf/main.c
+++ b/app/test-dma-perf/main.c
@@ -549,13 +549,13 @@ main(int argc, char *argv[])
 		return -1;
 	}
 	if (rst_path_ptr == NULL) {
-		strlcpy(rst_path, cfg_path_ptr, PATH_MAX);
-		char *token = strtok(basename(rst_path), ".");
+		rte_basename(cfg_path_ptr, rst_path, sizeof(rst_path));
+		char *token = strtok(rst_path, ".");
 		if (token == NULL) {
 			printf("Config file error.\n");
 			return -1;
 		}
-		strcat(token, "_result.csv");
+		strlcat(token, "_result.csv", sizeof(rst_path));
 		rst_path_ptr = rst_path;
 	}
 
diff --git a/app/test/process.h b/app/test/process.h
index 9fb2bf481c..0dba48aa18 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -217,7 +217,7 @@ get_current_prefix(char *prefix, int size)
 		return NULL;
 
 	/* get the prefix */
-	snprintf(prefix, size, "%s", basename(dirname(buf)));
+	rte_basename(dirname(buf), prefix, size);
 
 	return prefix;
 }
-- 
2.48.1


  reply	other threads:[~2025-08-06 13:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 13:38 [PATCH 0/3] Use cross-platform rte_basename function Bruce Richardson
2025-08-06 13:38 ` Bruce Richardson [this message]
2025-08-06 13:38 ` [PATCH 2/3] eal: use common basename function Bruce Richardson
2025-08-06 13:38 ` [PATCH 3/3] dma/idxd: use DPDK " 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=20250806133833.3236170-2-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).