From: Stephen Hemminger <stephen@networkplumber.org>
To: liwencheng <liwencheng@phytium.com.cn>
Cc: dev@dpdk.org
Subject: Re: [PATCH v1 1/2] net/macb: add new driver
Date: Fri, 1 Nov 2024 22:43:10 -0700 [thread overview]
Message-ID: <20241101224310.2564e1b2@hermes.local> (raw)
In-Reply-To: <1730455640-1084345-1-git-send-email-liwencheng@phytium.com.cn>
On Fri, 1 Nov 2024 10:07:19 +0000
liwencheng <liwencheng@phytium.com.cn> wrote:
> +int macb_uio_init(const char *name, struct macb_iomem **iomem)
> +{
> + struct macb_iomem *new;
> + int ret;
> +
> + new = malloc(sizeof(struct macb_iomem));
> + if (!new) {
> + MACB_LOG(ERR, "No memory for IOMEM obj.");
> + return -ENOMEM;
> + }
> + memset(new, 0, sizeof(struct macb_iomem));
> +
> + new->name = malloc(strlen(name) + 1);
> + if (!new->name) {
> + MACB_LOG(ERR, "No memory for IOMEM-name obj.");
> + ret = -ENOMEM;
> + goto out_free;
> + }
> +
> + memcpy(new->name, name, strlen(name));
> + new->name[strlen(name)] = '\0';
This looks like you just reinvented strdup() function and
did with calling strlen() multiple times.
prev parent reply other threads:[~2024-11-02 5:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-01 10:07 liwencheng
2024-11-01 10:07 ` [PATCH v1 2/2] /usertools/dpdk-devbind:add the binding and unbinding of platform device liwencheng
2024-11-01 16:13 ` [PATCH v1 1/2] net/macb: add new driver Stephen Hemminger
2024-11-01 17:42 ` Stephen Hemminger
2024-11-02 5:43 ` Stephen Hemminger [this message]
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=20241101224310.2564e1b2@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=liwencheng@phytium.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).