X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fload_balancer%2Fconfig.c;h=07f92a1ab89005b21461ce30d7183d58bc0208be;hb=708bac973a0a5c146962affc160a1436ff471bfa;hp=1e14bede94d06a3562d17fb16a6ce3c61ed00d30;hpb=3b95eb689bdc0870fd5eb1653102bbd120f7aff6;p=dpdk.git diff --git a/examples/load_balancer/config.c b/examples/load_balancer/config.c index 1e14bede94..07f92a1ab8 100644 --- a/examples/load_balancer/config.c +++ b/examples/load_balancer/config.c @@ -1,35 +1,34 @@ /*- * BSD LICENSE - * - * Copyright(c) 2010-2012 Intel Corporation. All rights reserved. + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ #include @@ -49,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -65,7 +63,6 @@ #include #include #include -#include #include #include #include @@ -156,7 +153,7 @@ str_to_unsigned_array( int i, num_splits = 0; /* copy s so we don't modify original string */ - rte_snprintf(str, sizeof(str), "%s", s); + snprintf(str, sizeof(str), "%s", s); num_splits = rte_strsplit(str, sizeof(str), splits, num_vals, separator); errno = 0; @@ -233,7 +230,9 @@ parse_arg_rx(const char *arg) return -7; } lp->type = e_APP_LCORE_IO; - for (i = 0; i < lp->io.rx.n_nic_queues; i ++) { + const size_t n_queues = RTE_MIN(lp->io.rx.n_nic_queues, + RTE_DIM(lp->io.rx.nic_queues)); + for (i = 0; i < n_queues; i ++) { if ((lp->io.rx.nic_queues[i].port == port) && (lp->io.rx.nic_queues[i].queue == queue)) { return -8; @@ -310,7 +309,9 @@ parse_arg_tx(const char *arg) return -7; } lp->type = e_APP_LCORE_IO; - for (i = 0; i < lp->io.tx.n_nic_ports; i ++) { + const size_t n_ports = RTE_MIN(lp->io.tx.n_nic_ports, + RTE_DIM(lp->io.tx.nic_ports)); + for (i = 0; i < n_ports; i ++) { if (lp->io.tx.nic_ports[i] == port) { return -8; } @@ -757,7 +758,7 @@ app_parse_args(int argc, char **argv) argv[optind - 1] = prgname; ret = optind - 1; - optind = 0; /* reset getopt lib */ + optind = 1; /* reset getopt lib */ return ret; } @@ -793,7 +794,9 @@ app_get_lcore_for_nic_rx(uint8_t port, uint8_t queue, uint32_t *lcore_out) continue; } - for (i = 0; i < lp->rx.n_nic_queues; i ++) { + const size_t n_queues = RTE_MIN(lp->rx.n_nic_queues, + RTE_DIM(lp->rx.nic_queues)); + for (i = 0; i < n_queues; i ++) { if ((lp->rx.nic_queues[i].port == port) && (lp->rx.nic_queues[i].queue == queue)) { *lcore_out = lcore; @@ -818,7 +821,9 @@ app_get_lcore_for_nic_tx(uint8_t port, uint32_t *lcore_out) continue; } - for (i = 0; i < lp->tx.n_nic_ports; i ++) { + const size_t n_ports = RTE_MIN(lp->tx.n_nic_ports, + RTE_DIM(lp->tx.nic_ports)); + for (i = 0; i < n_ports; i ++) { if (lp->tx.nic_ports[i] == port) { *lcore_out = lcore; return 0;