tno anon union - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 510f0dbf6b829ebf119288dbdcef92d874bbf651
 (DIR) parent b90bacec60916b907fad50d1b0c92c11d5d56c83
 (HTM) Author: rsc <devnull@localhost>
       Date:   Fri, 11 Feb 2005 21:16:01 +0000
       
       no anon union
       
       Diffstat:
         M src/cmd/tar.C                       |      49 +++++++++++++++----------------
       
       1 file changed, 23 insertions(+), 26 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/tar.C b/src/cmd/tar.C
       t@@ -67,27 +67,24 @@ enum {
        #define issymlink(lf)        ((lf) == LF_SYMLINK1 || (lf) == LF_SYMLINK2)
        
        typedef union {
       -        uchar        data[Tblock];
       -        struct {
       -                char        name[Namsiz];
       -                char        mode[8];
       -                char        uid[8];
       -                char        gid[8];
       -                char        size[12];
       -                char        mtime[12];
       -                char        chksum[8];
       -                char        linkflag;
       -                char        linkname[Namsiz];
       -
       -                /* rest are defined by POSIX's ustar format; see p1003.2b */
       -                char        magic[6];        /* "ustar" */
       -                char        version[2];
       -                char        uname[32];
       -                char        gname[32];
       -                char        devmajor[8];
       -                char        devminor[8];
       -                char        prefix[Maxpfx]; /* if non-null, path= prefix "/" name */
       -        };
       +        char        name[Namsiz];
       +        char        mode[8];
       +        char        uid[8];
       +        char        gid[8];
       +        char        size[12];
       +        char        mtime[12];
       +        char        chksum[8];
       +        char        linkflag;
       +        char        linkname[Namsiz];
       +
       +        /* rest are defined by POSIX's ustar format; see p1003.2b */
       +        char        magic[6];        /* "ustar" */
       +        char        version[2];
       +        char        uname[32];
       +        char        gname[32];
       +        char        devmajor[8];
       +        char        devminor[8];
       +        char        prefix[Maxpfx]; /* if non-null, path= prefix "/" name */
        } Hdr;
        
        int debug;
       t@@ -200,7 +197,7 @@ getblkz(int ar)
                Hdr *hp = getblke(ar);
        
                if (hp != nil)
       -                memset(hp->data, 0, Tblock);
       +                memset(hp, 0, Tblock);
                return hp;
        }
        
       t@@ -270,7 +267,7 @@ chksum(Hdr *hp)
        {
                int n = Tblock;
                long i = 0;
       -        uchar *cp = hp->data;
       +        uchar *cp = (uchar*)hp;
        
                memset(hp->chksum, ' ', sizeof hp->chksum);
                while (n-- > 0)
       t@@ -522,7 +519,7 @@ addtoar(int ar, char *file, char *shortf)
                                hbp = getblke(ar);
                                blksread = gothowmany(blksleft);
                                bytes = blksread * Tblock;
       -                        n = read(fd, hbp->data, bytes);
       +                        n = read(fd, hbp, bytes);
                                if (n < 0)
                                        sysfatal("error reading %s: %r", file);
                                /*
       t@@ -530,7 +527,7 @@ addtoar(int ar, char *file, char *shortf)
                                 * compression and emergency recovery of data.
                                 */
                                if (n < Tblock)
       -                                memset(hbp->data + n, 0, bytes - n);
       +                                memset((char*)hbp + n, 0, bytes - n);
                                putblkmany(ar, blksread);
                        }
                        close(fd);
       t@@ -716,7 +713,7 @@ extract1(int ar, Hdr *hp, char *fname)
                                        fname);
                        blksread = gothowmany(blksleft);
                        wrbytes = (bytes >= Tblock*blksread? Tblock*blksread: bytes);
       -                if (fd >= 0 && write(fd, hbp->data, wrbytes) != wrbytes)
       +                if (fd >= 0 && write(fd, (char*)hbp, wrbytes) != wrbytes)
                                sysfatal("write error on %s: %r", fname);
                        putreadblks(ar, blksread);
                        bytes -= wrbytes;