From: Eric Biggers <ebiggers@kernel.org>
To: Li Lingfeng <lilingfeng3@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
tj@kernel.org, axboe@kernel.dk, akpm@linux-foundation.org,
jack@suse.cz, bingjingc@synology.com, james.smart@broadcom.com,
houtao1@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com,
yukuai3@huawei.com
Subject: Re: [PATCH-next v3] lib: parser: optimize match_NUMER apis to use local array
Date: Thu, 19 Jan 2023 18:07:27 -0800 [thread overview]
Message-ID: <Y8n3Xxh+Rqo9vWHx@sol.localdomain> (raw)
In-Reply-To: <20230120021304.5773-1-lilingfeng3@huawei.com>
On Fri, Jan 20, 2023 at 10:13:04AM +0800, Li Lingfeng wrote:
> [PATCH-next v3] lib: parser: optimize match_NUMER apis to use
NUMER => NUMBER
> Memory will be allocated to store substring_t in match_strdup(), which means
> the caller of match_strdup() may need to be scheduled out to wait for reclaiming
> memory.
Text in commit messages should be wrapped at 72 columns.
> @@ -163,18 +169,16 @@ static int match_number(substring_t *s, int *result, int base)
> */
> static int match_u64int(substring_t *s, u64 *result, int base)
> {
> - char *buf;
> + char buf[NUMBER_BUF_LEN];
> int ret;
> u64 val;
>
> - buf = match_strdup(s);
> - if (!buf)
> - return -ENOMEM;
> -
> + if ((s->to - s->from) >= NUMBER_BUF_LEN)
> + return -ERANGE;
> + match_strlcpy(buf, s, NUMBER_BUF_LEN);
As I requested on v2, the return value of match_strlcpy() should be used instead
of checking '((s->to - s->from) >= NUMBER_BUF_LEN'.
- Eric
prev parent reply other threads:[~2023-01-20 2:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-20 2:13 Li Lingfeng
2023-01-20 2:00 ` Tejun Heo
2023-01-20 3:50 ` Jens Axboe
2023-01-20 2:07 ` Eric Biggers [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=Y8n3Xxh+Rqo9vWHx@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bingjingc@synology.com \
--cc=houtao1@huawei.com \
--cc=jack@suse.cz \
--cc=james.smart@broadcom.com \
--cc=lilingfeng3@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.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
all inboxes | Powered by JetHome®