examples/packet_ordering: use proper exit method
[dpdk.git] / examples / packet_ordering / main.c
index a99961f..b5fc6c5 100644 (file)
@@ -143,10 +143,7 @@ parse_portmask(const char *portmask)
        /* parse hexadecimal string */
        pm = strtoul(portmask, &end, 16);
        if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
-               return -1;
-
-       if (pm == 0)
-               return -1;
+               return 0;
 
        return pm;
 }
@@ -322,7 +319,13 @@ configure_eth_port(uint16_t port_id)
        if (ret < 0)
                return ret;
 
-       rte_eth_macaddr_get(port_id, &addr);
+       ret = rte_eth_macaddr_get(port_id, &addr);
+       if (ret != 0) {
+               printf("Failed to get MAC address (port %u): %s\n",
+                               port_id, rte_strerror(-ret));
+               return ret;
+       }
+
        printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
                        " %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
                        port_id,
@@ -330,7 +333,9 @@ configure_eth_port(uint16_t port_id)
                        addr.addr_bytes[2], addr.addr_bytes[3],
                        addr.addr_bytes[4], addr.addr_bytes[5]);
 
-       rte_eth_promiscuous_enable(port_id);
+       ret = rte_eth_promiscuous_enable(port_id);
+       if (ret != 0)
+               return ret;
 
        return 0;
 }
@@ -667,7 +672,7 @@ main(int argc, char **argv)
        /* Initialize EAL */
        ret = rte_eal_init(argc, argv);
        if (ret < 0)
-               return -1;
+               rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
 
        argc -= ret;
        argv += ret;
@@ -675,7 +680,7 @@ main(int argc, char **argv)
        /* Parse the application specific arguments */
        ret = parse_args(argc, argv);
        if (ret < 0)
-               return -1;
+               rte_exit(EXIT_FAILURE, "Invalid packet_ordering arguments\n");
 
        /* Check if we have enought cores */
        if (rte_lcore_count() < 3)