From: Danylo Vodopianov <dvo-...@napatech.com>

convert_error func was removed as far as this approach was deprecated.

Coverity issue: 448973
Fixes: e526adf1fdef ("net/ntnic: add minimal create/destroy flow operations")

Signed-off-by: Danylo Vodopianov <dvo-...@napatech.com>
---
 drivers/net/ntnic/include/create_elements.h   |   1 -
 drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 151 ++++++------------
 2 files changed, 53 insertions(+), 99 deletions(-)

diff --git a/drivers/net/ntnic/include/create_elements.h 
b/drivers/net/ntnic/include/create_elements.h
index 1456977837..f0b9410cb9 100644
--- a/drivers/net/ntnic/include/create_elements.h
+++ b/drivers/net/ntnic/include/create_elements.h
@@ -61,7 +61,6 @@ enum nt_rte_flow_item_type {
 extern rte_spinlock_t flow_lock;
 
 int interpret_raw_data(uint8_t *data, uint8_t *preserve, int size, struct 
rte_flow_item *out);
-int convert_error(struct rte_flow_error *error, struct rte_flow_error 
*rte_flow_error);
 int create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr 
*attr);
 int create_match_elements(struct cnv_match_s *match, const struct 
rte_flow_item items[],
        int max_elem);
diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c 
b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
index b07e16c1d3..70bff776be 100644
--- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
+++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
@@ -246,23 +246,6 @@ int interpret_raw_data(uint8_t *data, uint8_t *preserve, 
int size, struct rte_fl
        return hdri + 1;
 }
 
