fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL | FTS_COMFOLLOW;
}
- (void)signal(SIGINFO, siginfo);
+ signal(SIGINFO, siginfo);
/* Save the target base in "to". */
target = argv[--argc];
rval = 1;
continue;
}
- (void)strncat(target_mid, p, nlen);
+ strncat(target_mid, p, nlen);
to.p_end = target_mid + nlen;
*to.p_end = 0;
STRIP_TRAILING_SLASH(to);
to.p_path, curr->fts_path);
rval = 1;
if (S_ISDIR(curr->fts_statp->st_mode))
- (void)fts_set(ftsp, curr, FTS_SKIP);
+ fts_set(ftsp, curr, FTS_SKIP);
continue;
}
if (!S_ISDIR(curr->fts_statp->st_mode) &&
if (!Rflag) {
warnx("%s is a directory (not copied).",
curr->fts_path);
- (void)fts_set(ftsp, curr, FTS_SKIP);
+ fts_set(ftsp, curr, FTS_SKIP);
badcp = rval = 1;
break;
}
break;
}
if (vflag && !badcp)
- (void)printf("%s -> %s\n", curr->fts_path, to.p_path);
+ printf("%s -> %s\n", curr->fts_path, to.p_path);
}
if (errno)
err(1, "fts_read");
if (nflag) {
if (vflag)
printf("%s not overwritten\n", to.p_path);
- (void)close(from_fd);
+ close(from_fd);
return (0);
} else if (iflag) {
- (void)fprintf(stderr, "overwrite %s? %s",
+ fprintf(stderr, "overwrite %s? %s",
to.p_path, YESNO);
checkch = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
if (checkch != 'y' && checkch != 'Y') {
- (void)close(from_fd);
- (void)fprintf(stderr, "not overwritten\n");
+ close(from_fd);
+ fprintf(stderr, "not overwritten\n");
return (1);
}
}
if (fflag) {
/* remove existing destination file name,
* create a new file */
- (void)unlink(to.p_path);
+ unlink(to.p_path);
if (!lflag)
to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
fs->st_mode & ~(S_ISUID | S_ISGID));
if (to_fd == -1) {
warn("%s", to.p_path);
- (void)close(from_fd);
+ close(from_fd);
return (1);
}
wtotal += wcount;
if (info) {
info = 0;
- (void)fprintf(stderr,
+ fprintf(stderr,
"%s -> %s %3d%%\n",
entp->fts_path, to.p_path,
cp_pct(wtotal, fs->st_size));
wtotal += wcount;
if (info) {
info = 0;
- (void)fprintf(stderr,
+ fprintf(stderr,
"%s -> %s %3d%%\n",
entp->fts_path, to.p_path,
cp_pct(wtotal, fs->st_size));
}
}
- (void)close(from_fd);
+ close(from_fd);
return (rval);
}
usage(void)
{
- (void)fprintf(stderr, "%s\n%s\n",
+ fprintf(stderr, "%s\n%s\n",
"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file",
" cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... "
"target_directory");
/* It's a directory, move each file into it. */
if (strlen(argv[argc - 1]) > sizeof(path) - 1)
errx(1, "%s: destination pathname too long", *argv);
- (void)strcpy(path, argv[argc - 1]);
+ strcpy(path, argv[argc - 1]);
baselen = strlen(path);
endp = &path[baselen];
if (!baselen || *(endp - 1) != '/') {
printf("%s not overwritten\n", to);
return (0);
} else if (iflg) {
- (void)fprintf(stderr, "overwrite %s? %s", to, YESNO);
+ fprintf(stderr, "overwrite %s? %s", to, YESNO);
ask = 1;
} else if (access(to, W_OK) && !stat(to, &sb) && isatty(STDIN_FILENO)) {
strmode(sb.st_mode, modep);
- (void)fprintf(stderr, "override %s%s%s/%s for %s? %s",
+ fprintf(stderr, "override %s%s%s/%s for %s? %s",
modep + 1, modep[9] == ' ' ? "" : " ",
user_from_uid((unsigned long)sb.st_uid, 0),
group_from_gid((unsigned long)sb.st_gid, 0), to, YESNO);
while (ch != '\n' && ch != EOF)
ch = getchar();
if (first != 'y' && first != 'Y') {
- (void)fprintf(stderr, "not overwritten\n");
+ fprintf(stderr, "not overwritten\n");
return (0);
}
}
if (errno == EEXIST && unlink(to) == 0)
continue;
warn("fastcopy: open() failed (to): %s", to);
- (void)close(from_fd);
+ close(from_fd);
return (1);
}
while ((nread = read(from_fd, bp, (size_t)blen)) > 0)
warn("fastcopy: read() failed: %s", from);
err: if (unlink(to))
warn("%s: remove", to);
- (void)close(from_fd);
- (void)close(to_fd);
+ close(from_fd);
+ close(to_fd);
return (1);
}
if (fchmod(to_fd, sbp->st_mode))
warn("%s: set mode (was: 0%03o)", to, oldmode);
- (void)close(from_fd);
+ close(from_fd);
/*
* XXX
* NFS doesn't support chflags; ignore errors unless there's reason
copy(const char *from, const char *to)
{
struct stat sb;
- int pid, status;
+ int status;
+ pid_t pid;
if (lstat(to, &sb) == 0) {
/* Destination path exists. */
/* Copy source to destination. */
if (!(pid = vfork())) {
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to,
- (char *)NULL);
+ NULL);
_exit(EXEC_FAILED);
}
if (waitpid(pid, &status, 0) == -1) {
/* Delete the source. */
if (!(pid = vfork())) {
- execl(_PATH_RM, "mv", "-rf", "--", from, (char *)NULL);
+ execl(_PATH_RM, "mv", "-rf", "--", from, NULL);
_exit(EXEC_FAILED);
}
if (waitpid(pid, &status, 0) == -1) {
usage(void)
{
- (void)fprintf(stderr, "%s\n%s\n",
- "usage: mv [-f | -i | -n] [-hv] source target",
- " mv [-f | -i | -n] [-v] source ... directory");
+ fprintf(stderr, "%s\n%s\n",
+ "usage: mv [-f | -i | -n] [-hv] source target",
+ " mv [-f | -i | -n] [-v] source ... directory");
exit(EX_USAGE);
}