* [PATCH] rawdev: fix device ID retrieval function prototype
@ 2025-09-24 5:56 Nawal Kishor
2025-10-15 15:05 ` Thomas Monjalon
0 siblings, 1 reply; 4+ messages in thread
From: Nawal Kishor @ 2025-09-24 5:56 UTC (permalink / raw)
To: dev, Sachin Saxena, Hemant Agrawal, Shreyansh Jain
Cc: jerinj, asekhar, Nawal Kishor
Fixed rte_rawdev_get_dev_id() function prototype and its usage.
Fixes: c88b3f2558ed ("rawdev: introduce raw device library")
Signed-off-by: Nawal Kishor <nkishor@marvell.com>
---
This patch fixes the return type of rte_rawdev_get_dev_id(). It would be good
to have it merged before the 25.11 release, as it corrects a user-visible API
bug and is a safe change.
app/test/test_rawdev.c | 11 +++++++++--
lib/rawdev/rte_rawdev.c | 2 +-
lib/rawdev/rte_rawdev.h | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/app/test/test_rawdev.c b/app/test/test_rawdev.c
index d34691dacf..d1d250c9ac 100644
--- a/app/test/test_rawdev.c
+++ b/app/test/test_rawdev.c
@@ -25,11 +25,18 @@ test_rawdev_selftests(void)
static int
test_rawdev_selftest_impl(const char *pmd, const char *opts)
{
- int ret;
+ int dev_id, ret;
printf("\n### Test rawdev infrastructure using skeleton driver\n");
rte_vdev_init(pmd, opts);
- ret = rte_rawdev_selftest(rte_rawdev_get_dev_id(pmd));
+ dev_id = rte_rawdev_get_dev_id(pmd);
+ if (dev_id < 0) {
+ printf("Failed to get dev_id for %s\n", pmd);
+ ret = dev_id;
+ goto exit;
+ }
+ ret = rte_rawdev_selftest(dev_id);
+exit:
rte_vdev_uninit(pmd);
return ret;
}
diff --git a/lib/rawdev/rte_rawdev.c b/lib/rawdev/rte_rawdev.c
index 4da7956d5a..f21d29114c 100644
--- a/lib/rawdev/rte_rawdev.c
+++ b/lib/rawdev/rte_rawdev.c
@@ -39,7 +39,7 @@ rte_rawdev_count(void)
}
RTE_EXPORT_SYMBOL(rte_rawdev_get_dev_id)
-uint16_t
+int
rte_rawdev_get_dev_id(const char *name)
{
uint16_t i;
diff --git a/lib/rawdev/rte_rawdev.h b/lib/rawdev/rte_rawdev.h
index 3fc471526e..ad849e5bea 100644
--- a/lib/rawdev/rte_rawdev.h
+++ b/lib/rawdev/rte_rawdev.h
@@ -44,7 +44,7 @@ rte_rawdev_count(void);
* Returns raw device identifier on success.
* - <0: Failure to find named raw device.
*/
-uint16_t
+int
rte_rawdev_get_dev_id(const char *name);
/**
--
2.48.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rawdev: fix device ID retrieval function prototype
2025-09-24 5:56 [PATCH] rawdev: fix device ID retrieval function prototype Nawal Kishor
@ 2025-10-15 15:05 ` Thomas Monjalon
2025-10-16 6:56 ` Nawal Kishor
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2025-10-15 15:05 UTC (permalink / raw)
To: Nawal Kishor
Cc: dev, Sachin Saxena, Hemant Agrawal, Shreyansh Jain, jerinj, asekhar
24/09/2025 07:56, Nawal Kishor:
> Fixed rte_rawdev_get_dev_id() function prototype and its usage.
What? Why?
[...]
> -uint16_t
> +int
> rte_rawdev_get_dev_id(const char *name);
Other functions handle dev_id as uint16_t, so why changing this function?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rawdev: fix device ID retrieval function prototype
2025-10-15 15:05 ` Thomas Monjalon
@ 2025-10-16 6:56 ` Nawal Kishor
2025-10-16 8:08 ` Thomas Monjalon
0 siblings, 1 reply; 4+ messages in thread
From: Nawal Kishor @ 2025-10-16 6:56 UTC (permalink / raw)
To: Thomas Monjalon
Cc: dev, Sachin Saxena, Hemant Agrawal, Shreyansh Jain, Jerin Jacob,
Ashwin Sekhar T K
>> Fixed rte_rawdev_get_dev_id() function prototype and its usage.
>
>What? Why?
>[...]
>> -uint16_t
>> +int
>> rte_rawdev_get_dev_id(const char *name);
>Other functions handle dev_id as uint16_t, so why changing this function?
The spec says that rte_rawdev_get_dev_id() returns negative number in case of failure.
But in the definition it is returning uint16_t which will never be negative, hence changed it to int.
If this is not acceptable, what fix will you suggest?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rawdev: fix device ID retrieval function prototype
2025-10-16 6:56 ` Nawal Kishor
@ 2025-10-16 8:08 ` Thomas Monjalon
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2025-10-16 8:08 UTC (permalink / raw)
To: Nawal Kishor
Cc: dev, Sachin Saxena, Hemant Agrawal, Shreyansh Jain, Jerin Jacob,
Ashwin Sekhar T K
16/10/2025 08:56, Nawal Kishor:
>
> >> Fixed rte_rawdev_get_dev_id() function prototype and its usage.
> >
> >What? Why?
>
> >[...]
> >> -uint16_t
> >> +int
> >> rte_rawdev_get_dev_id(const char *name);
>
> >Other functions handle dev_id as uint16_t, so why changing this function?
>
> The spec says that rte_rawdev_get_dev_id() returns negative number in case of failure.
> But in the definition it is returning uint16_t which will never be negative, hence changed it to int.
>
> If this is not acceptable, what fix will you suggest?
You should change to int16_t for all rawdev id parameters.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-16 8:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-24 5:56 [PATCH] rawdev: fix device ID retrieval function prototype Nawal Kishor
2025-10-15 15:05 ` Thomas Monjalon
2025-10-16 6:56 ` Nawal Kishor
2025-10-16 8:08 ` Thomas Monjalon
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).