DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <dev@dpdk.org>, <yux.jiang@intel.com>,
	<bruce.richardson@intel.com>, <kevin.laatz@intel.com>
Subject: [PATCH] examples/dma: fix max-frame-size cannot be zero
Date: Tue, 20 Feb 2024 02:31:53 +0000	[thread overview]
Message-ID: <20240220023153.29793-1-fengchengwen@huawei.com> (raw)

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 <yux.jiang@intel.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 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


             reply	other threads:[~2024-02-20  2:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20  2:31 Chengwen Feng [this message]
2024-02-21  6:51 ` Jiang, YuX
2024-03-05 11:42   ` fengchengwen
2024-03-05 12:52     ` Thomas Monjalon
2024-03-07  9:07       ` 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=20240220023153.29793-1-fengchengwen@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=kevin.laatz@intel.com \
    --cc=thomas@monjalon.net \
    --cc=yux.jiang@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).