[dpdk-dev] [PATCH v5 3/4] examples/multi_process/client_server_mp/mp_server: fix style

David Marchand david.marchand at redhat.com
Fri Aug 2 13:09:34 CEST 2019


On Fri, Aug 2, 2019 at 4:59 AM Stephen Hemminger
<stephen at networkplumber.org> wrote:
>
> Lots of little style complaints from checkpatch.
>
> Signed-off-by: Stephen Hemminger <stephen at 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)


uint16_t

See build error at
http://mails.dpdk.org/archives/test-report/2019-August/092150.html


-- 
David Marchand


More information about the dev mailing list