Lots of little style complaints from checkpatch.

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
 .../client_server_mp/mp_server/args.c         | 37 ++++-----
 .../client_server_mp/mp_server/init.c         | 79 +++++++++++--------
 .../client_server_mp/mp_server/main.c         | 44 ++++++-----
 3 files changed, 88 insertions(+), 72 deletions(-)

diff --git a/examples/multi_process/client_server_mp/mp_server/args.c 
b/examples/multi_process/client_server_mp/mp_server/args.c
index fdc008b3d677..91c823856a72 100644
--- a/examples/multi_process/client_server_mp/mp_server/args.c
+++ b/examples/multi_process/client_server_mp/mp_server/args.c
@@ -112,33 +112,34 @@ parse_app_args(int argc, char *argv[])
        progname = argv[0];
 
        while ((opt = getopt_long(argc, argvopt, "n:p:", lgopts,
-               &option_index)) != EOF){
-               switch (opt){
-                       case 'p':
-                               if (parse_portmask(optarg) != 0) {
-                                       usage();
-                                       return -1;
-                               }
-                               break;
-                       case 'n':
-                               if (parse_num_clients(optarg) != 0){
-                                       usage();
-                                       return -1;
-                               }
-                               break;
-                       default:
-                               printf("ERROR: Unknown option '%c'\n", opt);
+                                 &option_index)) != EOF) {
+
+               switch (opt) {
+               case 'p':
+                       if (parse_portmask(optarg) != 0) {
+                               usage();
+                               return -1;
+                       }
+                       break;
+               case 'n':
+                       if (parse_num_clients(optarg) != 0) {
                                usage();
                                return -1;
+                       }
+                       break;
+               default:
+                       printf("ERROR: Unknown option '%c'\n", opt);
+                       usage();
+                       return -1;
                }
        }
 
