- Remove (void) casts - Make WARNS?= 6 clean - Add WARNS?= 6 Index: src/usr.bin/xinstall/Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/xinstall/Makefile,v retrieving revision 1.22 diff -u -r1.22 Makefile --- src/usr.bin/xinstall/Makefile 17 Mar 2004 10:52:12 -0000 1.22 +++ src/usr.bin/xinstall/Makefile 12 Dec 2004 23:38:50 -0000 @@ -4,5 +4,6 @@ PROG= xinstall PROGNAME= install MAN= install.1 +WARNS?= 6 .include Index: src/usr.bin/xinstall/xinstall.c =================================================================== RCS file: /home/ncvs/src/usr.bin/xinstall/xinstall.c,v retrieving revision 1.65 diff -u -r1.65 xinstall.c --- src/usr.bin/xinstall/xinstall.c 17 Mar 2004 11:06:40 -0000 1.65 +++ src/usr.bin/xinstall/xinstall.c 12 Dec 2004 23:38:50 -0000 @@ -270,6 +270,8 @@ char backup[MAXPATHLEN], *p, pathbuf[MAXPATHLEN], tempfile[MAXPATHLEN]; files_match = 0; + from_fd = -1; + to_fd = -1; /* If try to install NULL file to a directory, fails. */ if (flags & DIRECTORY || strcmp(from_name, _PATH_DEVNULL)) { @@ -281,7 +283,7 @@ } /* Build the target path. */ if (flags & DIRECTORY) { - (void)snprintf(pathbuf, sizeof(pathbuf), "%s/%s", + snprintf(pathbuf, sizeof(pathbuf), "%s/%s", to_name, (p = strrchr(from_name, '/')) ? ++p : from_name); to_name = pathbuf; @@ -319,7 +321,7 @@ /* Close "to" file unless we match. */ if (!files_match) - (void)close(to_fd); + close(to_fd); } if (!files_match) { @@ -333,7 +335,7 @@ &to_sb)) < 0) err(EX_OSERR, "%s", to_name); if (verbose) - (void)printf("install: %s -> %s\n", + printf("install: %s -> %s\n", from_name, to_name); } if (!devnull) @@ -366,7 +368,7 @@ if (fstat(temp_fd, &temp_sb)) { serrno = errno; - (void)unlink(tempfile); + unlink(tempfile); errno = serrno; err(EX_OSERR, "%s", tempfile); } @@ -383,12 +385,12 @@ tvb[0].tv_usec = 0; tvb[1].tv_sec = to_sb.st_mtime; tvb[1].tv_usec = 0; - (void)utimes(tempfile, tvb); + utimes(tempfile, tvb); } else { files_match = 1; - (void)unlink(tempfile); + unlink(tempfile); } - (void) close(temp_fd); + close(temp_fd); } } @@ -399,7 +401,7 @@ if (tempcopy && !files_match) { /* Try to turn off the immutable bits. */ if (to_sb.st_flags & NOCHANGEBITS) - (void)chflags(to_name, to_sb.st_flags & ~NOCHANGEBITS); + chflags(to_name, to_sb.st_flags & ~NOCHANGEBITS); if (dobackup) { if ((size_t)snprintf(backup, MAXPATHLEN, "%s%s", to_name, suffix) != strlen(to_name) + strlen(suffix)) { @@ -408,7 +410,7 @@ to_name); } if (verbose) - (void)printf("install: %s -> %s\n", to_name, backup); + printf("install: %s -> %s\n", to_name, backup); if (rename(to_name, backup) < 0) { serrno = errno; unlink(tempfile); @@ -418,7 +420,7 @@ } } if (verbose) - (void)printf("install: %s -> %s\n", from_name, to_name); + printf("install: %s -> %s\n", from_name, to_name); if (rename(tempfile, to_name) < 0) { serrno = errno; unlink(tempfile); @@ -428,7 +430,7 @@ } /* Re-open to_fd so we aren't hosed by the rename(2). */ - (void) close(to_fd); + close(to_fd); if ((to_fd = open(to_name, O_RDONLY, 0)) < 0) err(EX_OSERR, "%s", to_name); } @@ -441,12 +443,12 @@ tvb[0].tv_usec = 0; tvb[1].tv_sec = from_sb.st_mtime; tvb[1].tv_usec = 0; - (void)utimes(to_name, tvb); + utimes(to_name, tvb); } if (fstat(to_fd, &to_sb) == -1) { serrno = errno; - (void)unlink(to_name); + unlink(to_name); errno = serrno; err(EX_OSERR, "%s", to_name); } @@ -460,14 +462,14 @@ (mode != (to_sb.st_mode & ALLPERMS))) { /* Try to turn off the immutable bits. */ if (to_sb.st_flags & NOCHANGEBITS) - (void)fchflags(to_fd, to_sb.st_flags & ~NOCHANGEBITS); + fchflags(to_fd, to_sb.st_flags & ~NOCHANGEBITS); } if ((gid != (gid_t)-1 && gid != to_sb.st_gid) || (uid != (uid_t)-1 && uid != to_sb.st_uid)) if (fchown(to_fd, uid, gid) == -1) { serrno = errno; - (void)unlink(to_name); + unlink(to_name); errno = serrno; err(EX_OSERR,"%s: chown/chgrp", to_name); } @@ -475,7 +477,7 @@ if (mode != (to_sb.st_mode & ALLPERMS)) if (fchmod(to_fd, mode)) { serrno = errno; - (void)unlink(to_name); + unlink(to_name); errno = serrno; err(EX_OSERR, "%s: chmod", to_name); } @@ -496,16 +498,16 @@ warn("%s: chflags", to_name); else { serrno = errno; - (void)unlink(to_name); + unlink(to_name); errno = serrno; err(EX_OSERR, "%s: chflags", to_name); } } } - (void)close(to_fd); + close(to_fd); if (!devnull) - (void)close(from_fd); + close(from_fd); } /* @@ -527,10 +529,12 @@ if (from_len <= MAX_CMP_SIZE) { done_compare = 0; if (trymmap(from_fd) && trymmap(to_fd)) { - p = mmap(NULL, from_len, PROT_READ, MAP_SHARED, from_fd, (off_t)0); + p = mmap(NULL, from_len, PROT_READ, MAP_SHARED, from_fd, + (off_t)0); if (p == (char *)MAP_FAILED) goto out; - q = mmap(NULL, from_len, PROT_READ, MAP_SHARED, to_fd, (off_t)0); + q = mmap(NULL, from_len, PROT_READ, MAP_SHARED, to_fd, + (off_t)0); if (q == (char *)MAP_FAILED) { munmap(p, from_len); goto out; @@ -581,13 +585,13 @@ { char *p; - (void)strncpy(temp, path, tsize); + strncpy(temp, path, tsize); temp[tsize - 1] = '\0'; if ((p = strrchr(temp, '/')) != NULL) p++; else p = temp; - (void)strncpy(p, "INS@XXXX", &temp[tsize - 1] - p); + strncpy(p, "INS@XXXX", &temp[tsize - 1] - p); temp[tsize - 1] = '\0'; return (mkstemp(temp)); } @@ -610,17 +614,17 @@ * it might work. */ if (sbp->st_flags & NOCHANGEBITS) - (void)chflags(path, sbp->st_flags & ~NOCHANGEBITS); + chflags(path, sbp->st_flags & ~NOCHANGEBITS); if (dobackup) { if ((size_t)snprintf(backup, MAXPATHLEN, "%s%s", path, suffix) != strlen(path) + strlen(suffix)) errx(EX_OSERR, "%s: backup filename too long", path); - (void)snprintf(backup, MAXPATHLEN, "%s%s", + snprintf(backup, MAXPATHLEN, "%s%s", path, suffix); if (verbose) - (void)printf("install: %s -> %s\n", + printf("install: %s -> %s\n", path, backup); if (rename(path, backup) < 0) err(EX_OSERR, "rename: %s to %s", path, backup); @@ -665,7 +669,7 @@ from_fd, (off_t)0)) != (char *)MAP_FAILED) { if ((nw = write(to_fd, p, size)) != size) { serrno = errno; - (void)unlink(to_name); + unlink(to_name); errno = nw > 0 ? EIO : serrno; err(EX_OSERR, "%s", to_name); } @@ -675,13 +679,13 @@ while ((nr = read(from_fd, buf, sizeof(buf))) > 0) if ((nw = write(to_fd, buf, nr)) != nr) { serrno = errno; - (void)unlink(to_name); + unlink(to_name); errno = nw > 0 ? EIO : serrno; err(EX_OSERR, "%s", to_name); } if (nr != 0) { serrno = errno; - (void)unlink(to_name); + unlink(to_name); errno = serrno; err(EX_OSERR, "%s", from_name); } @@ -701,7 +705,7 @@ switch (fork()) { case -1: serrno = errno; - (void)unlink(to_name); + unlink(to_name); errno = serrno; err(EX_TEMPFAIL, "fork"); case 0: @@ -713,7 +717,7 @@ default: if (wait(&status) == -1 || status) { serrno = errno; - (void)unlink(to_name); + unlink(to_name); errc(EX_SOFTWARE, serrno, "wait"); /* NOTREACHED */ } @@ -740,10 +744,11 @@ err(EX_OSERR, "mkdir %s", path); /* NOTREACHED */ } else if (verbose) - (void)printf("install: mkdir %s\n", + printf("install: mkdir %s\n", path); } else if (!S_ISDIR(sb.st_mode)) - errx(EX_OSERR, "%s exists but is not a directory", path); + errx(EX_OSERR, + "%s exists but is not a directory", path); if (!(*p = ch)) break; } @@ -761,7 +766,7 @@ void usage() { - (void)fprintf(stderr, + fprintf(stderr, "usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n" " [-o owner] file1 file2\n" " install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"