This error is seen in build of type "minsize":

In function 'rte_ml_dev_pmd_allocate':
lib/mldev/rte_mldev.c:84:16: error:
'dev' may be used uninitialized [-Werror=maybe-uninitialized]
   84 |         if (dev->data == NULL) {
      |             ~~~^~~~~~

It looks to be a compiler issue because we are not supposed
to reach this point without finding a device to assign.

The variable is initialized to allow compiling with "minsize" option.

Signed-off-by: Thomas Monjalon <[email protected]>
---
 lib/mldev/rte_mldev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c
index f5061f015c..7fae867882 100644
--- a/lib/mldev/rte_mldev.c
+++ b/lib/mldev/rte_mldev.c
@@ -55,7 +55,7 @@ rte_ml_dev_pmd_allocate(const char *name, uint8_t socket_id)
 {
        char mz_name[RTE_MEMZONE_NAMESIZE];
        const struct rte_memzone *mz;
-       struct rte_ml_dev *dev;
+       struct rte_ml_dev *dev = NULL;
        int16_t dev_id;
 
        /* implicit initialization of library before adding first device */
-- 
2.52.0

Reply via email to