diff mbox

[PATCHv2] test: do not use negative array index

Message ID 1437063055-14984-1-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit d2b3247f56570cdeee0da660075bbe2fb8647d90
Headers show

Commit Message

Maxim Uvarov July 16, 2015, 4:10 p.m. UTC
odp_pktio_send() can return -1 error and that return code
can be used as array index in code bellow. On error just
increase drop counter and free packets.
https://bugs.linaro.org/show_bug.cgi?id=1688

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 example/packet/odp_pktio.c   | 1 +
 test/performance/odp_l2fwd.c | 1 +
 2 files changed, 2 insertions(+)

Comments

Bill Fischofer July 17, 2015, 3:55 a.m. UTC | #1
On Thursday, July 16, 2015, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> odp_pktio_send() can return -1 error and that return code
> can be used as array index in code bellow. On error just
> increase drop counter and free packets.
> https://bugs.linaro.org/show_bug.cgi?id=1688
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org <javascript:;>>


Reviewed-by: Bill Fischofer <bill.fischofe@linaro.org>

---
>  example/packet/odp_pktio.c   | 1 +
>  test/performance/odp_l2fwd.c | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
> index 8004d69..040571b 100644
> --- a/example/packet/odp_pktio.c
> +++ b/example/packet/odp_pktio.c
> @@ -291,6 +291,7 @@ static void *pktio_ifburst_thread(void *arg)
>                                 /* Swap Eth MACs and IP-addrs */
>                                 swap_pkt_addrs(pkt_tbl, pkts_ok);
>                                 sent = odp_pktio_send(pktio, pkt_tbl,
> pkts_ok);
> +                               sent = sent > 0 ? sent : 0;
>                                 if (odp_unlikely(sent < pkts_ok)) {
>                                         err_cnt += pkts_ok - sent;
>                                         do
> diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
> index 9cc201f..a408c7d 100644
> --- a/test/performance/odp_l2fwd.c
> +++ b/test/performance/odp_l2fwd.c
> @@ -231,6 +231,7 @@ static void *pktio_ifburst_thread(void *arg)
>                 if (pkts_ok > 0) {
>                         int sent = odp_pktio_send(pktio_dst, pkt_tbl,
> pkts_ok);
>
> +                       sent = sent > 0 ? sent : 0;
>                         if (odp_unlikely(sent < pkts_ok)) {
>                                 stats->drops += pkts_ok - sent;
>                                 do
> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org <javascript:;>
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov July 17, 2015, 10:04 a.m. UTC | #2
Merged,
Maxim.

On 07/17/15 06:55, Bill Fischofer wrote:
>
>
> On Thursday, July 16, 2015, Maxim Uvarov <maxim.uvarov@linaro.org 
> <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     odp_pktio_send() can return -1 error and that return code
>     can be used as array index in code bellow. On error just
>     increase drop counter and free packets.
>     https://bugs.linaro.org/show_bug.cgi?id=1688
>
>     Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org <javascript:;>>
>
>
> Reviewed-by: Bill Fischofer <bill.fischofe@linaro.org 
> <mailto:bill.fischofe@linaro.org>>
>
>     ---
>      example/packet/odp_pktio.c   | 1 +
>      test/performance/odp_l2fwd.c | 1 +
>      2 files changed, 2 insertions(+)
>
>     diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
>     index 8004d69..040571b 100644
>     --- a/example/packet/odp_pktio.c
>     +++ b/example/packet/odp_pktio.c
>     @@ -291,6 +291,7 @@ static void *pktio_ifburst_thread(void *arg)
>                                     /* Swap Eth MACs and IP-addrs */
>                                     swap_pkt_addrs(pkt_tbl, pkts_ok);
>                                     sent = odp_pktio_send(pktio,
>     pkt_tbl, pkts_ok);
>     +                               sent = sent > 0 ? sent : 0;
>                                     if (odp_unlikely(sent < pkts_ok)) {
>                                             err_cnt += pkts_ok - sent;
>                                             do
>     diff --git a/test/performance/odp_l2fwd.c
>     b/test/performance/odp_l2fwd.c
>     index 9cc201f..a408c7d 100644
>     --- a/test/performance/odp_l2fwd.c
>     +++ b/test/performance/odp_l2fwd.c
>     @@ -231,6 +231,7 @@ static void *pktio_ifburst_thread(void *arg)
>                     if (pkts_ok > 0) {
>                             int sent = odp_pktio_send(pktio_dst,
>     pkt_tbl, pkts_ok);
>
>     +                       sent = sent > 0 ? sent : 0;
>                             if (odp_unlikely(sent < pkts_ok)) {
>                                     stats->drops += pkts_ok - sent;
>                                     do
>     --
>     1.9.1
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <javascript:;>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 8004d69..040571b 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -291,6 +291,7 @@  static void *pktio_ifburst_thread(void *arg)
 				/* Swap Eth MACs and IP-addrs */
 				swap_pkt_addrs(pkt_tbl, pkts_ok);
 				sent = odp_pktio_send(pktio, pkt_tbl, pkts_ok);
+				sent = sent > 0 ? sent : 0;
 				if (odp_unlikely(sent < pkts_ok)) {
 					err_cnt += pkts_ok - sent;
 					do
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 9cc201f..a408c7d 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -231,6 +231,7 @@  static void *pktio_ifburst_thread(void *arg)
 		if (pkts_ok > 0) {
 			int sent = odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok);
 
+			sent = sent > 0 ? sent : 0;
 			if (odp_unlikely(sent < pkts_ok)) {
 				stats->drops += pkts_ok - sent;
 				do