[dpdk-dev,v1,1/1] examples/bond: fix unchecked return value

Message ID 1467206138-153175-1-git-send-email-piotrx.t.azarewicz@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Piotr Azarewicz June 29, 2016, 1:15 p.m. UTC
  The example is calling rte_eal_wait_lcore without checking return value.
Now it is fixed by checking the value and print proper message.

Coverity issue: 37789
Coverity issue: 37790
Fixes: cc7e8ae84faa ("examples/bond: add example application for link bonding mode 6")

Signed-off-by: Piotr Azarewicz <piotrx.t.azarewicz@intel.com>
---
 examples/bond/main.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
  

Comments

Piotr Azarewicz June 30, 2016, 10:46 a.m. UTC | #1
> The example is calling rte_eal_wait_lcore without checking return value.
> Now it is fixed by checking the value and print proper message.
> 
> Coverity issue: 37789
> Coverity issue: 37790
> Fixes: cc7e8ae84faa ("examples/bond: add example application for link
> bonding mode 6")
> 
> Signed-off-by: Piotr Azarewicz <piotrx.t.azarewicz@intel.com>

As you may see its acked by Declan:
http://article.gmane.org/gmane.comp.networking.dpdk.devel/43015

Sorry for my issue with email.

Acked-by: Declan Doherty <declan.doherty@intel.com>
  

Patch

diff --git a/examples/bond/main.c b/examples/bond/main.c
index 53bd044..776fad0 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -590,10 +590,14 @@  static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
 		return;
 	}
 	global_flag_stru_p->LcoreMainIsRunning = 0;
-	rte_eal_wait_lcore(global_flag_stru_p->LcoreMainCore);
-	cmdline_printf(cl,
-			"lcore_main stopped on core:%d\n",
-			global_flag_stru_p->LcoreMainCore);
+	if (rte_eal_wait_lcore(global_flag_stru_p->LcoreMainCore) < 0)
+		cmdline_printf(cl,
+				"error: lcore_main can not stop on core:%d\n",
+				global_flag_stru_p->LcoreMainCore);
+	else
+		cmdline_printf(cl,
+				"lcore_main stopped on core:%d\n",
+				global_flag_stru_p->LcoreMainCore);
 	rte_spinlock_unlock(&global_flag_stru_p->lock);
 }
 
@@ -628,10 +632,14 @@  static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
 		return;
 	}
 	global_flag_stru_p->LcoreMainIsRunning = 0;
-	rte_eal_wait_lcore(global_flag_stru_p->LcoreMainCore);
-	cmdline_printf(cl,
-			"lcore_main stopped on core:%d\n",
-			global_flag_stru_p->LcoreMainCore);
+	if (rte_eal_wait_lcore(global_flag_stru_p->LcoreMainCore) < 0)
+		cmdline_printf(cl,
+				"error: lcore_main can not stop on core:%d\n",
+				global_flag_stru_p->LcoreMainCore);
+	else
+		cmdline_printf(cl,
+				"lcore_main stopped on core:%d\n",
+				global_flag_stru_p->LcoreMainCore);
 	rte_spinlock_unlock(&global_flag_stru_p->lock);
 	cmdline_quit(cl);
 }