From 940a5a2d01caf7ee6040d40b0224e1e4ac00e2ee Mon Sep 17 00:00:00 2001 From: guenther Date: Wed, 21 Jan 2015 03:18:31 +0000 Subject: [PATCH] Reduce opt_t from long to int. Debug message consistency: format opts with %#x and modes with %#04o --- usr.bin/rdist/client.c | 37 ++++++++++++++++++------------------- usr.bin/rdist/types.h | 4 ++-- usr.bin/rdistd/server.c | 40 +++++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/usr.bin/rdist/client.c b/usr.bin/rdist/client.c index c5081cc8eae..3bf967e49a8 100644 --- a/usr.bin/rdist/client.c +++ b/usr.bin/rdist/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.33 2015/01/20 09:00:16 guenther Exp $ */ +/* $OpenBSD: client.c,v 1.34 2015/01/21 03:18:31 guenther Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -371,8 +371,7 @@ sendhardlink(opt_t opts, struct linkbuf *lp, char *rname, int destdir) } ENCODE(elname, lname); ENCODE(ername, rname); - (void) sendcmd(C_RECVHARDLINK, "%lo %s %s", - opts, elname, ername); + (void) sendcmd(C_RECVHARDLINK, "%o %s %s", opts, elname, ername); return(response()); } @@ -405,7 +404,7 @@ sendfile(char *rname, opt_t opts, struct stat *stb, char *user, */ ENCODE(ername, rname); - (void) sendcmd(C_RECVREG, "%lo %04o %lld %lld %lld %s %s %s", + (void) sendcmd(C_RECVREG, "%o %04o %lld %lld %lld %s %s %s", opts, stb->st_mode & 07777, (long long) stb->st_size, (long long)stb->st_mtime, (long long)stb->st_atime, user, group, ername); @@ -594,7 +593,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, "%lo %04o 0 0 0 %s %s %s", + (void) sendcmd(C_RECVDIR, "%o %04o 0 0 0 %s %s %s", opts, stb->st_mode & 07777, user, group, ername); if (response() < 0) return(-1); @@ -664,7 +663,7 @@ sendlink(char *rname, opt_t opts, struct stat *stb, char *user, u_char *s; char ername[PATH_MAX*4]; - debugmsg(DM_CALL, "sendlink(%s, %lx, stb, %d)\n", rname, opts, destdir); + debugmsg(DM_CALL, "sendlink(%s, %#x, stb, %d)\n", rname, opts, destdir); if (stb->st_nlink > 1) { struct linkbuf *lp; @@ -677,7 +676,7 @@ sendlink(char *rname, opt_t opts, struct stat *stb, char *user, * Gather and send basic link info */ ENCODE(ername, rname); - (void) sendcmd(C_RECVSYMLINK, "%lo %04o %lld %lld %lld %s %s %s", + (void) sendcmd(C_RECVSYMLINK, "%o %04o %lld %lld %lld %s %s %s", opts, stb->st_mode & 07777, (long long) stb->st_size, (long long)stb->st_mtime, (long long)stb->st_atime, user, group, ername); @@ -783,7 +782,7 @@ update(char *rname, opt_t opts, struct stat *statp) u_char *cp; char ername[PATH_MAX*4]; - debugmsg(DM_CALL, "update(%s, 0x%lx, %p)\n", rname, opts, statp); + debugmsg(DM_CALL, "update(%s, %#x, %p)\n", rname, opts, statp); switch (statp->st_mode & S_IFMT) { case S_IFBLK: @@ -930,7 +929,7 @@ update(char *rname, opt_t opts, struct stat *statp) */ lmode = statp->st_mode & 07777; - debugmsg(DM_MISC, "update(%s,) local mode %04o remote mode %04o\n", + debugmsg(DM_MISC, "update(%s,) local mode %#04o remote mode %#04o\n", rname, lmode, rmode); debugmsg(DM_MISC, "update(%s,) size %lld mtime %lld owner '%s' grp '%s'" "\n", rname, (long long) size, (long long)mtime, owner, group); @@ -952,7 +951,7 @@ update(char *rname, opt_t opts, struct stat *statp) } if (!IS_ON(opts, DO_NOCHKMODE) && lmode != rmode) { - debugmsg(DM_MISC, "modes do not match (%04o != %04o).\n", + debugmsg(DM_MISC, "modes do not match (%#04o != %#04o).\n", lmode, rmode); return(US_CHMOG); } @@ -1051,15 +1050,15 @@ statupdate(int u, char *starget, opt_t opts, char *rname, int destdir, if (u == US_CHMOG) { if (IS_ON(opts, DO_VERIFY)) { message(MT_INFO, - "%s: need to change to perm %04o, owner %s, group %s", + "%s: need to change to perm %#04o, owner %s, group %s", starget, lmode, user, group); runspecial(starget, opts, rname, destdir); } else { - message(MT_CHANGE, "%s: change to perm %04o, owner %s, group %s", + message(MT_CHANGE, "%s: change to perm %#04o, owner %s, group %s", starget, lmode, user, group); ENCODE(ername, rname); - (void) sendcmd(C_CHMOG, "%lo %04o %s %s %s", + (void) sendcmd(C_CHMOG, "%o %04o %s %s %s", opts, lmode, user, group, ername); (void) response(); } @@ -1121,7 +1120,7 @@ fullupdate(int u, char *starget, opt_t opts, char *rname, int destdir, } return (sendfile(rname, opts, st, user, group, destdir) == 0); } else { - message(MT_INFO, "%s: unknown file type 0%o", starget, + message(MT_INFO, "%s: unknown file type %#o", starget, st->st_mode); return(0); } @@ -1152,7 +1151,7 @@ sendit(char *rname, opt_t opts, int destdir) if (checkfilename(rname) != 0) return(-1); - debugmsg(DM_CALL, "sendit(%s, 0x%lx) called\n", rname, opts); + debugmsg(DM_CALL, "sendit(%s, %#x) called\n", rname, opts); if (except(target)) return(0); @@ -1164,7 +1163,7 @@ sendit(char *rname, opt_t opts, int destdir) * Does rname need updating? */ u = update(rname, opts, &stb); - debugmsg(DM_MISC, "sendit(%s, 0x%lx): update status of %s is %d\n", + debugmsg(DM_MISC, "sendit(%s, %#x): update status of %s is %d\n", rname, opts, target, u); /* @@ -1224,7 +1223,7 @@ install(char *src, char *dest, int ddir, int destdir, opt_t opts) char ername[PATH_MAX*4]; debugmsg(DM_CALL, - "install(src=%s,dest=%s,ddir=%d,destdir=%d,opts=%ld) start\n", + "install(src=%s,dest=%s,ddir=%d,destdir=%d,opts=%#x) start\n", (src?src:"NULL"), (dest?dest:"NULL"), ddir, destdir, opts); /* * Save source name @@ -1294,9 +1293,9 @@ install(char *src, char *dest, int ddir, int destdir, opt_t opts) */ ENCODE(ername, dest); if (ddir) - (void) sendcmd(C_DIRTARGET, "%lo %s", opts, ername); + (void) sendcmd(C_DIRTARGET, "%o %s", opts, ername); else - (void) sendcmd(C_TARGET, "%lo %s", opts, ername); + (void) sendcmd(C_TARGET, "%o %s", opts, ername); if (response() < 0) return(-1); diff --git a/usr.bin/rdist/types.h b/usr.bin/rdist/types.h index 62e5bb10f6d..63371665fb8 100644 --- a/usr.bin/rdist/types.h +++ b/usr.bin/rdist/types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: types.h,v 1.7 2015/01/20 06:08:08 guenther Exp $ */ +/* $OpenBSD: types.h,v 1.8 2015/01/21 03:18:31 guenther Exp $ */ #ifndef __myTYPES_H__ #define __myTYPES_H__ @@ -37,7 +37,7 @@ #define DO_DEFOWNER 0x0800000 #define DO_SPARSE 0x1000000 /* XXX not implemented */ -typedef long opt_t; +typedef int opt_t; /* Debug Message types */ #define DM_CALL 0x01 diff --git a/usr.bin/rdistd/server.c b/usr.bin/rdistd/server.c index dcad7801897..a318ded3f71 100644 --- a/usr.bin/rdistd/server.c +++ b/usr.bin/rdistd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.35 2015/01/20 09:00:16 guenther Exp $ */ +/* $OpenBSD: server.c,v 1.36 2015/01/21 03:18:31 guenther Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -653,7 +653,7 @@ chkparent(char *name, opt_t opts) struct stat stb; int r = -1; - debugmsg(DM_CALL, "chkparent(%s, %lo) start\n", name, opts); + debugmsg(DM_CALL, "chkparent(%s, %#x) start\n", name, opts); cp = strrchr(name, '/'); if (cp == NULL || cp == name) @@ -668,7 +668,7 @@ chkparent(char *name, opt_t opts) r = 0; } else debugmsg(DM_MISC, - "chkparent(%s, %lo) mkdir fail: %s\n", + "chkparent(%s, %#04o) mkdir fail: %s\n", name, opts, SYSERR); } } else /* It exists */ @@ -996,23 +996,21 @@ recvdir(opt_t opts, int mode, char *owner, char *group) (stb.st_mode & 07777) != mode) { if (IS_ON(opts, DO_VERIFY)) message(MT_NOTICE, - "%s: need to chmod to %o", + "%s: need to chmod to %#04o", target, mode); - else { - if (chmod(target, mode) != 0) - message(MT_NOTICE, - "%s: chmod from %o to %o failed: %s", - target, - stb.st_mode & 07777, - mode, - SYSERR); - else - message(MT_NOTICE, - "%s: chmod from %o to %o", - target, - stb.st_mode & 07777, - mode); - } + else if (chmod(target, mode) != 0) + message(MT_NOTICE, + "%s: chmod from %#04o to %#04o failed: %s", + target, + stb.st_mode & 07777, + mode, + SYSERR); + else + message(MT_NOTICE, + "%s: chmod from %#04o to %#04o", + target, + stb.st_mode & 07777, + mode); } /* @@ -1448,7 +1446,7 @@ recvit(char *cmd, int type) file = fileb; debugmsg(DM_MISC, - "recvit: opts = %04lo mode = %04o size = %lld mtime = %lld", + "recvit: opts = %#x 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", @@ -1604,7 +1602,7 @@ dochmog(char *cmd) file = fileb; debugmsg(DM_MISC, - "dochmog: opts = %04lo mode = %04o", opts, mode); + "dochmog: opts = %#x mode = %#04o", opts, mode); debugmsg(DM_MISC, "dochmog: owner = '%s' group = '%s' file = '%s' catname = %d", owner, group, file, catname); -- 2.20.1