From: Stephen Hemminger <stephen@networkplumber.org>
To: Yong Zhang <zhang.yong25@zte.com.cn>
Cc: thomas@monjalon.net, dev@dpdk.org, wang.yong19@zte.com.cn,
li.min10@zte.com.cn, ran.ming@zte.com.cn
Subject: Re: [v4,2/5] raw/gdtc: add support for queue setup operation
Date: Mon, 11 Nov 2024 21:05:05 -0800 [thread overview]
Message-ID: <20241111210505.690b0e6b@hermes.local> (raw)
In-Reply-To: <20241029134609.2499338-3-zhang.yong25@zte.com.cn>
On Tue, 29 Oct 2024 21:45:24 +0800
Yong Zhang <zhang.yong25@zte.com.cn> wrote:
> + /* Init sw_ring */
> + memset(name, 0, sizeof(name));
> + snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "gdma_vq%d_sw_ring", queue_id);
> + size = queue->queue_size * sizeof(struct zxdh_gdma_job *);
> + queue->sw_ring.job = rte_zmalloc(name, size, 0);
This works as is, but:
1. Do not need memset() before snprintf since snprintf will create null terminated string
2. rte_zmalloc() doesn't really care about the name arg
3. You should be using rte_calloc() if it is an array, because that is more common
and may help some checkers in future when DPDK can tell compiler that rte_calloc is functional
equivalent of calloc().
4. The name is being used as a memzone name, and not a rawdev name.
RTE_RAWDEV_NAME_MAX_LEN = 64
RTE_MEMZONE_NAMESIZE = 32
so you are at some risk of future bug where memzone names becomes too long.
> +
> + if (queue->sw_ring.job != NULL)
> + rte_free(queue->sw_ring.job);
> +
> + if (queue->ring.ring_mz != NULL)
> + rte_memzone_free(queue->ring.ring_mz);
Both these function handle NULL as a no-op, so the check for NULL is unnecessary.
There is a coccinelle script that finds these.
next prev parent reply other threads:[~2024-11-12 5:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 13:45 [v4,1/5] raw/gdtc: introduce gdtc raw device driver Yong Zhang
2024-10-29 13:45 ` [v4,2/5] raw/gdtc: add support for queue setup operation Yong Zhang
2024-11-12 5:05 ` Stephen Hemminger [this message]
2024-10-29 13:45 ` [v4,3/5] raw/gdtc: add support for standard rawdev operations Yong Zhang
2024-10-29 13:45 ` [v4,4/5] raw/gdtc: add support for enqueue operation Yong Zhang
2024-10-29 13:45 ` [v4,5/5] raw/gdtc: add support for dequeue operation Yong Zhang
2024-11-04 2:15 ` Re:[PATCH] raw/gdtc: introduce gdtc raw device driver Yong Zhang
2024-11-12 4:12 ` [PATCH] " Thomas Monjalon
2024-11-12 5:13 ` Stephen Hemminger
2024-11-14 9:36 ` zhang.yong25
2024-11-12 5:08 ` [v4,1/5] " Stephen Hemminger
2024-11-12 5:08 ` Stephen Hemminger
2024-11-13 9:22 ` zhang.yong25
2024-11-13 14:59 ` Stephen Hemminger
2024-11-12 5:09 ` Stephen Hemminger
2024-11-12 5:48 ` Stephen Hemminger
2024-11-14 9:20 ` [v5,1/5] " Yong Zhang
2024-11-14 9:20 ` [v5,2/5] raw/gdtc: add support for queue setup operation Yong Zhang
2024-11-20 0:46 ` Thomas Monjalon
2024-11-20 1:45 ` zhang.yong25
2024-11-20 1:59 ` Thomas Monjalon
2024-11-14 9:20 ` [v5,3/5] raw/gdtc: add support for standard rawdev operations Yong Zhang
2024-11-14 9:20 ` [v5,4/5] raw/gdtc: add support for enqueue operation Yong Zhang
2024-11-14 9:20 ` [v5,5/5] raw/gdtc: add support for dequeue operation Yong Zhang
2024-11-20 0:45 ` [v5,1/5] raw/gdtc: introduce gdtc raw device driver 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=20241111210505.690b0e6b@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=li.min10@zte.com.cn \
--cc=ran.ming@zte.com.cn \
--cc=thomas@monjalon.net \
--cc=wang.yong19@zte.com.cn \
--cc=zhang.yong25@zte.com.cn \
/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).