From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0C59643A0B; Tue, 20 Feb 2024 03:33:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D1925402B8; Tue, 20 Feb 2024 03:33:21 +0100 (CET) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 5534F4029B for ; Tue, 20 Feb 2024 03:33:20 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Tf3LQ196Cz1X2cn; Tue, 20 Feb 2024 10:31:10 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 2DAE01A0172; Tue, 20 Feb 2024 10:33:18 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 20 Feb 2024 10:33:17 +0800 From: Chengwen Feng To: , , , , Subject: [PATCH] examples/dma: fix max-frame-size cannot be zero Date: Tue, 20 Feb 2024 02:31:53 +0000 Message-ID: <20240220023153.29793-1-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500024.china.huawei.com (7.185.36.10) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org In the original implementation, the max_frame_size could be zero, but commit ("examples/dma: replace getopt with argparse") treat zero as an error. This commit fixes it. Also, since unsigned doesn't < 0, adjust "<= 0" judgement to "== 0". Fixes: 8d85afb19af7 ("examples/dma: replace getopt with argparse") Reported-by: Jiang, YuX Signed-off-by: Chengwen Feng --- examples/dma/dmafwd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c index f4a0bff06e..acceae6b7b 100644 --- a/examples/dma/dmafwd.c +++ b/examples/dma/dmafwd.c @@ -695,23 +695,23 @@ dma_parse_args(int argc, char **argv, unsigned int nb_ports) return ret; /* check argument's value which parsing by autosave. */ - if (dma_batch_sz <= 0 || dma_batch_sz > MAX_PKT_BURST) { + if (dma_batch_sz == 0 || dma_batch_sz > MAX_PKT_BURST) { printf("Invalid dma batch size, %d.\n", dma_batch_sz); return -1; } - if (max_frame_size <= 0 || max_frame_size > RTE_ETHER_MAX_JUMBO_FRAME_LEN) { + if (max_frame_size > RTE_ETHER_MAX_JUMBO_FRAME_LEN) { printf("Invalid max frame size, %d.\n", max_frame_size); return -1; } - if (nb_queues <= 0 || nb_queues > MAX_RX_QUEUES_COUNT) { + if (nb_queues == 0 || nb_queues > MAX_RX_QUEUES_COUNT) { printf("Invalid RX queues number %d. Max %u\n", nb_queues, MAX_RX_QUEUES_COUNT); return -1; } - if (ring_size <= 0) { + if (ring_size == 0) { printf("Invalid ring size, %d.\n", ring_size); return -1; } @@ -721,7 +721,7 @@ dma_parse_args(int argc, char **argv, unsigned int nb_ports) ring_size = MBUF_RING_SIZE; } - if (stats_interval <= 0) { + if (stats_interval == 0) { printf("Invalid stats interval, setting to 1\n"); stats_interval = 1; /* set to default */ } -- 2.17.1