From 7b115b74aec094ec50c0dd2b66f32c6a49e3a8eb Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 25 Aug 2004 01:23:15 +0000 Subject: [PATCH] Minor cleanups. Submitted-by: "Douwe Kiela" --- bin/cp/cp.c | 14 ++++++-------- bin/cp/extern.h | 4 +--- bin/cp/utils.c | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/bin/cp/cp.c b/bin/cp/cp.c index f205bf1264..a6bc80baa2 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1988, 1993, 1994 The Regents of the University of California. All rights reserved. * @(#)cp.c 8.2 (Berkeley) 4/1/94 * $FreeBSD: src/bin/cp/cp.c,v 1.24.2.7 2002/09/24 12:41:04 mckay Exp $ - * $DragonFly: src/bin/cp/cp.c,v 1.7 2004/07/22 13:19:26 asmodai Exp $ + * $DragonFly: src/bin/cp/cp.c,v 1.8 2004/08/25 01:23:15 dillon Exp $ */ /* @@ -80,11 +80,11 @@ static int Rflag, rflag; enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE }; -static int copy (char *[], enum op, int); +static int copy (char **, enum op, int); static int mastercmp (const FTSENT **, const FTSENT **); int -main(int argc, char *argv[]) +main(int argc, char **argv) { struct stat to_stat, tmp_stat; enum op type; @@ -232,15 +232,12 @@ main(int argc, char *argv[]) } static int -copy(argv, type, fts_options) - char *argv[]; - enum op type; - int fts_options; +copy(char **argv, enum op type, int fts_options) { struct stat to_stat; FTS *ftsp; FTSENT *curr; - int base = 0, dne, badcp, nlen, rval; + int base, dne, badcp, nlen, rval; char *p, *target_mid; mode_t mask, mode; @@ -250,6 +247,7 @@ copy(argv, type, fts_options) */ mask = ~umask(0777); umask(~mask); + base = 0; if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL) err(1, NULL); diff --git a/bin/cp/extern.h b/bin/cp/extern.h index efdc68f43c..1639030f83 100644 --- a/bin/cp/extern.h +++ b/bin/cp/extern.h @@ -32,7 +32,7 @@ * * @(#)extern.h 8.2 (Berkeley) 4/1/94 * $FreeBSD: src/bin/cp/extern.h,v 1.9.2.3 2002/08/10 13:20:19 johan Exp $ - * $DragonFly: src/bin/cp/extern.h,v 1.3 2003/09/21 04:18:34 drhodus Exp $ + * $DragonFly: src/bin/cp/extern.h,v 1.4 2004/08/25 01:23:15 dillon Exp $ */ typedef struct { @@ -44,8 +44,6 @@ typedef struct { extern PATH_T to; extern int fflag, iflag, nflag, pflag, vflag; -#include - __BEGIN_DECLS int copy_fifo (struct stat *, int); int copy_file (FTSENT *, int); diff --git a/bin/cp/utils.c b/bin/cp/utils.c index 205dc174c1..a91d1e98e9 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -32,7 +32,7 @@ * * @(#)utils.c 8.3 (Berkeley) 4/1/94 * $FreeBSD: src/bin/cp/utils.c,v 1.27.2.6 2002/08/10 13:20:19 johan Exp $ - * $DragonFly: src/bin/cp/utils.c,v 1.4 2004/07/22 11:41:56 asmodai Exp $ + * $DragonFly: src/bin/cp/utils.c,v 1.5 2004/08/25 01:23:15 dillon Exp $ */ #include @@ -54,6 +54,8 @@ #include "extern.h" +#define YESNO "(y/n [n]) " + int copy_file(FTSENT *entp, int dne) { @@ -81,20 +83,19 @@ copy_file(FTSENT *entp, int dne) * modified by the umask.) */ if (!dne) { -#define YESNO "(y/n [n]) " if (nflag) { if (vflag) printf("%s not overwritten\n", to.p_path); 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); } } @@ -102,7 +103,7 @@ copy_file(FTSENT *entp, int dne) if (fflag) { /* remove existing destination file name, * create a new file */ - (void)unlink(to.p_path); + unlink(to.p_path); to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT, fs->st_mode & ~(S_ISUID | S_ISGID)); } else @@ -114,7 +115,7 @@ copy_file(FTSENT *entp, int dne) if (to_fd == -1) { warn("%s", to.p_path); - (void)close(from_fd); + close(from_fd); return (1);; } @@ -179,7 +180,7 @@ copy_file(FTSENT *entp, int dne) if (pflag && setfile(fs, to_fd)) rval = 1; - (void)close(from_fd); + close(from_fd); if (close(to_fd)) { warn("%s", to.p_path); rval = 1; @@ -298,7 +299,7 @@ void usage(void) { - (void)fprintf(stderr, "%s\n%s\n", + fprintf(stderr, "%s\n%s\n", "usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target", " cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory"); exit(EX_USAGE); -- 2.41.0