[06/10] net/dpaa2: fix possible use of uninitialized vars

Message ID 20190905093239.27187-7-amo@semihalf.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Add an option to use LTO for DPDK build |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Andrzej Ostruszka Sept. 5, 2019, 9:32 a.m. UTC
  This patch fixes 'maybe-uninitialized' warnings reported by compiler
when using LTO.

Signed-off-by: Andrzej Ostruszka <aostruszka@marvell.com>
---
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 1 +
 drivers/net/dpaa2/mc/dpkg.c            | 2 +-
 drivers/net/dpaa2/mc/dpni.c            | 9 ++++++---
 3 files changed, 8 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
index 56e2e56a3..2f6534a31 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
@@ -51,6 +51,7 @@  rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
 	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_DATA;
 	kg_cfg.extracts[0].extract.from_data.offset = offset;
 	kg_cfg.extracts[0].extract.from_data.size = size;
+	kg_cfg.extracts[0].num_of_byte_masks = 0;
 	kg_cfg.num_extracts = 1;
 
 	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
diff --git a/drivers/net/dpaa2/mc/dpkg.c b/drivers/net/dpaa2/mc/dpkg.c
index 80f94f40e..7aa63ea12 100644
--- a/drivers/net/dpaa2/mc/dpkg.c
+++ b/drivers/net/dpaa2/mc/dpkg.c
@@ -63,7 +63,7 @@  dpkg_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, uint8_t *key_cfg_buf)
 		dpkg_set_field(extr->extract_type, EXTRACT_TYPE,
 			       cfg->extracts[i].type);
 
-		for (j = 0; j < DPKG_NUM_OF_MASKS; j++) {
+		for (j = 0; j < extr->num_of_byte_masks; j++) {
 			extr->masks[j].mask = cfg->extracts[i].masks[j].mask;
 			extr->masks[j].offset =
 				cfg->extracts[i].masks[j].offset;
diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c
index 362cd476f..b74a1a317 100644
--- a/drivers/net/dpaa2/mc/dpni.c
+++ b/drivers/net/dpaa2/mc/dpni.c
@@ -1803,10 +1803,13 @@  int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
 	cmd_params->qtype = qtype;
 	cmd_params->tc = tc_id;
 	cmd_params->congestion_point = cfg->cg_point;
-	cmd_params->cgid = (uint8_t)cfg->cgid;
-	cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
+	if (cfg->cg_point == DPNI_CP_CONGESTION_GROUP)
+		cmd_params->cgid = (uint8_t)cfg->cgid;
+	if (cfg->dest_cfg.dest_type != DPNI_DEST_NONE) {
+		cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
+		cmd_params->dest_priority = cfg->dest_cfg.priority;
+	}
 	cmd_params->notification_mode = cpu_to_le16(cfg->notification_mode);
-	cmd_params->dest_priority = cfg->dest_cfg.priority;
 	cmd_params->message_iova = cpu_to_le64(cfg->message_iova);
 	cmd_params->message_ctx = cpu_to_le64(cfg->message_ctx);
 	cmd_params->threshold_entry = cpu_to_le32(cfg->threshold_entry);