summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2012-11-12 01:14:42 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2012-11-12 01:14:42 +0000
commit1af61169269325a8703f15fe704b911bf9a2892b (patch)
tree9a1e0d1f082bd986f7b7a348aa8c6a5a5de77d0a /usr.bin
parent439a2e177c7fc7552c89d2d52714439665db3dc6 (diff)
Fix various format string issues. Stop assuming time_t is long or smaller.
Enable warnings. ok krw@, ian@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rdist/Makefile3
-rw-r--r--usr.bin/rdist/client.c36
-rw-r--r--usr.bin/rdist/defs.h12
-rw-r--r--usr.bin/rdist/docmd.c12
-rw-r--r--usr.bin/rdist/expand.c4
-rw-r--r--usr.bin/rdist/gram.y4
-rw-r--r--usr.bin/rdist/lookup.c4
-rw-r--r--usr.bin/rdistd/Makefile3
-rw-r--r--usr.bin/rdistd/server.c21
9 files changed, 51 insertions, 48 deletions
diff --git a/usr.bin/rdist/Makefile b/usr.bin/rdist/Makefile
index 98f0126822b..94e53be7a8c 100644
--- a/usr.bin/rdist/Makefile
+++ b/usr.bin/rdist/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.15 2004/01/05 02:55:28 espie Exp $
+# $OpenBSD: Makefile,v 1.16 2012/11/12 01:14:41 guenther Exp $
PROG= rdist
@@ -6,6 +6,7 @@ CFLAGS+=-I. -I${.CURDIR} -DOS_H=\"os-openbsd.h\"
SRCS= gram.y child.c client.c common.c distopt.c docmd.c expand.c \
isexec.c lookup.c message.c rdist.c
CLEANFILES+=gram.c y.tab.h
+WARNINGS=yes
.include <bsd.prog.mk>
diff --git a/usr.bin/rdist/client.c b/usr.bin/rdist/client.c
index 82844eaa8c1..076391dfa84 100644
--- a/usr.bin/rdist/client.c
+++ b/usr.bin/rdist/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.23 2011/04/10 15:47:28 krw Exp $ */
+/* $OpenBSD: client.c,v 1.24 2012/11/12 01:14:41 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -365,7 +365,7 @@ sendhardlink(opt_t opts, struct linkbuf *lp, char *rname, int destdir)
}
ENCODE(elname, lname);
ENCODE(ername, rname);
- (void) sendcmd(C_RECVHARDLINK, "%o %s %s",
+ (void) sendcmd(C_RECVHARDLINK, "%lo %s %s",
opts, elname, ername);
return(response());
@@ -399,9 +399,9 @@ sendfile(char *rname, opt_t opts, struct stat *stb, char *user,
*/
ENCODE(ername, rname);
- (void) sendcmd(C_RECVREG, "%o %04o %lld %ld %ld %s %s %s",
+ (void) sendcmd(C_RECVREG, "%lo %04o %lld %lld %lld %s %s %s",
opts, stb->st_mode & 07777, (long long) stb->st_size,
- stb->st_mtime, stb->st_atime,
+ (long long)stb->st_mtime, (long long)stb->st_atime,
user, group, ername);
if (response() < 0) {
(void) close(f);
@@ -588,7 +588,7 @@ senddir(char *rname, opt_t opts, struct stat *stb, char *user,
* Send recvdir command in recvit() format.
*/
ENCODE(ername, rname);
- (void) sendcmd(C_RECVDIR, "%o %04o 0 0 0 %s %s %s",
+ (void) sendcmd(C_RECVDIR, "%lo %04o 0 0 0 %s %s %s",
opts, stb->st_mode & 07777, user, group, ername);
if (response() < 0)
return(-1);
@@ -597,7 +597,7 @@ senddir(char *rname, opt_t opts, struct stat *stb, char *user,
* Don't descend into directory
*/
if (IS_ON(opts, DO_NODESCEND))
- return(0);
+ goto out;
if (IS_ON(opts, DO_REMOVE))
if (rmchk(opts) > 0)
@@ -653,7 +653,7 @@ sendlink(char *rname, opt_t opts, struct stat *stb, char *user,
u_char *s;
char ername[MAXPATHLEN*4];
- debugmsg(DM_CALL, "sendlink(%s, %x, stb, %d)\n", rname, opts, destdir);
+ debugmsg(DM_CALL, "sendlink(%s, %lx, stb, %d)\n", rname, opts, destdir);
if (stb->st_nlink > 1) {
struct linkbuf *lp;
@@ -666,9 +666,9 @@ sendlink(char *rname, opt_t opts, struct stat *stb, char *user,
* Gather and send basic link info
*/
ENCODE(ername, rname);
- (void) sendcmd(C_RECVSYMLINK, "%o %04o %lld %ld %ld %s %s %s",
+ (void) sendcmd(C_RECVSYMLINK, "%lo %04o %lld %lld %lld %s %s %s",
opts, stb->st_mode & 07777, (long long) stb->st_size,
- stb->st_mtime, stb->st_atime,
+ (long long)stb->st_mtime, (long long)stb->st_atime,
user, group, ername);
if (response() < 0)
return(-1);
@@ -772,7 +772,7 @@ update(char *rname, opt_t opts, struct stat *statp)
u_char *cp;
char ername[MAXPATHLEN*4];
- debugmsg(DM_CALL, "update(%s, 0x%x, 0x%x)\n", rname, opts, statp);
+ debugmsg(DM_CALL, "update(%s, 0x%lx, %p)\n", rname, opts, statp);
switch (statp->st_mode & S_IFMT) {
case S_IFBLK:
@@ -921,8 +921,8 @@ update(char *rname, opt_t opts, struct stat *statp)
debugmsg(DM_MISC, "update(%s,) local mode %04o remote mode %04o\n",
rname, lmode, rmode);
- debugmsg(DM_MISC, "update(%s,) size %lld mtime %d owner '%s' grp '%s'"
- "\n", rname, (long long) size, mtime, owner, group);
+ debugmsg(DM_MISC, "update(%s,) size %lld mtime %lld owner '%s' grp '%s'"
+ "\n", rname, (long long) size, (long long)mtime, owner, group);
if (statp->st_mtime != mtime) {
if (statp->st_mtime < mtime && IS_ON(opts, DO_YOUNGER)) {
@@ -1048,7 +1048,7 @@ statupdate(int u, char *target, opt_t opts, char *rname, int destdir,
message(MT_CHANGE, "%s: change to perm %04o, owner %s, group %s",
target, lmode, user, group);
ENCODE(ername, rname);
- (void) sendcmd(C_CHMOG, "%o %04o %s %s %s",
+ (void) sendcmd(C_CHMOG, "%lo %04o %s %s %s",
opts, lmode, user, group, ername);
(void) response();
}
@@ -1141,7 +1141,7 @@ sendit(char *rname, opt_t opts, int destdir)
if (checkfilename(rname) != 0)
return(-1);
- debugmsg(DM_CALL, "sendit(%s, 0x%x) called\n", rname, opts);
+ debugmsg(DM_CALL, "sendit(%s, 0x%lx) called\n", rname, opts);
if (except(target))
return(0);
@@ -1153,7 +1153,7 @@ sendit(char *rname, opt_t opts, int destdir)
* Does rname need updating?
*/
u = update(rname, opts, &stb);
- debugmsg(DM_MISC, "sendit(%s, 0x%x): update status of %s is %d\n",
+ debugmsg(DM_MISC, "sendit(%s, 0x%lx): update status of %s is %d\n",
rname, opts, target, u);
/*
@@ -1218,7 +1218,7 @@ install(char *src, char *dest, int ddir, int destdir, opt_t opts)
char ername[MAXPATHLEN*4];
debugmsg(DM_CALL,
- "install(src=%s,dest=%s,ddir=%d,destdir=%d,opts=%d) start\n",
+ "install(src=%s,dest=%s,ddir=%d,destdir=%d,opts=%ld) start\n",
(src?src:"NULL"), (dest?dest:"NULL"), ddir, destdir, opts);
/*
* Save source name
@@ -1288,9 +1288,9 @@ install(char *src, char *dest, int ddir, int destdir, opt_t opts)
*/
ENCODE(ername, dest);
if (ddir)
- (void) sendcmd(C_DIRTARGET, "%o %s", opts, ername);
+ (void) sendcmd(C_DIRTARGET, "%lo %s", opts, ername);
else
- (void) sendcmd(C_TARGET, "%o %s", opts, ername);
+ (void) sendcmd(C_TARGET, "%lo %s", opts, ername);
if (response() < 0)
return(-1);
diff --git a/usr.bin/rdist/defs.h b/usr.bin/rdist/defs.h
index 5dc77403c04..687f61d2799 100644
--- a/usr.bin/rdist/defs.h
+++ b/usr.bin/rdist/defs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: defs.h,v 1.17 2011/04/10 15:47:28 krw Exp $ */
+/* $OpenBSD: defs.h,v 1.18 2012/11/12 01:14:41 guenther Exp $ */
#ifndef __DEFS_H__
#define __DEFS_H__
@@ -368,7 +368,7 @@ void finish(void);
void lostconn(void);
void coredump(void);
void sighandler(int);
-int sendcmd(char, char *, ...);
+int sendcmd(char, char *, ...) __attribute__((__format__ (printf, 2, 3)));
int remline(u_char *, int, int);
ssize_t readrem(char *, ssize_t);
char *getusername(UID_T, char *, opt_t);
@@ -449,10 +449,10 @@ void msgprusage(void);
void msgprconfig(void);
char *msgparseopts(char *, int);
void checkhostname(void);
-void message(int, char *, ...);
-void debugmsg(int, char *, ...);
-void error(char *, ...);
-void fatalerr(char *, ...);
+void message(int, char *, ...) __attribute__((__format__ (printf, 2, 3)));
+void debugmsg(int, char *, ...) __attribute__((__format__ (printf, 2, 3)));
+void error(char *, ...) __attribute__((__format__ (printf, 1, 2)));
+void fatalerr(char *, ...) __attribute__((__format__ (printf, 1, 2)));
char *getnotifyfile(void);
/* rdist.c */
diff --git a/usr.bin/rdist/docmd.c b/usr.bin/rdist/docmd.c
index fb14ded7830..ad0645c2b9f 100644
--- a/usr.bin/rdist/docmd.c
+++ b/usr.bin/rdist/docmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: docmd.c,v 1.24 2011/04/21 02:44:15 krw Exp $ */
+/* $OpenBSD: docmd.c,v 1.25 2012/11/12 01:14:41 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -470,7 +470,7 @@ doarrow(struct cmd *cmd, char **filev)
return;
}
- debugmsg(DM_CALL, "doarrow(%x, %s, %x) start",
+ debugmsg(DM_CALL, "doarrow(%p, %s, %p) start",
files, A(rhost), sbcmds);
if (nflag)
@@ -534,7 +534,7 @@ doarrow(struct cmd *cmd, char **filev)
destdir = ddir;
debugmsg(DM_MISC,
- "Debug files->n_next= %d, destdir=%d, ddir=%d",
+ "Debug files->n_next= %p, destdir=%d, ddir=%d",
files->n_next, destdir, ddir);
if (!sc->sc_name || !*sc->sc_name) {
@@ -543,7 +543,7 @@ doarrow(struct cmd *cmd, char **filev)
}
debugmsg(DM_MISC,
- "Debug sc->sc_name=%x, destdir=%d, ddir=%d",
+ "Debug sc->sc_name=%p, destdir=%d, ddir=%d",
sc->sc_name, destdir, ddir);
for (f = files; f != NULL; f = f->n_next) {
@@ -641,7 +641,7 @@ rcmptime(struct stat *st, struct subcmd *sbcmds, char **env)
char *optarget;
int len;
- debugmsg(DM_CALL, "rcmptime(%x) start", st);
+ debugmsg(DM_CALL, "rcmptime(%p) start", st);
if ((d = opendir((char *) target)) == NULL) {
error("%s: open directory failed: %s", target, SYSERR);
@@ -762,7 +762,7 @@ dodcolon(struct cmd *cmd, char **filev)
return;
}
- debugmsg(DM_MISC, "%s: mtime %d\n", stamp, stb.st_mtime);
+ debugmsg(DM_MISC, "%s: mtime %lld\n", stamp, (long long)stb.st_mtime);
env = NULL;
for (sc = sbcmds; sc != NULL; sc = sc->sc_next) {
diff --git a/usr.bin/rdist/expand.c b/usr.bin/rdist/expand.c
index 4e47670778d..f9d86419034 100644
--- a/usr.bin/rdist/expand.c
+++ b/usr.bin/rdist/expand.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: expand.c,v 1.12 2009/10/27 23:59:42 deraadt Exp $ */
+/* $OpenBSD: expand.c,v 1.13 2012/11/12 01:14:41 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -112,7 +112,7 @@ expand(struct namelist *list, int wh) /* quote in list->n_name */
char pathbuf[BUFSIZ];
if (debug)
- debugmsg(DM_CALL, "expand(%x, %d) start, list = %s",
+ debugmsg(DM_CALL, "expand(%p, %d) start, list = %s",
list, wh, getnlstr(list));
if (wh == 0)
diff --git a/usr.bin/rdist/gram.y b/usr.bin/rdist/gram.y
index 097583d2d8c..3f321cee479 100644
--- a/usr.bin/rdist/gram.y
+++ b/usr.bin/rdist/gram.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: gram.y,v 1.9 2009/10/27 23:59:42 deraadt Exp $ */
+/* $OpenBSD: gram.y,v 1.10 2012/11/12 01:14:41 guenther Exp $ */
/*
* Copyright (c) 1993 Michael A. Cooper
@@ -413,7 +413,7 @@ insert(char *label, struct namelist *files, struct namelist *hosts,
struct cmd *c, *prev, *nc;
struct namelist *h, *lasth;
- debugmsg(DM_CALL, "insert(%s, %x, %x, %x) start, files = %s",
+ debugmsg(DM_CALL, "insert(%s, %p, %p, %p) start, files = %s",
label == NULL ? "(null)" : label,
files, hosts, subcmds, getnlstr(files));
diff --git a/usr.bin/rdist/lookup.c b/usr.bin/rdist/lookup.c
index 868130c9d8e..71f0d7b33e5 100644
--- a/usr.bin/rdist/lookup.c
+++ b/usr.bin/rdist/lookup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lookup.c,v 1.13 2009/10/27 23:59:42 deraadt Exp $ */
+/* $OpenBSD: lookup.c,v 1.14 2012/11/12 01:14:41 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -118,7 +118,7 @@ lookup(char *name, int action, struct namelist *value)
struct syment *s;
char ebuf[BUFSIZ];
- debugmsg(DM_CALL, "lookup(%s, %d, %x)", name, action, value);
+ debugmsg(DM_CALL, "lookup(%s, %d, %p)", name, action, value);
n = 0;
for (cp = name; *cp; )
diff --git a/usr.bin/rdistd/Makefile b/usr.bin/rdistd/Makefile
index 7dcca7df29d..bac7456575d 100644
--- a/usr.bin/rdistd/Makefile
+++ b/usr.bin/rdistd/Makefile
@@ -1,8 +1,9 @@
-# $OpenBSD: Makefile,v 1.4 2003/05/06 22:10:11 millert Exp $
+# $OpenBSD: Makefile,v 1.5 2012/11/12 01:14:41 guenther Exp $
PROG= rdistd
SRCS= common.c filesys-os.c filesys.c message.c rdistd.c server.c
.PATH: ${.CURDIR}/../rdist
CFLAGS+=-I${.CURDIR}/../rdist -DOS_H=\"os-openbsd.h\"
+WARNINGS=yes
.include <bsd.prog.mk>
diff --git a/usr.bin/rdistd/server.c b/usr.bin/rdistd/server.c
index ab4343583d2..59b1a775ef4 100644
--- a/usr.bin/rdistd/server.c
+++ b/usr.bin/rdistd/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.22 2011/04/10 15:47:28 krw Exp $ */
+/* $OpenBSD: server.c,v 1.23 2012/11/12 01:14:41 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -656,8 +656,9 @@ query(char *xname)
case S_IFIFO:
#endif
#endif
- (void) sendcmd(QC_YES, "%lld %ld %o %s %s",
- (long long) stb.st_size, stb.st_mtime,
+ (void) sendcmd(QC_YES, "%lld %lld %o %s %s",
+ (long long) stb.st_size,
+ (long long) stb.st_mtime,
stb.st_mode & 07777,
getusername(stb.st_uid, target, options),
getgroupname(stb.st_gid, target, options));
@@ -680,7 +681,7 @@ chkparent(char *name, opt_t opts)
struct stat stb;
int r = -1;
- debugmsg(DM_CALL, "chkparent(%s, %o) start\n", name, opts);
+ debugmsg(DM_CALL, "chkparent(%s, %lo) start\n", name, opts);
cp = strrchr(name, '/');
if (cp == NULL || cp == name)
@@ -695,7 +696,7 @@ chkparent(char *name, opt_t opts)
r = 0;
} else
debugmsg(DM_MISC,
- "chkparent(%s, %o) mkdir fail: %s\n",
+ "chkparent(%s, %lo) mkdir fail: %s\n",
name, opts, SYSERR);
}
} else /* It exists */
@@ -1428,7 +1429,7 @@ recvit(char *cmd, int type)
/*
* Get modification time
*/
- mtime = (time_t) strtol(cp, &cp, 10);
+ mtime = (time_t) strtoll(cp, &cp, 10);
if (*cp++ != ' ') {
error("recvit: mtime not delimited");
return;
@@ -1437,7 +1438,7 @@ recvit(char *cmd, int type)
/*
* Get access time
*/
- atime = strtol(cp, &cp, 10);
+ atime = (time_t) strtoll(cp, &cp, 10);
if (*cp++ != ' ') {
error("recvit: atime not delimited");
return;
@@ -1477,8 +1478,8 @@ recvit(char *cmd, int type)
file = fileb;
debugmsg(DM_MISC,
- "recvit: opts = %04o mode = %04o size = %lld mtime = %d",
- opts, mode, (long long) size, mtime);
+ "recvit: opts = %04lo mode = %04o size = %lld mtime = %lld",
+ opts, mode, (long long) size, (long long)mtime);
debugmsg(DM_MISC,
"recvit: owner = '%s' group = '%s' file = '%s' catname = %d isdir = %d",
owner, group, file, catname, (type == S_IFDIR) ? 1 : 0);
@@ -1633,7 +1634,7 @@ dochmog(char *cmd)
file = fileb;
debugmsg(DM_MISC,
- "dochmog: opts = %04o mode = %04o", opts, mode);
+ "dochmog: opts = %04lo mode = %04o", opts, mode);
debugmsg(DM_MISC,
"dochmog: owner = '%s' group = '%s' file = '%s' catname = %d",
owner, group, file, catname);