Code cleanup:
- Removed case '?' before default in switch - Don't forget to close opened decriptors when malloc() fails - Hold vfork() result in variable with pid_t type (instead of int) Sent ages ago by Slava Semushin <php-coder@altlinux.ru> in private mail.
This commit is contained in:
parent
a068899f90
commit
76e0b9a57a
10
bin/mv/mv.c
10
bin/mv/mv.c
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: mv.c,v 1.38 2007/02/15 09:57:16 rillig Exp $ */
|
/* $NetBSD: mv.c,v 1.39 2008/01/16 11:43:34 hubertf Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1989, 1993, 1994
|
* Copyright (c) 1989, 1993, 1994
|
||||||
|
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\n\
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
|
static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: mv.c,v 1.38 2007/02/15 09:57:16 rillig Exp $");
|
__RCSID("$NetBSD: mv.c,v 1.39 2008/01/16 11:43:34 hubertf Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -98,7 +98,6 @@ main(int argc, char *argv[])
|
||||||
case 'v':
|
case 'v':
|
||||||
vflg = 1;
|
vflg = 1;
|
||||||
break;
|
break;
|
||||||
case '?':
|
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
@ -273,6 +272,8 @@ fastcopy(char *from, char *to, struct stat *sbp)
|
||||||
}
|
}
|
||||||
if (!blen && !(bp = malloc(blen = sbp->st_blksize))) {
|
if (!blen && !(bp = malloc(blen = sbp->st_blksize))) {
|
||||||
warn(NULL);
|
warn(NULL);
|
||||||
|
(void)close(from_fd);
|
||||||
|
(void)close(to_fd);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
while ((nread = read(from_fd, bp, blen)) > 0)
|
while ((nread = read(from_fd, bp, blen)) > 0)
|
||||||
|
@ -333,7 +334,8 @@ err: if (unlink(to))
|
||||||
int
|
int
|
||||||
copy(char *from, char *to)
|
copy(char *from, char *to)
|
||||||
{
|
{
|
||||||
int pid, status;
|
pid_t pid;
|
||||||
|
int status;
|
||||||
|
|
||||||
if ((pid = vfork()) == 0) {
|
if ((pid = vfork()) == 0) {
|
||||||
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to, NULL);
|
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to, NULL);
|
||||||
|
|
Loading…
Reference in New Issue