dpdkstat: refactored pipe error checking
authorMaryam Tahhan <maryam.tahhan@intel.com>
Tue, 7 Jun 2016 11:46:52 +0000 (12:46 +0100)
committerKim Jones <kim-marie.jones@intel.com>
Thu, 28 Jul 2016 12:23:46 +0000 (13:23 +0100)
This commit cleans up and fixes the pipe creation, and improves the
error checking.

Change-Id: I53de4a7ff450aea349971f58fe5cce8904da1e89
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
src/dpdkstat.c

index 903523f..e5aafde 100644 (file)
@@ -342,11 +342,16 @@ static int dpdk_helper_spawn(enum DPDK_HELPER_ACTION action)
     return -1;
   }
 
-  int pipe0_flags = fcntl(g_configuration->helper_pipes[1], F_GETFL, 0);
-  int pipe1_flags = fcntl(g_configuration->helper_pipes[0], F_GETFL, 0);
-  int p1err = fcntl(g_configuration->helper_pipes[1], F_SETFL, pipe1_flags | O_NONBLOCK);
-  int p2err = fcntl(g_configuration->helper_pipes[0], F_SETFL, pipe0_flags | O_NONBLOCK);
-  if (pipe0_flags == -1 || pipe1_flags == -1 || p1err == -1 || p2err == -1) {
+  int pipe0_flags = fcntl(g_configuration->helper_pipes[0], F_GETFL, 0);
+  int pipe1_flags = fcntl(g_configuration->helper_pipes[1], F_GETFL, 0);
+  if (pipe0_flags == -1 || pipe1_flags == -1) {
+    ERROR("dpdkstat: error setting up pipe flags: %s\n", strerror(errno));
+  }
+  int  pipe0_err = fcntl(g_configuration->helper_pipes[0], F_SETFL, pipe1_flags
+                         | O_NONBLOCK);
+  int  pipe1_err = fcntl(g_configuration->helper_pipes[1], F_SETFL, pipe0_flags
+                         | O_NONBLOCK);
+  if (pipe0_err == -1 || pipe1_err == -1) {
     ERROR("dpdkstat: error setting up pipes: %s\n", strerror(errno));
   }