[Toybox] [PATCH 2/2] pending/file: reuse int
Isaac Dunham
ibid.ag at gmail.com
Sun Feb 28 17:17:20 PST 2016
On Sun, Feb 28, 2016 at 06:58:49PM -0500, Rich Felker wrote:
> 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.
Really, it comes out the same (at least with GCC 5.3 like Alpine uses);
no idea how lame a compiler it takes for this to be useful.
So I guess it's best to ignore it.
Thanks,
Isaac Dunham
1456708640.0
More information about the Toybox
mailing list