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:
hubertf 2008-01-16 11:43:34 +00:00
parent a068899f90
commit 76e0b9a57a
1 changed files with 6 additions and 4 deletions

View File

@ -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
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
#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 /* not lint */
@ -98,7 +98,6 @@ main(int argc, char *argv[])
case 'v':
vflg = 1;
break;
case '?':
default:
usage();
}
@ -273,6 +272,8 @@ fastcopy(char *from, char *to, struct stat *sbp)
}
if (!blen && !(bp = malloc(blen = sbp->st_blksize))) {
warn(NULL);
(void)close(from_fd);
(void)close(to_fd);
return (1);
}
while ((nread = read(from_fd, bp, blen)) > 0)
@ -333,7 +334,8 @@ err: if (unlink(to))
int
copy(char *from, char *to)
{
int pid, status;
pid_t pid;
int status;
if ((pid = vfork()) == 0) {
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to, NULL);