[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] maint: prefer STREQ_LEN and STRPREFIX over strncmp in all ca
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] maint: prefer STREQ_LEN and STRPREFIX over strncmp in all cases |
Date: |
Mon, 16 Feb 2015 12:31:47 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
On 15/02/15 22:26, Bernhard Voelker wrote:
> diff --git a/src/du.c b/src/du.c
> index 65fc074..5c664f9 100644
> --- a/src/du.c
> +++ b/src/du.c
> @@ -968,8 +968,7 @@ main (int argc, char **argv)
> {
> /* Ignore "posix-" prefix, for compatibility with ls. */
> static char const posix_prefix[] = "posix-";
> - while (strncmp (time_style, posix_prefix, sizeof posix_prefix
> - 1)
> - == 0)
> + while (STRPREFIX (time_style, posix_prefix))
> time_style += sizeof posix_prefix - 1;
I think the only difference between STREQ_LEN() and STRPREFIX()
is that the former is more efficient when len is available?
Hence STREQ_LEN() could be used above too?
thanks for the nice cleanup,
Pádraig