From 76e0b9a57ac7de1c2e387c6727c7702df4745073 Mon Sep 17 00:00:00 2001 From: hubertf Date: Wed, 16 Jan 2008 11:43:34 +0000 Subject: [PATCH] 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 in private mail. --- bin/mv/mv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/mv/mv.c b/bin/mv/mv.c index 68bebe2036ee..9df45838944b 100644 --- a/bin/mv/mv.c +++ b/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 @@ -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);