Commit Diff


commit - 8824e122a3e9a4ec6ecd5d241bc7d74581300a29
commit + 14f06f6792b50ad91f86c08b3a72e9d57ed98330
blob - d030b0b44c5a65a7c0f21ac503f49461c526d0c9
blob + c468fcb64dec356f4c7fe6729a83e478b1dd22fd
--- src/cmd/tar.c
+++ src/cmd/tar.c
@@ -16,7 +16,9 @@
  * keyletters and options.
  */
 #define	TARGBEGIN {\
-	(argv0 || (argv0 = *argv)), argv++, argc--;\
+	if (argv0 == nil)\
+		argv0 = *argv;\
+	argv++, argc--;\
 	if (argv[0]) {\
 		char *_args, *_argt;\
 		Rune _argc;\
@@ -69,28 +71,25 @@ enum {
 #define isreallink(lf)	((lf) == LF_LINK)
 #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];
+typedef 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 */
-	};
+	/* 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;
 
 typedef struct {
@@ -318,7 +317,7 @@ getblkz(int ar)
 	Hdr *hp = getblke(ar);
 
 	if (hp != nil)
-		memset(hp->data, 0, Tblock);
+		memset(hp, 0, Tblock);
 	return hp;
 }
 
@@ -391,7 +390,7 @@ chksum(Hdr *hp)
 {
 	int n = Tblock;
 	long i = 0;
-	uchar *cp = hp->data;
+	uchar *cp = (uchar*)hp;
 	char oldsum[sizeof hp->chksum];
 
 	memmove(oldsum, hp->chksum, sizeof oldsum);
@@ -664,7 +663,7 @@ addtoar(int ar, char *file, char *shortf)
 			hbp = getblke(ar);
 			blksread = gothowmany(blksleft);
 			bytes = blksread * Tblock;
-			n = readn(fd, hbp->data, bytes);
+			n = readn(fd, hbp, bytes);
 			if (n < 0)
 				sysfatal("error reading %s: %r", file);
 			/*
@@ -672,7 +671,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((uchar*)hbp + n, 0, bytes - n);
 			putblkmany(ar, blksread);
 		}
 		close(fd);
@@ -883,7 +882,7 @@ extract1(int ar, Hdr *hp, char *fname)
 		wrbytes = Tblock*blksread;
 		if(wrbytes > bytes)
 			wrbytes = bytes;
-		if (fd >= 0 && write(fd, hbp->data, wrbytes) != wrbytes)
+		if (fd >= 0 && write(fd, hbp, wrbytes) != wrbytes)
 			sysfatal("write error on %s: %r", fname);
 		putreadblks(ar, blksread);
 		bytes -= wrbytes;