summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2002-02-22 21:24:14 +0000
committermarkm <markm@FreeBSD.org>2002-02-22 21:24:14 +0000
commit2b941891dbad5a4edcf64325cbd3a6cf9f8b0931 (patch)
tree7df96d0a81d721bfad76255e68d1542c4a161f7b
parent3ce9528bfb2bfddd566fc2750966b7fc0b2a8a93 (diff)
downloadFreeBSD-src-2b941891dbad5a4edcf64325cbd3a6cf9f8b0931.zip
FreeBSD-src-2b941891dbad5a4edcf64325cbd3a6cf9f8b0931.tar.gz
Fix warnings inspired by lint, a commercial lint and WARNS=4.
-rw-r--r--bin/cp/Makefile1
-rw-r--r--bin/cp/cp.c14
-rw-r--r--bin/cp/extern.h10
-rw-r--r--bin/cp/utils.c16
4 files changed, 20 insertions, 21 deletions
diff --git a/bin/cp/Makefile b/bin/cp/Makefile
index 7108f71..9180efe 100644
--- a/bin/cp/Makefile
+++ b/bin/cp/Makefile
@@ -4,6 +4,5 @@
PROG= cp
SRCS= cp.c utils.c
CFLAGS+= -DVM_AND_BUFFER_CACHE_SYNCHRONIZED
-WARNS= 0
.include <bsd.prog.mk>
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index 0aede8b..21439d8a 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -82,9 +82,12 @@ static const char rcsid[] =
*--(p).p_end = 0; \
}
-PATH_T to = { to.p_path, "", "" };
+static char emptystring[] = "";
-int Rflag, iflag, pflag, rflag, fflag, vflag;
+PATH_T to = { to.p_path, emptystring, "" };
+
+int iflag, pflag, fflag;
+static int Rflag, rflag, vflag;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -241,7 +244,8 @@ 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 = 0, dne, badcp, rval;
+ size_t nlen;
char *p, *target_mid;
mode_t mask, mode;
@@ -267,6 +271,7 @@ copy(char *argv[], enum op type, int fts_options)
warnx("%s: directory causes a cycle", curr->fts_path);
badcp = rval = 1;
continue;
+ default:
}
/*
@@ -370,7 +375,8 @@ copy(char *argv[], enum op type, int fts_options)
}
if (!S_ISDIR(curr->fts_statp->st_mode) &&
S_ISDIR(to_stat.st_mode)) {
- warnx("cannot overwrite directory %s with non-directory %s",
+ warnx("cannot overwrite directory %s with "
+ "non-directory %s",
to.p_path, curr->fts_path);
badcp = rval = 1;
continue;
diff --git a/bin/cp/extern.h b/bin/cp/extern.h
index 5647b5f..74536c3 100644
--- a/bin/cp/extern.h
+++ b/bin/cp/extern.h
@@ -35,15 +35,13 @@
*/
typedef struct {
- char *p_end; /* pointer to NULL at end of path */
- char *target_end; /* pointer to end of target base */
- char p_path[PATH_MAX]; /* pointer to the start of a path */
+ char *p_end; /* pointer to NULL at end of path */
+ char *target_end; /* pointer to end of target base */
+ char p_path[PATH_MAX]; /* pointer to the start of a path */
} PATH_T;
extern PATH_T to;
-extern int iflag, pflag, fflag, vflag;
-
-#include <sys/cdefs.h>
+extern int iflag, pflag, fflag;
__BEGIN_DECLS
int copy_fifo(struct stat *, int);
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index d6eb0b1..aea1ce3 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -41,7 +41,6 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/stat.h>
-#include <sys/time.h>
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
#include <sys/mman.h>
#endif
@@ -115,7 +114,7 @@ copy_file(FTSENT *entp, int dne)
if (to_fd == -1) {
warn("%s", to.p_path);
(void)close(from_fd);
- return (1);;
+ return (1);
}
rval = 0;
@@ -191,19 +190,19 @@ int
copy_link(FTSENT *p, int exists)
{
int len;
- char link[PATH_MAX];
+ char llink[PATH_MAX];
- if ((len = readlink(p->fts_path, link, sizeof(link) - 1)) == -1) {
+ if ((len = readlink(p->fts_path, llink, sizeof(llink) - 1)) == -1) {
warn("readlink: %s", p->fts_path);
return (1);
}
- link[len] = '\0';
+ llink[len] = '\0';
if (exists && unlink(to.p_path)) {
warn("unlink: %s", to.p_path);
return (1);
}
- if (symlink(link, to.p_path)) {
- warn("symlink: %s", link);
+ if (symlink(llink, to.p_path)) {
+ warn("symlink: %s", llink);
return (1);
}
return (0);
@@ -237,9 +236,6 @@ copy_special(struct stat *from_stat, int exists)
return (pflag ? setfile(from_stat, 0) : 0);
}
-#define RETAINBITS \
- (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
-
int
setfile(struct stat *fs, int fd)
{
OpenPOWER on IntegriCloud