From 9a58b8c65cf760e0813dde6a9be505c25a0029b7 Mon Sep 17 00:00:00 2001 From: guenther Date: Sun, 14 Aug 2016 18:30:33 +0000 Subject: [PATCH] Remove many unnecessary casts. Verified by comparing generated code on both ILP32 and LP64. ok millert@ --- bin/pax/ar_io.c | 22 ++++---- bin/pax/buf_subs.c | 28 +++++----- bin/pax/cpio.c | 125 ++++++++++++++++++-------------------------- bin/pax/file_subs.c | 18 +++---- bin/pax/tables.c | 4 +- bin/pax/tar.c | 46 ++++++++-------- 6 files changed, 111 insertions(+), 132 deletions(-) diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c index bacba60695d..9b8fe86eb05 100644 --- a/bin/pax/ar_io.c +++ b/bin/pax/ar_io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar_io.c,v 1.56 2016/06/03 23:22:20 tedu Exp $ */ +/* $OpenBSD: ar_io.c,v 1.57 2016/08/14 18:30:33 guenther Exp $ */ /* $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $ */ /*- @@ -175,7 +175,7 @@ ar_open(const char *name) artyp = ioctl(arfd, MTIOCGET, &mb) ? ISCHR : ISTAPE; else if (S_ISBLK(arsb.st_mode)) artyp = ISBLK; - else if ((lseek(arfd, (off_t)0L, SEEK_CUR) == -1) && (errno == ESPIPE)) + else if ((lseek(arfd, 0, SEEK_CUR) == -1) && (errno == ESPIPE)) artyp = ISPIPE; else artyp = ISREG; @@ -462,7 +462,7 @@ ar_set_wr(void) * file, we must get rid of all the stuff after the current offset * (it was not written by pax). */ - if (((cpos = lseek(arfd, (off_t)0L, SEEK_CUR)) < 0) || + if (((cpos = lseek(arfd, 0, SEEK_CUR)) < 0) || (ftruncate(arfd, cpos) < 0)) { syswarn(1, errno, "Unable to truncate archive file"); return(-1); @@ -621,9 +621,9 @@ ar_write(char *buf, int bsz) * in size by forcing the runt record to next archive * volume */ - if ((cpos = lseek(arfd, (off_t)0L, SEEK_CUR)) < 0) + if ((cpos = lseek(arfd, 0, SEEK_CUR)) < 0) break; - cpos -= (off_t)res; + cpos -= res; if (ftruncate(arfd, cpos) < 0) break; res = lstrval = 0; @@ -757,9 +757,9 @@ ar_rdsync(void) io_ok = 0; if (((fsbz = arsb.st_blksize) <= 0) || (artyp != ISREG)) fsbz = BLKMULT; - if ((cpos = lseek(arfd, (off_t)0L, SEEK_CUR)) < 0) + if ((cpos = lseek(arfd, 0, SEEK_CUR)) < 0) break; - mpos = fsbz - (cpos % (off_t)fsbz); + mpos = fsbz - (cpos % fsbz); if (lseek(arfd, mpos, SEEK_CUR) < 0) break; lstrval = 1; @@ -818,7 +818,7 @@ ar_fow(off_t sksz, off_t *skipped) /* * figure out where we are in the archive */ - if ((cpos = lseek(arfd, (off_t)0L, SEEK_CUR)) >= 0) { + if ((cpos = lseek(arfd, 0, SEEK_CUR)) >= 0) { /* * we can be asked to move farther than there are bytes in this * volume, if so, just go to file end and let normal buf_fill() @@ -886,7 +886,7 @@ ar_rev(off_t sksz) * may not even have the ability to lseek() in any direction). * First we figure out where we are in the archive. */ - if ((cpos = lseek(arfd, (off_t)0L, SEEK_CUR)) < 0) { + if ((cpos = lseek(arfd, 0, SEEK_CUR)) < 0) { syswarn(1, errno, "Unable to obtain current archive byte offset"); lstrval = -1; @@ -900,7 +900,7 @@ ar_rev(off_t sksz) * previous volume and continue our movement backwards from * there. */ - if ((cpos -= sksz) < (off_t)0L) { + if ((cpos -= sksz) < 0) { if (arvol > 1) { /* * this should never happen @@ -909,7 +909,7 @@ ar_rev(off_t sksz) lstrval = -1; return(-1); } - cpos = (off_t)0L; + cpos = 0; } if (lseek(arfd, cpos, SEEK_SET) < 0) { syswarn(1, errno, "Unable to seek archive backwards"); diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c index cac45294436..bd9c435f0c2 100644 --- a/bin/pax/buf_subs.c +++ b/bin/pax/buf_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf_subs.c,v 1.27 2015/03/19 05:14:24 guenther Exp $ */ +/* $OpenBSD: buf_subs.c,v 1.28 2016/08/14 18:30:33 guenther Exp $ */ /* $NetBSD: buf_subs.c,v 1.5 1995/03/21 09:07:08 cgd Exp $ */ /*- @@ -236,7 +236,7 @@ appnd_start(off_t skcnt) skcnt += bufend - bufpt; if ((cnt = (skcnt/blksz) * blksz) < skcnt) cnt += blksz; - if (ar_rev((off_t)cnt) < 0) + if (ar_rev(cnt) < 0) goto out; /* @@ -258,7 +258,7 @@ appnd_start(off_t skcnt) goto out; bufpt += res; } - if (ar_rev((off_t)(bufpt - buf)) < 0) + if (ar_rev(bufpt - buf) < 0) goto out; bufpt = buf + cnt; bufend = buf + blksz; @@ -428,7 +428,7 @@ rd_skip(off_t skcnt) * what is left we have to read (which may be the whole thing if * ar_fow() told us the device can only read to skip records); */ - while (res > 0L) { + while (res > 0) { cnt = bufend - bufpt; /* * if the read fails, we will have to resync @@ -565,7 +565,7 @@ wr_skip(off_t skcnt) /* * loop while there is more padding to add */ - while (skcnt > 0L) { + while (skcnt > 0) { cnt = bufend - bufpt; if ((cnt <= 0) && ((cnt = buf_flush(blksz)) < 0)) return(-1); @@ -606,7 +606,7 @@ wr_rdfile(ARCHD *arcn, int ifd, off_t *left) /* * while there are more bytes to write */ - while (size > 0L) { + while (size > 0) { cnt = bufend - bufpt; if ((cnt <= 0) && ((cnt = buf_flush(blksz)) < 0)) { *left = size; @@ -625,7 +625,7 @@ wr_rdfile(ARCHD *arcn, int ifd, off_t *left) */ if (res < 0) syswarn(1, errno, "Read fault on %s", arcn->org_name); - else if (size != 0L) + else if (size != 0) paxwarn(1, "File changed size during read %s", arcn->org_name); else if (fstat(ifd, &sb) < 0) syswarn(1, errno, "Failed stat on %s", arcn->org_name); @@ -681,14 +681,14 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *left) } else syswarn(0,errno,"Unable to obtain block size for file %s",fnm); rem = sz; - *left = 0L; + *left = 0; /* * Copy the archive to the file the number of bytes specified. We have * to assume that we want to recover file holes as none of the archive * formats can record the location of file holes. */ - while (size > 0L) { + while (size > 0) { cnt = bufend - bufpt; /* * if we get a read error, we do not want to skip, as we may @@ -721,20 +721,20 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *left) * written. just closing with the file offset moved forward may not put * a hole at the end of the file. */ - if (isem && (arcn->sb.st_size > 0L)) + if (isem && (arcn->sb.st_size > 0)) file_flush(ofd, fnm, isem); /* * if we failed from archive read, we do not want to skip */ - if ((size > 0L) && (*left == 0L)) + if ((size > 0) && (*left == 0)) return(-1); /* * some formats record a crc on file data. If so, then we compare the * calculated crc to the crc stored in the archive */ - if (docrc && (size == 0L) && (arcn->crc != crc)) + if (docrc && (size == 0) && (arcn->crc != crc)) paxwarn(1,"Actual crc does not match expected crc %s",arcn->name); return(0); } @@ -750,7 +750,7 @@ void cp_file(ARCHD *arcn, int fd1, int fd2) { int cnt; - off_t cpcnt = 0L; + off_t cpcnt = 0; int res = 0; char *fnm = arcn->name; int no_hole = 0; @@ -813,7 +813,7 @@ cp_file(ARCHD *arcn, int fd1, int fd2) * written. just closing with the file offset moved forward may not put * a hole at the end of the file. */ - if (!no_hole && isem && (arcn->sb.st_size > 0L)) + if (!no_hole && isem && (arcn->sb.st_size > 0)) file_flush(fd2, fnm, isem); } diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c index c4c26bb6519..40505be943e 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpio.c,v 1.28 2016/08/14 04:47:52 guenther Exp $ */ +/* $OpenBSD: cpio.c,v 1.29 2016/08/14 18:30:33 guenther Exp $ */ /* $NetBSD: cpio.c,v 1.5 1995/03/21 09:07:13 cgd Exp $ */ /*- @@ -284,7 +284,7 @@ cpio_rd(ARCHD *arcn, char *buf) * byte oriented cpio (posix) does not have padding! extract the octal * ascii fields from the header */ - arcn->pad = 0L; + arcn->pad = 0; arcn->sb.st_dev = (dev_t)asc_ul(hd->c_dev, sizeof(hd->c_dev), OCT); arcn->sb.st_ino = (ino_t)asc_ul(hd->c_ino, sizeof(hd->c_ino), OCT); arcn->sb.st_mode = (mode_t)asc_ul(hd->c_mode, sizeof(hd->c_mode), OCT); @@ -345,7 +345,7 @@ cpio_rd(ARCHD *arcn, char *buf) off_t cpio_endrd(void) { - return((off_t)(sizeof(HD_CPIO) + sizeof(TRAILER))); + return sizeof(HD_CPIO) + sizeof(TRAILER); } /* @@ -380,10 +380,10 @@ cpio_wr(ARCHD *arcn) /* * check and repair truncated device and inode fields in the header */ - if (map_dev(arcn, (u_long)CPIO_MASK, (u_long)CPIO_MASK) < 0) + if (map_dev(arcn, CPIO_MASK, CPIO_MASK) < 0) return(-1); - arcn->pad = 0L; + arcn->pad = 0; nsz = arcn->nlen + 1; hd = (HD_CPIO *)hdblk; if ((arcn->type != PAX_BLK) && (arcn->type != PAX_CHR)) @@ -407,7 +407,7 @@ cpio_wr(ARCHD *arcn) /* * set data size to hold link name */ - if (ul_asc((u_long)arcn->ln_nlen, hd->c_filesize, + if (ul_asc(arcn->ln_nlen, hd->c_filesize, sizeof(hd->c_filesize), OCT)) goto out; break; @@ -415,8 +415,7 @@ cpio_wr(ARCHD *arcn) /* * all other file types have no file data */ - if (ul_asc((u_long)0, hd->c_filesize, sizeof(hd->c_filesize), - OCT)) + if (ul_asc(0, hd->c_filesize, sizeof(hd->c_filesize), OCT)) goto out; break; } @@ -424,24 +423,17 @@ cpio_wr(ARCHD *arcn) /* * copy the values to the header using octal ascii */ - if (ul_asc((u_long)MAGIC, hd->c_magic, sizeof(hd->c_magic), OCT) || - ul_asc((u_long)arcn->sb.st_dev, hd->c_dev, sizeof(hd->c_dev), - OCT) || - ul_asc((u_long)arcn->sb.st_ino, hd->c_ino, sizeof(hd->c_ino), - OCT) || - ul_asc((u_long)arcn->sb.st_mode, hd->c_mode, sizeof(hd->c_mode), - OCT) || - ul_asc((u_long)arcn->sb.st_uid, hd->c_uid, sizeof(hd->c_uid), - OCT) || - ul_asc((u_long)arcn->sb.st_gid, hd->c_gid, sizeof(hd->c_gid), - OCT) || - ul_asc((u_long)arcn->sb.st_nlink, hd->c_nlink, sizeof(hd->c_nlink), - OCT) || - ul_asc((u_long)arcn->sb.st_rdev, hd->c_rdev, sizeof(hd->c_rdev), - OCT) || + if (ul_asc(MAGIC, hd->c_magic, sizeof(hd->c_magic), OCT) || + ul_asc(arcn->sb.st_dev, hd->c_dev, sizeof(hd->c_dev), OCT) || + ul_asc(arcn->sb.st_ino, hd->c_ino, sizeof(hd->c_ino), OCT) || + ul_asc(arcn->sb.st_mode, hd->c_mode, sizeof(hd->c_mode), OCT) || + ul_asc(arcn->sb.st_uid, hd->c_uid, sizeof(hd->c_uid), OCT) || + ul_asc(arcn->sb.st_gid, hd->c_gid, sizeof(hd->c_gid), OCT) || + ul_asc(arcn->sb.st_nlink, hd->c_nlink, sizeof(hd->c_nlink), OCT) || + ul_asc(arcn->sb.st_rdev, hd->c_rdev, sizeof(hd->c_rdev), OCT) || ull_asc(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->c_mtime, sizeof(hd->c_mtime), OCT) || - ul_asc((u_long)nsz, hd->c_namesize, sizeof(hd->c_namesize), OCT)) + ul_asc(nsz, hd->c_namesize, sizeof(hd->c_namesize), OCT)) goto out; /* @@ -563,7 +555,7 @@ vcpio_rd(ARCHD *arcn, char *buf) } hd = (HD_VCPIO *)buf; - arcn->pad = 0L; + arcn->pad = 0; /* * extract the hex ascii fields from the header @@ -600,7 +592,7 @@ vcpio_rd(ARCHD *arcn, char *buf) /* * skip padding. header + filename is aligned to 4 byte boundaries */ - if (rd_skip((off_t)(VCPIO_PAD(sizeof(HD_VCPIO) + nsz))) < 0) + if (rd_skip(VCPIO_PAD(sizeof(HD_VCPIO) + nsz)) < 0) return(-1); /* @@ -621,7 +613,7 @@ vcpio_rd(ARCHD *arcn, char *buf) * read in the link name and skip over the padding */ if ((rd_ln_nm(arcn) < 0) || - (rd_skip((off_t)(VCPIO_PAD(arcn->sb.st_size))) < 0)) + (rd_skip(VCPIO_PAD(arcn->sb.st_size)) < 0)) return(-1); /* @@ -640,8 +632,8 @@ vcpio_rd(ARCHD *arcn, char *buf) off_t vcpio_endrd(void) { - return((off_t)(sizeof(HD_VCPIO) + sizeof(TRAILER) + - (VCPIO_PAD(sizeof(HD_VCPIO) + sizeof(TRAILER))))); + return sizeof(HD_VCPIO) + sizeof(TRAILER) + + (VCPIO_PAD(sizeof(HD_VCPIO) + sizeof(TRAILER))); } /* @@ -678,7 +670,7 @@ vcpio_wr(ARCHD *arcn) * check and repair truncated device and inode fields in the cpio * header */ - if (map_dev(arcn, (u_long)VCPIO_MASK, (u_long)VCPIO_MASK) < 0) + if (map_dev(arcn, VCPIO_MASK, VCPIO_MASK) < 0) return(-1); nsz = arcn->nlen + 1; hd = (HD_VCPIO *)hdblk; @@ -690,15 +682,12 @@ vcpio_wr(ARCHD *arcn) * file data crc's, and the crc if needed. */ if (docrc) { - if (ul_asc((u_long)VCMAGIC, hd->c_magic, sizeof(hd->c_magic), - OCT) || - ul_asc((u_long)arcn->crc,hd->c_chksum,sizeof(hd->c_chksum), - HEX)) + if (ul_asc(VCMAGIC, hd->c_magic, sizeof(hd->c_magic), OCT) || + ul_asc(arcn->crc,hd->c_chksum,sizeof(hd->c_chksum), HEX)) goto out; } else { - if (ul_asc((u_long)VMAGIC, hd->c_magic, sizeof(hd->c_magic), - OCT) || - ul_asc((u_long)0L, hd->c_chksum, sizeof(hd->c_chksum),HEX)) + if (ul_asc(VMAGIC, hd->c_magic, sizeof(hd->c_magic), OCT) || + ul_asc(0, hd->c_chksum, sizeof(hd->c_chksum),HEX)) goto out; } @@ -723,8 +712,8 @@ vcpio_wr(ARCHD *arcn) * no file data for the caller to process, the file data has * the size of the link */ - arcn->pad = 0L; - if (ul_asc((u_long)arcn->ln_nlen, hd->c_filesize, + arcn->pad = 0; + if (ul_asc(arcn->ln_nlen, hd->c_filesize, sizeof(hd->c_filesize), HEX)) goto out; break; @@ -732,9 +721,8 @@ vcpio_wr(ARCHD *arcn) /* * no file data for the caller to process */ - arcn->pad = 0L; - if (ul_asc((u_long)0L, hd->c_filesize, sizeof(hd->c_filesize), - HEX)) + arcn->pad = 0; + if (ul_asc(0, hd->c_filesize, sizeof(hd->c_filesize), HEX)) goto out; break; } @@ -742,27 +730,18 @@ vcpio_wr(ARCHD *arcn) /* * set the other fields in the header */ - if (ul_asc((u_long)arcn->sb.st_ino, hd->c_ino, sizeof(hd->c_ino), - HEX) || - ul_asc((u_long)arcn->sb.st_mode, hd->c_mode, sizeof(hd->c_mode), - HEX) || - ul_asc((u_long)arcn->sb.st_uid, hd->c_uid, sizeof(hd->c_uid), - HEX) || - ul_asc((u_long)arcn->sb.st_gid, hd->c_gid, sizeof(hd->c_gid), - HEX) || + if (ul_asc(arcn->sb.st_ino, hd->c_ino, sizeof(hd->c_ino), HEX) || + ul_asc(arcn->sb.st_mode, hd->c_mode, sizeof(hd->c_mode), HEX) || + ul_asc(arcn->sb.st_uid, hd->c_uid, sizeof(hd->c_uid), HEX) || + ul_asc(arcn->sb.st_gid, hd->c_gid, sizeof(hd->c_gid), HEX) || ul_asc(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->c_mtime, sizeof(hd->c_mtime), HEX) || - ul_asc((u_long)arcn->sb.st_nlink, hd->c_nlink, sizeof(hd->c_nlink), - HEX) || - ul_asc((u_long)MAJOR(arcn->sb.st_dev),hd->c_maj, sizeof(hd->c_maj), - HEX) || - ul_asc((u_long)MINOR(arcn->sb.st_dev),hd->c_min, sizeof(hd->c_min), - HEX) || - ul_asc((u_long)MAJOR(arcn->sb.st_rdev),hd->c_rmaj,sizeof(hd->c_maj), - HEX) || - ul_asc((u_long)MINOR(arcn->sb.st_rdev),hd->c_rmin,sizeof(hd->c_min), - HEX) || - ul_asc((u_long)nsz, hd->c_namesize, sizeof(hd->c_namesize), HEX)) + ul_asc(arcn->sb.st_nlink, hd->c_nlink, sizeof(hd->c_nlink), HEX) || + ul_asc(MAJOR(arcn->sb.st_dev),hd->c_maj, sizeof(hd->c_maj), HEX) || + ul_asc(MINOR(arcn->sb.st_dev),hd->c_min, sizeof(hd->c_min), HEX) || + ul_asc(MAJOR(arcn->sb.st_rdev),hd->c_rmaj,sizeof(hd->c_maj), HEX) || + ul_asc(MINOR(arcn->sb.st_rdev),hd->c_rmin,sizeof(hd->c_min), HEX) || + ul_asc(nsz, hd->c_namesize, sizeof(hd->c_namesize), HEX)) goto out; /* @@ -770,7 +749,7 @@ vcpio_wr(ARCHD *arcn) */ if ((wr_rdbuf(hdblk, (int)sizeof(HD_VCPIO)) < 0) || (wr_rdbuf(arcn->name, (int)nsz) < 0) || - (wr_skip((off_t)(VCPIO_PAD(sizeof(HD_VCPIO) + nsz))) < 0)) { + (wr_skip(VCPIO_PAD(sizeof(HD_VCPIO) + nsz)) < 0)) { paxwarn(1,"Could not write sv4cpio header for %s",arcn->org_name); return(-1); } @@ -791,7 +770,7 @@ vcpio_wr(ARCHD *arcn) * write the link name, tell the caller we are done. */ if ((wr_rdbuf(arcn->ln_name, arcn->ln_nlen) < 0) || - (wr_skip((off_t)(VCPIO_PAD(arcn->ln_nlen))) < 0)) { + (wr_skip(VCPIO_PAD(arcn->ln_nlen)) < 0)) { paxwarn(1,"Could not write sv4cpio link name for %s", arcn->org_name); return(-1); @@ -858,7 +837,7 @@ bcpio_rd(ARCHD *arcn, char *buf) if (bcpio_id(buf, sizeof(HD_BCPIO)) < 0) return(-1); - arcn->pad = 0L; + arcn->pad = 0; hd = (HD_BCPIO *)buf; if (swp_head) { /* @@ -910,7 +889,7 @@ bcpio_rd(ARCHD *arcn, char *buf) /* * header + file name are aligned to 2 byte boundaries, skip if needed */ - if (rd_skip((off_t)(BCPIO_PAD(sizeof(HD_BCPIO) + nsz))) < 0) + if (rd_skip(BCPIO_PAD(sizeof(HD_BCPIO) + nsz)) < 0) return(-1); /* @@ -928,7 +907,7 @@ bcpio_rd(ARCHD *arcn, char *buf) } if ((rd_ln_nm(arcn) < 0) || - (rd_skip((off_t)(BCPIO_PAD(arcn->sb.st_size))) < 0)) + (rd_skip(BCPIO_PAD(arcn->sb.st_size)) < 0)) return(-1); /* @@ -947,8 +926,8 @@ bcpio_rd(ARCHD *arcn, char *buf) off_t bcpio_endrd(void) { - return((off_t)(sizeof(HD_BCPIO) + sizeof(TRAILER) + - (BCPIO_PAD(sizeof(HD_BCPIO) + sizeof(TRAILER))))); + return sizeof(HD_BCPIO) + sizeof(TRAILER) + + (BCPIO_PAD(sizeof(HD_BCPIO) + sizeof(TRAILER))); } /* @@ -976,7 +955,7 @@ bcpio_wr(ARCHD *arcn) * check and repair truncated device and inode fields in the cpio * header */ - if (map_dev(arcn, (u_long)BCPIO_MASK, (u_long)BCPIO_MASK) < 0) + if (map_dev(arcn, BCPIO_MASK, BCPIO_MASK) < 0) return(-1); if ((arcn->type != PAX_BLK) && (arcn->type != PAX_CHR)) @@ -1009,7 +988,7 @@ bcpio_wr(ARCHD *arcn) * no file data for the caller to process, the file data has * the size of the link */ - arcn->pad = 0L; + arcn->pad = 0; hd->h_filesize_1[0] = CHR_WR_0(arcn->ln_nlen); hd->h_filesize_1[1] = CHR_WR_1(arcn->ln_nlen); hd->h_filesize_2[0] = CHR_WR_2(arcn->ln_nlen); @@ -1023,7 +1002,7 @@ bcpio_wr(ARCHD *arcn) /* * no file data for the caller to process */ - arcn->pad = 0L; + arcn->pad = 0; hd->h_filesize_1[0] = (char)0; hd->h_filesize_1[1] = (char)0; hd->h_filesize_2[0] = (char)0; @@ -1088,7 +1067,7 @@ bcpio_wr(ARCHD *arcn) */ if ((wr_rdbuf(hdblk, (int)sizeof(HD_BCPIO)) < 0) || (wr_rdbuf(arcn->name, nsz) < 0) || - (wr_skip((off_t)(BCPIO_PAD(sizeof(HD_BCPIO) + nsz))) < 0)) { + (wr_skip(BCPIO_PAD(sizeof(HD_BCPIO) + nsz)) < 0)) { paxwarn(1, "Could not write bcpio header for %s", arcn->org_name); return(-1); } @@ -1109,7 +1088,7 @@ bcpio_wr(ARCHD *arcn) * write the link name, tell the caller we are done. */ if ((wr_rdbuf(arcn->ln_name, arcn->ln_nlen) < 0) || - (wr_skip((off_t)(BCPIO_PAD(arcn->ln_nlen))) < 0)) { + (wr_skip(BCPIO_PAD(arcn->ln_nlen)) < 0)) { paxwarn(1,"Could not write bcpio link name for %s",arcn->org_name); return(-1); } diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index 1f27d280f82..b568c4eed20 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file_subs.c,v 1.48 2016/02/16 04:30:07 guenther Exp $ */ +/* $OpenBSD: file_subs.c,v 1.49 2016/08/14 18:30:33 guenther Exp $ */ /* $NetBSD: file_subs.c,v 1.4 1995/03/21 09:07:18 cgd Exp $ */ /*- @@ -961,7 +961,7 @@ file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz, * skip, buf is empty so far */ if (fd > -1 && - lseek(fd, (off_t)wcnt, SEEK_CUR) < 0) { + lseek(fd, wcnt, SEEK_CUR) < 0) { syswarn(1,errno,"File seek on %s", name); return(-1); @@ -1031,7 +1031,7 @@ file_flush(int fd, char *fname, int isempt) /* * move back one byte and write a zero */ - if (lseek(fd, (off_t)-1, SEEK_CUR) < 0) { + if (lseek(fd, -1, SEEK_CUR) < 0) { syswarn(1, errno, "Failed seek on file %s", fname); return; } @@ -1080,8 +1080,8 @@ set_crc(ARCHD *arcn, int fd) { int i; int res; - off_t cpcnt = 0L; - u_long size; + off_t cpcnt = 0; + size_t size; u_int32_t crc = 0; char tbuf[FILEBLK]; struct stat sb; @@ -1090,12 +1090,12 @@ set_crc(ARCHD *arcn, int fd) /* * hmm, no fd, should never happen. well no crc then. */ - arcn->crc = 0L; + arcn->crc = 0; return(0); } - if ((size = (u_long)arcn->sb.st_blksize) > (u_long)sizeof(tbuf)) - size = (u_long)sizeof(tbuf); + if ((size = arcn->sb.st_blksize) > sizeof(tbuf)) + size = sizeof(tbuf); /* * read all the bytes we think that there are in the file. If the user @@ -1119,7 +1119,7 @@ set_crc(ARCHD *arcn, int fd) syswarn(1, errno, "Failed stat on %s", arcn->org_name); else if (timespeccmp(&arcn->sb.st_mtim, &sb.st_mtim, !=)) paxwarn(1, "File %s was modified during read", arcn->org_name); - else if (lseek(fd, (off_t)0L, SEEK_SET) < 0) + else if (lseek(fd, 0, SEEK_SET) < 0) syswarn(1, errno, "File rewind failed on: %s", arcn->org_name); else { arcn->crc = crc; diff --git a/bin/pax/tables.c b/bin/pax/tables.c index 220f594a5f3..74f01023903 100644 --- a/bin/pax/tables.c +++ b/bin/pax/tables.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tables.c,v 1.47 2015/03/19 05:14:24 guenther Exp $ */ +/* $OpenBSD: tables.c,v 1.48 2016/08/14 18:30:33 guenther Exp $ */ /* $NetBSD: tables.c,v 1.4 1995/03/21 09:07:45 cgd Exp $ */ /*- @@ -442,7 +442,7 @@ chk_ftime(ARCHD *arcn) * add the name at the end of the scratch file, saving the * offset. add the file to the head of the hash chain */ - if ((pt->seek = lseek(ffd, (off_t)0, SEEK_END)) >= 0) { + if ((pt->seek = lseek(ffd, 0, SEEK_END)) >= 0) { if (write(ffd, arcn->name, namelen) == namelen) { pt->mtim = arcn->sb.st_mtim; pt->namelen = namelen; diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 0c0bb1554c9..d6589107e61 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tar.c,v 1.60 2016/08/14 04:47:52 guenther Exp $ */ +/* $OpenBSD: tar.c,v 1.61 2016/08/14 18:30:33 guenther Exp $ */ /* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */ /*- @@ -84,7 +84,7 @@ char *gnu_link_string; /* GNU ././@LongLink hackery link */ int tar_endwr(void) { - return(wr_skip((off_t)(NULLCNT*BLKMULT))); + return wr_skip(NULLCNT * BLKMULT); } /* @@ -97,7 +97,7 @@ tar_endwr(void) off_t tar_endrd(void) { - return((off_t)(NULLCNT*BLKMULT)); + return NULLCNT * BLKMULT; } /* @@ -592,7 +592,7 @@ tar_wr(ARCHD *arcn) */ hd->linkflag = AREGTYPE; hd->name[len-1] = '/'; - if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 1)) + if (ul_oct(0, hd->size, sizeof(hd->size), 1)) goto out; } else if (arcn->type == PAX_SLK) { /* @@ -601,7 +601,7 @@ tar_wr(ARCHD *arcn) hd->linkflag = SYMTYPE; fieldcpy(hd->linkname, sizeof(hd->linkname), arcn->ln_name, sizeof(arcn->ln_name)); - if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 1)) + if (ul_oct(0, hd->size, sizeof(hd->size), 1)) goto out; } else if (PAX_IS_HARDLINK(arcn->type)) { /* @@ -610,7 +610,7 @@ tar_wr(ARCHD *arcn) hd->linkflag = LNKTYPE; fieldcpy(hd->linkname, sizeof(hd->linkname), arcn->ln_name, sizeof(arcn->ln_name)); - if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 1)) + if (ul_oct(0, hd->size, sizeof(hd->size), 1)) goto out; } else { /* @@ -628,11 +628,11 @@ tar_wr(ARCHD *arcn) /* * copy those fields that are independent of the type */ - if (ul_oct((u_long)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 0) || + if (ul_oct(arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 0) || ull_oct(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->mtime, sizeof(hd->mtime), 1) || - ul_oct((u_long)arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 0) || - ul_oct((u_long)arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 0)) + ul_oct(arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 0) || + ul_oct(arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 0)) goto out; /* @@ -645,7 +645,7 @@ tar_wr(ARCHD *arcn) goto out; if (wr_rdbuf(hdblk, sizeof(HD_TAR)) < 0) return(-1); - if (wr_skip((off_t)(BLKMULT - sizeof(HD_TAR))) < 0) + if (wr_skip(BLKMULT - sizeof(HD_TAR)) < 0) return(-1); if (PAX_IS_REG(arcn->type)) return(0); @@ -973,7 +973,7 @@ ustar_wr(ARCHD *arcn) */ memset(hdblk, 0, sizeof(hdblk)); hd = (HD_USTAR *)hdblk; - arcn->pad = 0L; + arcn->pad = 0; /* * split the name, or zero out the prefix @@ -1002,7 +1002,7 @@ ustar_wr(ARCHD *arcn) switch (arcn->type) { case PAX_DIR: hd->typeflag = DIRTYPE; - if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) + if (ul_oct(0, hd->size, sizeof(hd->size), 3)) goto out; break; case PAX_CHR: @@ -1011,16 +1011,16 @@ ustar_wr(ARCHD *arcn) hd->typeflag = CHRTYPE; else hd->typeflag = BLKTYPE; - if (ul_oct((u_long)MAJOR(arcn->sb.st_rdev), hd->devmajor, + if (ul_oct(MAJOR(arcn->sb.st_rdev), hd->devmajor, sizeof(hd->devmajor), 3) || - ul_oct((u_long)MINOR(arcn->sb.st_rdev), hd->devminor, + ul_oct(MINOR(arcn->sb.st_rdev), hd->devminor, sizeof(hd->devminor), 3) || - ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) + ul_oct(0, hd->size, sizeof(hd->size), 3)) goto out; break; case PAX_FIF: hd->typeflag = FIFOTYPE; - if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) + if (ul_oct(0, hd->size, sizeof(hd->size), 3)) goto out; break; case PAX_SLK: @@ -1032,7 +1032,7 @@ ustar_wr(ARCHD *arcn) hd->typeflag = LNKTYPE; fieldcpy(hd->linkname, sizeof(hd->linkname), arcn->ln_name, sizeof(arcn->ln_name)); - if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) + if (ul_oct(0, hd->size, sizeof(hd->size), 3)) goto out; break; case PAX_REG: @@ -1061,7 +1061,7 @@ ustar_wr(ARCHD *arcn) * set the remaining fields. Some versions want all 16 bits of mode * we better humor them (they really do not meet spec though).... */ - if (ul_oct((u_long)arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 3)) { + if (ul_oct(arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 3)) { if (uid_nobody == 0) { if (uid_name("nobody", &uid_nobody) == -1) goto out; @@ -1072,10 +1072,10 @@ ustar_wr(ARCHD *arcn) "Ustar header field is too small for uid %lu, " "using nobody", (u_long)arcn->sb.st_uid); } - if (ul_oct((u_long)uid_nobody, hd->uid, sizeof(hd->uid), 3)) + if (ul_oct(uid_nobody, hd->uid, sizeof(hd->uid), 3)) goto out; } - if (ul_oct((u_long)arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 3)) { + if (ul_oct(arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 3)) { if (gid_nobody == 0) { if (gid_name("nobody", &gid_nobody) == -1) goto out; @@ -1086,12 +1086,12 @@ ustar_wr(ARCHD *arcn) "Ustar header field is too small for gid %lu, " "using nobody", (u_long)arcn->sb.st_gid); } - if (ul_oct((u_long)gid_nobody, hd->gid, sizeof(hd->gid), 3)) + if (ul_oct(gid_nobody, hd->gid, sizeof(hd->gid), 3)) goto out; } if (ull_oct(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->mtime, sizeof(hd->mtime), 3) || - ul_oct((u_long)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 3)) + ul_oct(arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 3)) goto out; if (!Nflag) { strncpy(hd->uname, name_uid(arcn->sb.st_uid, 0), sizeof(hd->uname)); @@ -1111,7 +1111,7 @@ ustar_wr(ARCHD *arcn) goto out; if (wr_rdbuf(hdblk, sizeof(HD_USTAR)) < 0) return(-1); - if (wr_skip((off_t)(BLKMULT - sizeof(HD_USTAR))) < 0) + if (wr_skip(BLKMULT - sizeof(HD_USTAR)) < 0) return(-1); if (PAX_IS_REG(arcn->type)) return(0); -- 2.20.1