-int convert_error(struct rte_flow_error *error, struct rte_flow_error 
*rte_flow_error)
-{
-       if (error) {
-               error->cause = NULL;
-               error->message = rte_flow_error->message;
-
-               if (rte_flow_error->type == RTE_FLOW_ERROR_TYPE_NONE ||
-                       rte_flow_error->type == RTE_FLOW_ERROR_TYPE_NONE)
-                       error->type = RTE_FLOW_ERROR_TYPE_NONE;
-
-               else
-                       error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED;
-       }
-
-       return 0;
-}
-
 int create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr *attr)
 {
        memset(&attribute->attr, 0x0, sizeof(struct rte_flow_attr));
@@ -497,13 +480,10 @@ static int convert_flow(struct rte_eth_dev *eth_dev,
        struct pmd_internals *internals = eth_dev->data->dev_private;
        struct fpga_info_s *fpga_info = 
&internals->p_drv->ntdrv.adapter_info.fpga_info;
 
-       static struct rte_flow_error flow_error = {
-               .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
        uint32_t queue_offset = 0;
 
-       /* Set initial error */
-       convert_error(error, &flow_error);
-
        if (!internals) {
                rte_flow_error_set(error, EINVAL, 
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
                        "Missing eth_dev");
@@ -559,23 +539,19 @@ eth_flow_destroy(struct rte_eth_dev *eth_dev, struct 
rte_flow *flow, struct rte_
 
        struct pmd_internals *internals = eth_dev->data->dev_private;
 
-       static struct rte_flow_error flow_error = {
-               .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
        int res = 0;
-       /* Set initial error */
-       convert_error(error, &flow_error);
 
        if (!flow)
                return 0;
 
        if (is_flow_handle_typecast(flow)) {
-               res = flow_filter_ops->flow_destroy(internals->flw_dev, (void 
*)flow, &flow_error);
-               convert_error(error, &flow_error);
+               res = flow_filter_ops->flow_destroy(internals->flw_dev, (void 
*)flow, error);
 
        } else {
                res = flow_filter_ops->flow_destroy(internals->flw_dev, 
flow->flw_hdl,
-                       &flow_error);
-               convert_error(error, &flow_error);
+                       error);
 
                rte_spinlock_lock(&flow_lock);
                flow->used = 0;
@@ -606,8 +582,8 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev 
*eth_dev,
        struct cnv_match_s match = { 0 };
        struct cnv_action_s action = { 0 };
 
-       static struct rte_flow_error flow_error = {
-               .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
        uint32_t flow_stat_id = 0;
 
        if (convert_flow(eth_dev, attr, items, actions, &attribute, &match, 
&action, error) < 0)
@@ -620,8 +596,7 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev 
*eth_dev,
                void *flw_hdl = 
flow_filter_ops->flow_create(internals->flw_dev, &attribute.attr,
                        attribute.forced_vlan_vid, attribute.caller_id,
                        match.rte_flow_item, action.flow_actions,
-                       &flow_error);
-               convert_error(error, &flow_error);
+                       error);
                return (struct rte_flow *)flw_hdl;
        }
 
@@ -648,8 +623,7 @@ static struct rte_flow *eth_flow_create(struct rte_eth_dev 
*eth_dev,
                flow->flw_hdl = 
flow_filter_ops->flow_create(internals->flw_dev, &attribute.attr,
                        attribute.forced_vlan_vid, attribute.caller_id,
                        match.rte_flow_item, action.flow_actions,
-                       &flow_error);
-               convert_error(error, &flow_error);
+                       error);
 
                if (!flow->flw_hdl) {
                        rte_spinlock_lock(&flow_lock);
@@ -678,14 +652,14 @@ static int eth_flow_flush(struct rte_eth_dev *eth_dev, 
struct rte_flow_error *er
 
        struct pmd_internals *internals = eth_dev->data->dev_private;
 
-       static struct rte_flow_error flow_error = {
-               .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
        int res = 0;
        /* Main application caller_id is port_id shifted above VDPA ports */
        uint16_t caller_id = get_caller_id(eth_dev->data->port_id);
 
        if (internals->flw_dev) {
-               res = flow_filter_ops->flow_flush(internals->flw_dev, 
caller_id, &flow_error);
+               res = flow_filter_ops->flow_flush(internals->flw_dev, 
caller_id, error);
                rte_spinlock_lock(&flow_lock);
 
                for (int flow = 0; flow < MAX_RTE_FLOWS; flow++) {
@@ -702,8 +676,6 @@ static int eth_flow_flush(struct rte_eth_dev *eth_dev, 
struct rte_flow_error *er
                rte_spinlock_unlock(&flow_lock);
        }
 
-       convert_error(error, &flow_error);
-
        return res;
 }
 
@@ -721,8 +693,8 @@ static int eth_flow_actions_update(struct rte_eth_dev 
*eth_dev,
 
        struct pmd_internals *internals = eth_dev->data->dev_private;
 
-       static struct rte_flow_error flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
        int res = -1;
 
        if (internals->flw_dev) {
@@ -756,18 +728,16 @@ static int eth_flow_actions_update(struct rte_eth_dev 
*eth_dev,
                        res = 
flow_filter_ops->flow_actions_update(internals->flw_dev,
                                        (void *)flow,
                                        action.flow_actions,
-                                       &flow_error);
+                                       error);
 
                } else {
                        res = 
flow_filter_ops->flow_actions_update(internals->flw_dev,
                                        flow->flw_hdl,
                                        action.flow_actions,
-                                       &flow_error);
+                                       error);
                }
        }
 
-       convert_error(error, &flow_error);
-
        return res;
 }
 
@@ -785,17 +755,16 @@ static int eth_flow_dev_dump(struct rte_eth_dev *eth_dev,
 
        struct pmd_internals *internals = eth_dev->data->dev_private;
 
-       static struct rte_flow_error flow_error = {
-               .type = RTE_FLOW_ERROR_TYPE_NONE, .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        uint16_t caller_id = get_caller_id(eth_dev->data->port_id);
 
        int res = flow_filter_ops->flow_dev_dump(internals->flw_dev,
                        is_flow_handle_typecast(flow) ? (void *)flow
                        : flow->flw_hdl,
-                       caller_id, file, &flow_error);
+                       caller_id, file, error);
 
-       convert_error(error, &flow_error);
        return res;
 }
 
@@ -813,16 +782,14 @@ static int eth_flow_get_aged_flows(struct rte_eth_dev 
*eth_dev,
 
        struct pmd_internals *internals = eth_dev->data->dev_private;
 
-       static struct rte_flow_error flow_error = {
-               .type = RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        uint16_t caller_id = get_caller_id(eth_dev->data->port_id);
 
        int res = flow_filter_ops->flow_get_aged_flows(internals->flw_dev, 
caller_id, context,
-                       nb_contexts, &flow_error);
+                       nb_contexts, error);
 
-       convert_error(error, &flow_error);
        return res;
 }
 
@@ -842,17 +809,15 @@ static int eth_flow_info_get(struct rte_eth_dev *dev, 
struct rte_flow_port_info
 
        struct pmd_internals *internals = dev->data->dev_private;
 
-       static struct rte_flow_error flow_error = {
-               .type = RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        int res = flow_filter_ops->flow_info_get(internals->flw_dev,
                        get_caller_id(dev->data->port_id),
                        (struct rte_flow_port_info *)port_info,
                        (struct rte_flow_queue_info *)queue_info,
-                       &flow_error);
+                       error);
 
-       convert_error(error, &flow_error);
        return res;
 }
 
@@ -869,18 +834,16 @@ static int eth_flow_configure(struct rte_eth_dev *dev, 
const struct rte_flow_por
 
        struct pmd_internals *internals = dev->data->dev_private;
 
-       static struct rte_flow_error flow_error = {
-               .type = RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        int res = flow_filter_ops->flow_configure(internals->flw_dev,
                        get_caller_id(dev->data->port_id),
                        (const struct rte_flow_port_attr *)port_attr,
                        nb_queue,
                        (const struct rte_flow_queue_attr **)queue_attr,
-                       &flow_error);
+                       error);
 
-       convert_error(error, &flow_error);
        return res;
 }
 
@@ -897,8 +860,8 @@ static struct rte_flow_pattern_template 
*eth_flow_pattern_template_create(struct
 
        struct pmd_internals *internals = dev->data->dev_private;
 
-       static struct rte_flow_error flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        struct cnv_match_s match = { 0 };
        struct rte_flow_pattern_template_attr attr = {
@@ -918,9 +881,8 @@ static struct rte_flow_pattern_template 
*eth_flow_pattern_template_create(struct
 
        struct flow_pattern_template *res =
                
flow_filter_ops->flow_pattern_template_create(internals->flw_dev, &attr, 
caller_id,
-                       match.rte_flow_item, &flow_error);
+                       match.rte_flow_item, error);
 
-       convert_error(error, &flow_error);
        return (struct rte_flow_pattern_template *)res;
 }
 
@@ -937,15 +899,14 @@ static int eth_flow_pattern_template_destroy(struct 
rte_eth_dev *dev,
 
        struct pmd_internals *internals = dev->data->dev_private;
 
-       static struct rte_flow_error rte_flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        int res = 
flow_filter_ops->flow_pattern_template_destroy(internals->flw_dev,
                        (struct flow_pattern_template *)
                        pattern_template,
-                       &rte_flow_error);
+                       error);
 
-       convert_error(error, &rte_flow_error);
        return res;
 }
 
@@ -964,8 +925,8 @@ static struct rte_flow_actions_template 
*eth_flow_actions_template_create(struct
        struct pmd_internals *internals = dev->data->dev_private;
 
        struct fpga_info_s *fpga_info = 
&internals->p_drv->ntdrv.adapter_info.fpga_info;
-       static struct rte_flow_error rte_flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        struct cnv_action_s action = { 0 };
        struct cnv_action_s mask = { 0 };
@@ -1004,9 +965,8 @@ static struct rte_flow_actions_template 
*eth_flow_actions_template_create(struct
        struct flow_actions_template *res =
                
flow_filter_ops->flow_actions_template_create(internals->flw_dev, &attr, 
caller_id,
                        action.flow_actions,
-                       mask.flow_actions, &rte_flow_error);
+                       mask.flow_actions, error);
 
-       convert_error(error, &rte_flow_error);
        return (struct rte_flow_actions_template *)res;
 }
 
@@ -1023,15 +983,14 @@ static int eth_flow_actions_template_destroy(struct 
rte_eth_dev *dev,
 
        struct pmd_internals *internals = dev->data->dev_private;
 
-       static struct rte_flow_error rte_flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        int res = 
flow_filter_ops->flow_actions_template_destroy(internals->flw_dev,
                        (struct flow_actions_template *)
                        actions_template,
-                       &rte_flow_error);
+                       error);
 
-       convert_error(error, &rte_flow_error);
        return res;
 }
 
@@ -1050,8 +1009,8 @@ static struct rte_flow_template_table 
*eth_flow_template_table_create(struct rte
 
        struct pmd_internals *internals = dev->data->dev_private;
 
-       static struct rte_flow_error rte_flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        struct rte_flow_template_table_attr attr = {
                .flow_attr = {
@@ -1071,9 +1030,8 @@ static struct rte_flow_template_table 
*eth_flow_template_table_create(struct rte
                        forced_vlan_vid, caller_id,
                        (struct flow_pattern_template **)pattern_templates,
                        nb_pattern_templates, (struct flow_actions_template 
**)actions_templates,
-                       nb_actions_templates, &rte_flow_error);
+                       nb_actions_templates, error);
 
-       convert_error(error, &rte_flow_error);
        return (struct rte_flow_template_table *)res;
 }
 
@@ -1090,15 +1048,14 @@ static int eth_flow_template_table_destroy(struct 
rte_eth_dev *dev,
 
        struct pmd_internals *internals = dev->data->dev_private;
 
-       static struct rte_flow_error rte_flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        int res = 
flow_filter_ops->flow_template_table_destroy(internals->flw_dev,
                        (struct flow_template_table *)
                        template_table,
-                       &rte_flow_error);
+                       error);
 
-       convert_error(error, &rte_flow_error);
        return res;
 }
 
@@ -1118,8 +1075,8 @@ static struct rte_flow *eth_flow_async_create(struct 
rte_eth_dev *dev, uint32_t
        struct pmd_internals *internals = dev->data->dev_private;
 
        struct fpga_info_s *fpga_info = 
&internals->p_drv->ntdrv.adapter_info.fpga_info;
-       static struct rte_flow_error rte_flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        struct cnv_action_s action = { 0 };
        struct cnv_match_s match = { 0 };
@@ -1159,9 +1116,8 @@ static struct rte_flow *eth_flow_async_create(struct 
rte_eth_dev *dev, uint32_t
                        action.flow_actions,
                        actions_template_index,
                        user_data,
-                       &rte_flow_error);
+                       error);
 
-       convert_error(error, &rte_flow_error);
        return (struct rte_flow *)res;
 }
 
@@ -1178,17 +1134,16 @@ static int eth_flow_async_destroy(struct rte_eth_dev 
*dev, uint32_t queue_id,
 
        struct pmd_internals *internals = dev->data->dev_private;
 
-       static struct rte_flow_error rte_flow_error = { .type = 
RTE_FLOW_ERROR_TYPE_NONE,
-               .message = "none" };
+       error->type = RTE_FLOW_ERROR_TYPE_NONE;
+       error->message = "none";
 
        int res = flow_filter_ops->flow_async_destroy(internals->flw_dev,
                        queue_id,
                        (const struct rte_flow_op_attr *)op_attr,
                        (struct flow_handle *)flow,
                        user_data,
-                       &rte_flow_error);
+                       error);
 
-       convert_error(error, &rte_flow_error);
        return res;
 }
 
-- 
2.45.0

Reply via email to