From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 32484A00C5; Fri, 5 Jun 2020 15:41:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D9A661C13A; Fri, 5 Jun 2020 15:41:43 +0200 (CEST) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 4B0EC1BF83 for ; Fri, 5 Jun 2020 15:41:43 +0200 (CEST) Received: by mail-wr1-f66.google.com with SMTP id y17so9787620wrn.11 for ; Fri, 05 Jun 2020 06:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=WhJoKzN7U7Va7rM243G4X+/+uDwT6PoWy0qQyOodgfA=; b=zSofQxLADeckTcdKlowJMFA2ebAqeYFL1KWG7tctgRrxiZYraVyNGpobY9PeKTlnEn fRVqIHgG7Qq/hzTRpNBO6U1rReOhkSAGjM1luO10rQdKRR76wSzhqH97RkqYkAP206eP s9zE0IkNdTHeIUFFSXusa/2LO2a1Bnl005CMPw4xGfzSP1drkyaMB5sWBQrnes3ajk2X b+zYt9czcsd5gOL3PG/5ASDbGm+GwS9hAL8qo6z1MmhBccXw4BhDfyAlKZCDBmuMH0fa w/nnnYNZvw/X9BagAbU5nbEMEvSYXg3K4fQVMMEbdCvpSnjS4JcL6N58+k7KA2IuFIEh TjSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WhJoKzN7U7Va7rM243G4X+/+uDwT6PoWy0qQyOodgfA=; b=N4jjIKO7EYZ/12gkcrw+r70yAqiStUqGB3gmftmK6WAvKYGLFmIrS57ayr+okk4U8G gi066MEZV/J0tsOnJfUg7e1IDK/ChxE3KQzg39U4SVkMqEEF8AtHZP3tWPEzLZz/Qk1n ef6JSjljbqvnUu8x/D/eswR2GvrJeUmBaplwTQgMioXH3ppqWR41j3shXCTT2aBvB/y/ HOtfj406zGSTEQUVdp5uUFG3r01cWRxh3Eea7aO2lOCknQq/LUN+XwLqB3JpWqlIxwbM ekfNGi60gQc2OSiWpzwn0mfRW4PSw7ef1oUsIR2Q8a5tf7/cHqne5qeTMtoW1d+HZRGe xu8g== X-Gm-Message-State: AOAM530nKKuq16XHkSmSYO8qFqXz93Eds+i3FwVKryYV9sqRp3JM0fNS 16DyuckhvW7rnTi2AISMv1DOc2Zv10d2Ng== X-Google-Smtp-Source: ABdhPJwn8QJvTapOidlF37BVHRJDkDAD6jOisywIH1wf7l7EXAwPjrA9QbflvPAKQQlZkdsjNZaAyg== X-Received: by 2002:adf:de91:: with SMTP id w17mr10425387wrl.249.1591364502741; Fri, 05 Jun 2020 06:41:42 -0700 (PDT) Received: from localhost.localdomain ([39.40.101.253]) by smtp.gmail.com with ESMTPSA id c143sm16798372wmd.1.2020.06.05.06.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 06:41:42 -0700 (PDT) From: Sarosh Arif To: dev@dpdk.org, reshma.pattan@intel.com Cc: Sarosh Arif Date: Fri, 5 Jun 2020 18:41:14 +0500 Message-Id: <20200605134114.23149-1-sarosh.arif@emumba.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/packet_ordering: fix return value of parse_portmask X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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