DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sarosh Arif <sarosh.arif@emumba.com>
To: dev@dpdk.org, reshma.pattan@intel.com
Cc: Sarosh Arif <sarosh.arif@emumba.com>
Subject: [dpdk-dev] [PATCH] examples/packet_ordering: fix return value of parse_portmask
Date: Fri,  5 Jun 2020 18:41:14 +0500	[thread overview]
Message-ID: <20200605134114.23149-1-sarosh.arif@emumba.com> (raw)

Giving invalid or zero portmask as command line option to 
packet_ordering application will have an unexpected response.
The reason behind this is that parse_portmask's return value is
stored in a variable called portmask.The data type of portmask 
is unsigned int, hence returning -1 in case of zero or invalid
portmask causes an unexpected behaviour. 
If we return 0 instead of -1 this issue can be resolved.
The program already contains the functionality to print
"invalid portmask" and program usage if portmask is zero.

Fixes: 850f3733f840 ("examples/packet_ordering: new sample app")

Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
---
 examples/packet_ordering/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c
index edaf810d9..b5fc6c54b 100644
--- a/examples/packet_ordering/main.c
+++ b/examples/packet_ordering/main.c
@@ -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;
 }
-- 
2.17.1


             reply	other threads:[~2020-06-05 13:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 13:41 Sarosh Arif [this message]
2020-07-30 21:18 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200605134114.23149-1-sarosh.arif@emumba.com \
    --to=sarosh.arif@emumba.com \
    --cc=dev@dpdk.org \
    --cc=reshma.pattan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).