Re: [PATCH-next v3] lib: parser: optimize match_NUMER apis to use local array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux