[1/4] mldev: remove unnecessary null free checks
Checks
Commit Message
These are places where mldev is doing unnecessary checks
for calling free() style functions.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-mldev/test_device_ops.c | 6 ++----
app/test-mldev/test_inference_common.c | 24 ++++++++----------------
app/test-mldev/test_model_ops.c | 6 ++----
lib/mldev/rte_mldev.c | 3 +--
4 files changed, 13 insertions(+), 26 deletions(-)
Comments
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: 23 March 2023 06:34
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Srikanth
> Yalavarthi <syalavarthi@marvell.com>; Srikanth Yalavarthi
> <syalavarthi@marvell.com>
> Subject: [EXT] [PATCH 1/4] mldev: remove unnecessary null free checks
>
> External Email
>
> ----------------------------------------------------------------------
> These are places where mldev is doing unnecessary checks for calling free()
> style functions.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
@@ -70,8 +70,7 @@ test_device_setup(struct ml_test *test, struct ml_options *opt)
return 0;
error:
- if (test_device != NULL)
- rte_free(test_device);
+ rte_free(test_device);
return ret;
}
@@ -84,8 +83,7 @@ test_device_destroy(struct ml_test *test, struct ml_options *opt)
RTE_SET_USED(opt);
t = ml_test_priv(test);
- if (t != NULL)
- rte_free(t);
+ rte_free(t);
}
static int
@@ -492,8 +492,7 @@ test_inference_setup(struct ml_test *test, struct ml_options *opt)
return 0;
error:
- if (test_inference != NULL)
- rte_free(test_inference);
+ rte_free(test_inference);
return ret;
}
@@ -506,8 +505,7 @@ test_inference_destroy(struct ml_test *test, struct ml_options *opt)
RTE_SET_USED(opt);
t = ml_test_priv(test);
- if (t != NULL)
- rte_free(t);
+ rte_free(t);
}
int
@@ -748,8 +746,7 @@ ml_inference_iomem_destroy(struct ml_test *test, struct ml_options *opt, uint16_
/* destroy io pool */
sprintf(mp_name, "ml_io_pool_%d", fid);
mp = rte_mempool_lookup(mp_name);
- if (mp != NULL)
- rte_mempool_free(mp);
+ rte_mempool_free(mp);
}
int
@@ -776,8 +773,7 @@ ml_inference_mem_destroy(struct ml_test *test, struct ml_options *opt)
RTE_SET_USED(opt);
/* release op pool */
- if (t->op_pool != NULL)
- rte_mempool_free(t->op_pool);
+ rte_mempool_free(t->op_pool);
}
static bool
@@ -1088,11 +1084,9 @@ ml_inference_stats_get(struct ml_test *test, struct ml_options *opt)
print_line(80);
/* release buffers */
- if (t->xstats_map)
- rte_free(t->xstats_map);
+ rte_free(t->xstats_map);
- if (t->xstats_values)
- rte_free(t->xstats_values);
+ rte_free(t->xstats_values);
/* print end-to-end stats */
freq = rte_get_tsc_hz();
@@ -1129,11 +1123,9 @@ ml_inference_stats_get(struct ml_test *test, struct ml_options *opt)
return 0;
error:
- if (t->xstats_map)
- rte_free(t->xstats_map);
+ rte_free(t->xstats_map);
- if (t->xstats_values)
- rte_free(t->xstats_values);
+ rte_free(t->xstats_values);
return ret;
}
@@ -93,8 +93,7 @@ test_model_ops_setup(struct ml_test *test, struct ml_options *opt)
return 0;
error:
- if (test_model_ops != NULL)
- rte_free(test_model_ops);
+ rte_free(test_model_ops);
return ret;
}
@@ -107,8 +106,7 @@ test_model_ops_destroy(struct ml_test *test, struct ml_options *opt)
RTE_SET_USED(opt);
t = ml_test_priv(test);
- if (t != NULL)
- rte_free(t);
+ rte_free(t);
}
static int
@@ -836,8 +836,7 @@ rte_ml_op_pool_create(const char *name, unsigned int nb_elts, unsigned int cache
void
rte_ml_op_pool_free(struct rte_mempool *mempool)
{
- if (mempool != NULL)
- rte_mempool_free(mempool);
+ rte_mempool_free(mempool);
}
uint16_t