From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH 3/3] dma/idxd: use DPDK basename function
Date: Wed, 6 Aug 2025 13:38:33 +0000 [thread overview]
Message-ID: <20250806133833.3236170-4-bruce.richardson@intel.com> (raw)
In-Reply-To: <20250806133833.3236170-1-bruce.richardson@intel.com>
Even though the idxd_bus.c file is linux-only, we can simplify the code
through using rte_basename rather than just basename. Since rte_basename
does not modify its parameter, we can eliminate the strdup and free, and
since it also handles NULL sanely, we can remove an extra NULL check.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/dma/idxd/idxd_bus.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c
index ba8076715d..5ae42151e6 100644
--- a/drivers/dma/idxd/idxd_bus.c
+++ b/drivers/dma/idxd/idxd_bus.c
@@ -260,17 +260,14 @@ static int search_devargs(const char *name)
static int
is_for_this_process_use(struct rte_dsa_device *dev, const char *name)
{
- char *runtime_dir = strdup(rte_eal_get_runtime_dir());
+ char prefix[256];
int retval = 0;
- int prefixlen;
- char *prefix;
+ size_t prefixlen;
- if (runtime_dir == NULL)
+ prefixlen = rte_basename(rte_eal_get_runtime_dir(), prefix, sizeof(prefix));
+ if (prefixlen >= sizeof(prefix) || strcmp(prefix, ".") == 0)
return retval;
- prefix = basename(runtime_dir);
- prefixlen = strlen(prefix);
-
if (strncmp(name, "dpdk_", 5) == 0)
retval = 1;
if (strncmp(name, prefix, prefixlen) == 0 && name[prefixlen] == '_')
@@ -283,7 +280,6 @@ is_for_this_process_use(struct rte_dsa_device *dev, const char *name)
retval = !search_devargs(dev->device.name);
}
- free(runtime_dir);
return retval;
}
--
2.48.1
prev parent reply other threads:[~2025-08-06 13:39 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 ` [PATCH 1/3] app: use cross-platform basename function Bruce Richardson
2025-08-06 13:38 ` [PATCH 2/3] eal: use common " Bruce Richardson
2025-08-06 13:38 ` Bruce Richardson [this message]
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-4-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).