-       if (ports->num_ports == 0 || num_clients == 0){
+       if (ports->num_ports == 0 || num_clients == 0) {
                usage();
                return -1;
        }
 
-       if (ports->num_ports % 2 != 0){
+       if (ports->num_ports % 2 != 0) {
                printf("ERROR: application requires an even number of ports to 
use\n");
                return -1;
        }
diff --git a/examples/multi_process/client_server_mp/mp_server/init.c 
b/examples/multi_process/client_server_mp/mp_server/init.c
index 1b0569937b51..96c35f220a7d 100644
--- a/examples/multi_process/client_server_mp/mp_server/init.c
+++ b/examples/multi_process/client_server_mp/mp_server/init.c
@@ -49,7 +49,7 @@
 struct rte_mempool *pktmbuf_pool;
 
 /* array of info/queues for clients */
-struct client *clients = NULL;
+struct client *clients;
 
 /* the port details */
 struct port_info *ports;
@@ -72,7 +72,8 @@ init_mbuf_pools(void)
                num_mbufs_server + num_mbufs_client + num_mbufs_mp_cache;
 
        /* don't pass single-producer/single-consumer flags to mbuf create as it
-        * seems faster to use a cache instead */
+        * seems faster to use a cache instead
+        */
        printf("Creating mbuf pool '%s' [%u mbufs] ...\n",
                        PKTMBUF_POOL_NAME, num_mbufs);
        pktmbuf_pool = rte_pktmbuf_pool_create(PKTMBUF_POOL_NAME, num_mbufs,
@@ -108,9 +109,11 @@ init_port(uint16_t port_num)
        fflush(stdout);
 
        /* Standard DPDK port initialisation - config port, then set up
-        * rx and tx rings */
-       if ((retval = rte_eth_dev_configure(port_num, rx_rings, tx_rings,
-               &port_conf)) != 0)
+        * rx and tx rings
+        */
+       retval = rte_eth_dev_configure(port_num, rx_rings, tx_rings,
+                                      &port_conf);
+       if (retval != 0)
                return retval;
 
        retval = rte_eth_dev_adjust_nb_rx_tx_desc(port_num, &rx_ring_size,
@@ -122,22 +125,25 @@ init_port(uint16_t port_num)
                retval = rte_eth_rx_queue_setup(port_num, q, rx_ring_size,
                                rte_eth_dev_socket_id(port_num),
                                NULL, pktmbuf_pool);
-               if (retval < 0) return retval;
+               if (retval < 0)
+                       return retval;
        }
 
-       for ( q = 0; q < tx_rings; q ++ ) {
+       for (q = 0; q < tx_rings; q++) {
                retval = rte_eth_tx_queue_setup(port_num, q, tx_ring_size,
                                rte_eth_dev_socket_id(port_num),
                                NULL);
-               if (retval < 0) return retval;
+               if (retval < 0)
+                       return retval;
        }
 
        rte_eth_promiscuous_enable(port_num);
 
        retval  = rte_eth_dev_start(port_num);
-       if (retval < 0) return retval;
+       if (retval < 0)
+               return retval;
 
-       printf( "done: \n");
+       printf("done:\n");
 
        return 0;
 }
@@ -150,15 +156,15 @@ init_port(uint16_t port_num)
 static int
 init_shm_rings(void)
 {
-       unsigned i;
-       unsigned socket_id;
-       const char * q_name;
-       const unsigned ringsize = CLIENT_QUEUE_RINGSIZE;
+       unsigned int i, socket_id;
+       const char *q_name;
+       const unsigned int ringsize = CLIENT_QUEUE_RINGSIZE;
 
        clients = rte_malloc("client details",
                sizeof(*clients) * num_clients, 0);
        if (clients == NULL)
-               rte_exit(EXIT_FAILURE, "Cannot allocate memory for client 
program details\n");
+               rte_exit(EXIT_FAILURE,
+                        "Cannot allocate memory for client program details\n");
 
        for (i = 0; i < num_clients; i++) {
                /* Create an RX queue for each client */
@@ -166,13 +172,27 @@ init_shm_rings(void)
                q_name = get_rx_queue_name(i);
                clients[i].rx_q = rte_ring_create(q_name,
                                ringsize, socket_id,
-                               RING_F_SP_ENQ | RING_F_SC_DEQ ); /* single 
prod, single cons */
+                               RING_F_SP_ENQ | RING_F_SC_DEQ);
                if (clients[i].rx_q == NULL)
-                       rte_exit(EXIT_FAILURE, "Cannot create rx ring queue for 
client %u\n", i);
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot create rx ring queue for client %u\n",
+                                i);
        }
        return 0;
 }
 
+static void
+print_link_status(uint16 id, const struct rte_eth_link *link)
+{
+       if (link->link_status)
+               printf("Port %d Link Up - speed %u Mbps - %s-duplex\n",
+                      id, link->link_speed,
+                      (link->link_duplex == ETH_LINK_FULL_DUPLEX) ?
+                      "full" : "half");
+       else
+               printf("Port %d Link Down\n", id);
+}
+
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
 check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
@@ -192,21 +212,11 @@ check_all_ports_link_status(uint16_t port_num, uint32_t 
port_mask)
                                continue;
                        memset(&link, 0, sizeof(link));
                        rte_eth_link_get_nowait(ports->id[portid], &link);
+
                        /* print link status if flag set */
-                       if (print_flag == 1) {
-                               if (link.link_status)
-                                       printf("Port %d Link Up - speed %u "
-                                               "Mbps - %s\n", 
ports->id[portid],
-                                               (unsigned)link.link_speed,
-                               (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-                                       ("full-duplex") : ("half-duplex\n"));
-                               else
-                                       printf("Port %d Link Down\n",
-                                               (uint8_t)ports->id[portid]);
-                               continue;
-                       }
-                       /* clear all_ports_up flag if any link down */
-                       if (link.link_status == ETH_LINK_DOWN) {
+                       if (print_flag == 1)
+                               print_link_status(&link);
+                       else if (link.link_status == ETH_LINK_DOWN) {
                                all_ports_up = 0;
                                break;
                        }
@@ -251,7 +261,8 @@ init(int argc, char *argv[])
        mz = rte_memzone_reserve(MZ_PORT_INFO, sizeof(*ports),
                                rte_socket_id(), NO_FLAGS);
        if (mz == NULL)
-               rte_exit(EXIT_FAILURE, "Cannot reserve memory zone for port 
information\n");
+               rte_exit(EXIT_FAILURE,
+                        "Cannot reserve memory zone for port information\n");
        memset(mz->addr, 0, sizeof(*ports));
        ports = mz->addr;
 
@@ -269,8 +280,8 @@ init(int argc, char *argv[])
        for (i = 0; i < ports->num_ports; i++) {
                retval = init_port(ports->id[i]);
                if (retval != 0)
-                       rte_exit(EXIT_FAILURE, "Cannot initialise port %u\n",
-                                       (unsigned)i);
+                       rte_exit(EXIT_FAILURE,
+                                "Cannot initialise port %u\n", i);
        }
 
        check_all_ports_link_status(ports->num_ports, (~0x0));
diff --git a/examples/multi_process/client_server_mp/mp_server/main.c 
b/examples/multi_process/client_server_mp/mp_server/main.c
index 0150533700f0..bfec0bef3a71 100644
--- a/examples/multi_process/client_server_mp/mp_server/main.c
+++ b/examples/multi_process/client_server_mp/mp_server/main.c
@@ -64,8 +64,9 @@ get_printable_mac_addr(uint16_t port)
 
        if (unlikely(port >= RTE_MAX_ETHPORTS))
                return err_address;
-       if (unlikely(addresses[port][0]=='\0')){
+       if (unlikely(addresses[port][0] == '\0')) {
                struct rte_ether_addr mac;
+
                rte_eth_macaddr_get(port, &mac);
                snprintf(addresses[port], sizeof(addresses[port]),
                                "%02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -85,9 +86,9 @@ get_printable_mac_addr(uint16_t port)
 static void
 do_stats_display(void)
 {
-       unsigned i, j;
+       unsigned int i, j;
        const char clr[] = { 27, '[', '2', 'J', '\0' };
-       const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' };
+       const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' };
        uint64_t port_tx[RTE_MAX_ETHPORTS], port_tx_drop[RTE_MAX_ETHPORTS];
        uint64_t client_tx[MAX_CLIENTS], client_tx_drop[MAX_CLIENTS];
 
@@ -97,12 +98,14 @@ do_stats_display(void)
        memset(client_tx, 0, sizeof(client_tx));
        memset(client_tx_drop, 0, sizeof(client_tx_drop));
 
-       for (i = 0; i < num_clients; i++){
+       for (i = 0; i < num_clients; i++) {
                const volatile struct tx_stats *tx = &ports->tx_stats[i];
-               for (j = 0; j < ports->num_ports; j++){
+
+               for (j = 0; j < ports->num_ports; j++) {
                        /* assign to local variables here, save re-reading 
volatile vars */
                        const uint64_t tx_val = tx->tx[ports->id[j]];
                        const uint64_t drop_val = tx->tx_drop[ports->id[j]];
+
                        port_tx[j] += tx_val;
                        port_tx_drop[j] += drop_val;
                        client_tx[i] += tx_val;
@@ -116,21 +119,21 @@ do_stats_display(void)
        printf("PORTS\n");
        printf("-----\n");
        for (i = 0; i < ports->num_ports; i++)
-               printf("Port %u: '%s'\t", (unsigned)ports->id[i],
-                               get_printable_mac_addr(ports->id[i]));
+               printf("Port %u: '%s'\t", ports->id[i],
+                      get_printable_mac_addr(ports->id[i]));
        printf("\n\n");
-       for (i = 0; i < ports->num_ports; i++){
-               printf("Port %u - rx: %9"PRIu64"\t"
-                               "tx: %9"PRIu64"\n",
-                               (unsigned)ports->id[i], ports->rx_stats.rx[i],
+       for (i = 0; i < ports->num_ports; i++) {
+               printf("Port %u - rx: %9"PRIu64"\ttx: %9"PRIu64"\n",
+                               ports->id[i], ports->rx_stats.rx[i],
                                port_tx[i]);
        }
 
        printf("\nCLIENTS\n");
        printf("-------\n");
-       for (i = 0; i < num_clients; i++){
+       for (i = 0; i < num_clients; i++) {
                const unsigned long long rx = clients[i].stats.rx;
                const unsigned long long rx_drop = clients[i].stats.rx_drop;
+
                printf("Client %2u - rx: %9llu, rx_drop: %9llu\n"
                                "            tx: %9"PRIu64", tx_drop: 
%9"PRIu64"\n",
                                i, rx, rx_drop, client_tx[i], 
client_tx_drop[i]);
@@ -153,7 +156,8 @@ sleep_lcore(__attribute__((unused)) void *dummy)
 
        /* Only one core should display stats */
        if (rte_atomic32_test_and_set(&display_stats)) {
-               const unsigned sleeptime = 1;
+               const unsigned int sleeptime = 1;
+
                printf("Core %u displaying statistics\n", rte_lcore_id());
 
                /* Longer initial pause so above printf is seen */
@@ -173,7 +177,7 @@ sleep_lcore(__attribute__((unused)) void *dummy)
 static void
 clear_stats(void)
 {
-       unsigned i;
+       unsigned int i;
 
        for (i = 0; i < num_clients; i++)
                clients[i].stats.rx = clients[i].stats.rx_drop = 0;
@@ -194,12 +198,11 @@ flush_rx_queue(uint16_t client)
 
        cl = &clients[client];
        if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[client].buffer,
-                       cl_rx_buf[client].count, NULL) == 0){
+                       cl_rx_buf[client].count, NULL) == 0) {
                for (j = 0; j < cl_rx_buf[client].count; j++)
                        rte_pktmbuf_free(cl_rx_buf[client].buffer[j]);
                cl->stats.rx_drop += cl_rx_buf[client].count;
-       }
-       else
+       } else
                cl->stats.rx += cl_rx_buf[client].count;
 
        cl_rx_buf[client].count = 0;
@@ -243,14 +246,14 @@ process_packets(uint32_t port_num __rte_unused,
 static void
 do_packet_forwarding(void)
 {
-       unsigned port_num = 0; /* indexes the port[] array */
+       unsigned int port_num = 0; /* indexes the port[] array */
 
        for (;;) {
                struct rte_mbuf *buf[PACKET_READ_SIZE];
                uint16_t rx_count;
 
                /* read a port */
-               rx_count = rte_eth_rx_burst(ports->id[port_num], 0, \
+               rx_count = rte_eth_rx_burst(ports->id[port_num], 0,
                                buf, PACKET_READ_SIZE);
                ports->rx_stats.rx[port_num] += rx_count;
 
@@ -281,8 +284,9 @@ int
 main(int argc, char *argv[])
 {
        signal(SIGINT, signal_handler);
+
        /* initialise the system */
-       if (init(argc, argv) < 0 )
+       if (init(argc, argv) < 0)
                return -1;
        RTE_LOG(INFO, APP, "Finished Process Init.\n");
 
-- 
2.20.1

Reply via email to