[Toybox] [PATCH 2/2] pending/file: reuse int

Rich Felker dalias at libc.org
Sun Feb 28 15:58:49 PST 2016


On Sun, Feb 28, 2016 at 03:37:08PM -0800, Isaac Dunham wrote:
> ---
>  toys/pending/file.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/toys/pending/file.c b/toys/pending/file.c
> index 83e8c8e..789ef59 100644
> --- a/toys/pending/file.c
> +++ b/toys/pending/file.c
> @@ -126,7 +126,7 @@ static void do_regular_file(int fd, char *name)
>  {
>    char *s;
>    int len = read(fd, s = toybuf, sizeof(toybuf)-256);
> -  int magic;
> +  int peer;
>  
>    if (len<0) perror_msg("%s", name);
>  
> @@ -177,8 +177,8 @@ static void do_regular_file(int fd, char *name)
>      else if (toybuf[5] == '2') cpioformat = "SVR4 with CRC";
>      xprintf("ASCII cpio archive (%s)\n", cpioformat);
>    }
> -  else if (len>33 && (magic=peek(&s,2), magic==0143561 || magic==070707)) {
> -    if (magic == 0143561) printf("byte-swapped ");
> +  else if (len>33 && (peer=peek(&s,2), peer==0143561 || peer==070707)) {
> +    if (peer == 0143561) printf("byte-swapped ");
>      xprintf("cpio archive\n");
>    }
>    // tar archive (ustar/pax or gnu)
> @@ -187,10 +187,10 @@ static void do_regular_file(int fd, char *name)
>    }
>    // zip/jar/apk archive, ODF/OOXML document, or such
>    else if (len>5 && strstart(&s, "PK\03\04")) {
> -    int ver = (int)(char)(toybuf[4]);
> +    peer = (int)(char)(toybuf[4]);
>      xprintf("Zip archive data");
> -    if (ver)
> -      xprintf(", requires at least v%d.%d to extract", ver/10, ver%10);
> +    if (peer)
> +      xprintf(", requires at least v%d.%d to extract", peer/10, peer%10);
>      xputc('\n');
>    }
>    else {
> -- 

What's the point of this patch? Does it actually change the generated
code for the better? I would expect it to be at best the same code,
and possibly worse.

Rich

 1456703929.0


More information about the Toybox mailing list