[v3] app/testpmd: fix return value in portlist parser

Message ID 1582220343-22149-1-git-send-email-hariprasad.govindharajan@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v3] app/testpmd: fix return value in portlist parser |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail apply issues
ci/travis-robot warning Travis build: failed

Commit Message

Hariprasad Govindharajan Feb. 20, 2020, 5:39 p.m. UTC
  The function parse_port_list() is designed to return
unsigned int value. After sanitizing the inputs,
it is returning -1. Changed it to return 0.

Fixes: 2df00d562d20 ("app/testpmd: add --portlist option")
Cc: hariprasad.govindharajan@intel.com

Signed-off-by: Hariprasad Govindharajan <hariprasad.govindharajan@intel.com>
---
v3:
corrected the documentation comments.
updated the comments on return values.

v2:
modified the head line in the patch
---
 app/test-pmd/config.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
  

Comments

Ferruh Yigit Feb. 20, 2020, 8:41 p.m. UTC | #1
On 2/20/2020 5:39 PM, Hariprasad Govindharajan wrote:
> The function parse_port_list() is designed to return
> unsigned int value. After sanitizing the inputs,
> it is returning -1. Changed it to return 0.
> 
> Fixes: 2df00d562d20 ("app/testpmd: add --portlist option")
> Cc: hariprasad.govindharajan@intel.com
> 
> Signed-off-by: Hariprasad Govindharajan <hariprasad.govindharajan@intel.com>

(Carrying ack from previous version)
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 9d95202..e9b89c4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2616,9 +2616,6 @@  set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt)
  *   If the user wants to use only the ports 1,2 then the input
  *   is 1,2.
  *   valid characters are '-' and ','
- *   invalid chars like '.' or '#' will result in
- *   EAL: Error - exiting with code: 1
- *     Cause: Invalid fwd port list
  * @param[out] values
  *   This array will be filled with a list of port IDs
  *   based on the user input
@@ -2630,7 +2627,8 @@  set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt)
  *   1) Number of elements in the values array
  *   2) Maximum value of each element in the values array
  * @return
- *   -returns total count of parsed port IDs
+ *   On success, returns total count of parsed port IDs
+ *   On failure, returns 0
  */
 static unsigned int
 parse_port_list(const char *list, unsigned int *values, unsigned int maxsize)
@@ -2642,7 +2640,7 @@  parse_port_list(const char *list, unsigned int *values, unsigned int maxsize)
 	unsigned int marked[maxsize];
 
 	if (list == NULL || values == NULL)
-		return -1;
+		return 0;
 
 	for (i = 0; i < (int)maxsize; i++)
 		marked[i] = 0;