From 29387bc74b55a35e4ed6815fd886a06b9a573a48 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Tue, 17 Mar 2009 04:51:50 +0000 Subject: [PATCH] DEVEL15-printf-sanity-20090317 LICENSE IPL10 FIXES 124239 sanitize the arguments to printf to minimize warnings (cherry picked from commit 355344253605925972ea032d05dcb5fee3d8c3b6) --- src/afsd/afsd.c | 2 +- src/auth/ktc.c | 2 +- src/bozo/bnode.c | 24 +++++++------- src/bozo/bos.c | 4 +-- src/bucoord/commands.c | 2 +- src/butc/dump.c | 2 +- src/butc/tcmain.c | 2 +- src/config/stds.h | 7 ++++ src/des/quad_cksum.c | 1 + src/kauth/admin_tools.c | 11 ++++--- src/kauth/rebuild.c | 6 ++-- src/ptserver/db_verify.c | 2 +- src/ptserver/ptserver.c | 2 +- src/ubik/udebug.c | 23 +++++++------ src/ubik/utst_client.c | 7 ++-- src/uss/uss_acl.c | 2 +- src/viced/callback.c | 6 ++-- src/vlserver/cnvldb.c | 2 +- src/vlserver/vldb_check.c | 34 ++++++++++---------- src/vlserver/vlserver.c | 2 +- src/volser/volmain.c | 2 +- src/volser/vos.c | 68 ++++++++++++++++++++++++++------------- 22 files changed, 127 insertions(+), 86 deletions(-) diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index ec1879a2f..53784b8d7 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -1935,7 +1935,7 @@ mainproc(struct cmd_syndesc *as, void *arock) } memset(inode_for_V, '\0', (cacheFiles * sizeof(AFSD_INO_T))); if (afsd_debug) - printf("%s: %d inode_for_V entries at 0x%x, %d bytes\n", rn, + printf("%s: %d inode_for_V entries at 0x%x, %lu bytes\n", rn, cacheFiles, inode_for_V, (cacheFiles * sizeof(AFSD_INO_T))); #endif diff --git a/src/auth/ktc.c b/src/auth/ktc.c index f83af5b9c..3387222e2 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -1667,7 +1667,7 @@ ktc_newpag(void) if (pag == -1) { sprintf(fname, "%s%d", prefix, getuid()); } else { - sprintf(fname, "%sp%ld", prefix, (long int) pag); + sprintf(fname, "%sp%lu", prefix, afs_cast_uint32(pag)); } ktc_set_tkt_string(fname); diff --git a/src/bozo/bnode.c b/src/bozo/bnode.c index a68e3d023..50468e9a2 100644 --- a/src/bozo/bnode.c +++ b/src/bozo/bnode.c @@ -702,15 +702,15 @@ SendNotifierData(register int fd, register struct bnode_proc *tp) buf1 = "(null)"; (void)sprintf(bufp, "coreName: %s\n", buf1); bufp += strlen(bufp); - (void)sprintf(bufp, "pid: %ld\n", (long int)tp->pid); + (void)sprintf(bufp, "pid: %ld\n", afs_cast_int32(tp->pid)); bufp += strlen(bufp); - (void)sprintf(bufp, "lastExit: %ld\n", (long int)tp->lastExit); + (void)sprintf(bufp, "lastExit: %ld\n", afs_cast_int32(tp->lastExit)); bufp += strlen(bufp); #ifdef notdef - (void)sprintf(bufp, "lastSignal: %ld\n", (long int)tp->lastSignal); + (void)sprintf(bufp, "lastSignal: %ld\n", afs_cast_int32(tp->lastSignal)); bufp += strlen(bufp); #endif - (void)sprintf(bufp, "flags: %ld\n", (long int)tp->flags); + (void)sprintf(bufp, "flags: %ld\n", afs_cast_int32(tp->flags)); bufp += strlen(bufp); (void)sprintf(bufp, "END bnode_proc\n"); bufp += strlen(bufp); @@ -727,21 +727,21 @@ SendNotifierData(register int fd, register struct bnode_proc *tp) bufp += strlen(bufp); (void)sprintf(bufp, "name: %s\n", tb->name); bufp += strlen(bufp); - (void)sprintf(bufp, "rsTime: %ld\n", (long int)tb->rsTime); + (void)sprintf(bufp, "rsTime: %ld\n", afs_cast_int32(tb->rsTime)); bufp += strlen(bufp); - (void)sprintf(bufp, "rsCount: %ld\n", (long int)tb->rsCount); + (void)sprintf(bufp, "rsCount: %ld\n", afs_cast_int32(tb->rsCount)); bufp += strlen(bufp); - (void)sprintf(bufp, "procStartTime: %ld\n", (long int)tb->procStartTime); + (void)sprintf(bufp, "procStartTime: %ld\n", afs_cast_int32(tb->procStartTime)); bufp += strlen(bufp); - (void)sprintf(bufp, "procStarts: %ld\n", (long int)tb->procStarts); + (void)sprintf(bufp, "procStarts: %ld\n", afs_cast_int32(tb->procStarts)); bufp += strlen(bufp); - (void)sprintf(bufp, "lastAnyExit: %ld\n", (long int)tb->lastAnyExit); + (void)sprintf(bufp, "lastAnyExit: %ld\n", afs_cast_int32(tb->lastAnyExit)); bufp += strlen(bufp); - (void)sprintf(bufp, "lastErrorExit: %ld\n", (long int)tb->lastErrorExit); + (void)sprintf(bufp, "lastErrorExit: %ld\n", afs_cast_int32(tb->lastErrorExit)); bufp += strlen(bufp); - (void)sprintf(bufp, "errorCode: %ld\n", (long int)tb->errorCode); + (void)sprintf(bufp, "errorCode: %ld\n", afs_cast_int32(tb->errorCode)); bufp += strlen(bufp); - (void)sprintf(bufp, "errorSignal: %ld\n", (long int)tb->errorSignal); + (void)sprintf(bufp, "errorSignal: %ld\n", afs_cast_int32(tb->errorSignal)); bufp += strlen(bufp); /* (void) sprintf(bufp, "lastErrorName: %s\n", tb->lastErrorName); diff --git a/src/bozo/bos.c b/src/bozo/bos.c index f3a63f963..0c0dfc4d3 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -1357,14 +1357,14 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, if (mrafsParm->OptDontAskFS) strcat(tbuffer, " -DontAskFS"); if (mrafsParm->OptLogLevel) { - sprintf(pbuffer, " -LogLevel %ld", (long int) mrafsParm->OptLogLevel); + sprintf(pbuffer, " -LogLevel %ld", afs_cast_int32(mrafsParm->OptLogLevel)); strcat(tbuffer, pbuffer); } if (mrafsParm->OptRxDebug) strcat(tbuffer, " -rxdebug"); if (mrafsParm->OptResidencies) { sprintf(pbuffer, " -Residencies %lu", - (long unsigned int) mrafsParm->OptResidencies); + afs_cast_uint32(mrafsParm->OptResidencies)); strcat(tbuffer, pbuffer); } } diff --git a/src/bucoord/commands.c b/src/bucoord/commands.c index ffb468f78..e494555f8 100644 --- a/src/bucoord/commands.c +++ b/src/bucoord/commands.c @@ -941,7 +941,7 @@ bc_JobsCmd(struct cmd_syndesc *as, void *arock) if (statusPtr->dbDumpId) printf(": DumpID %u", statusPtr->dbDumpId); if (statusPtr->nKBytes) - printf(", %ld Kbytes", (long int) statusPtr->nKBytes); + printf(", %ld Kbytes", afs_cast_int32(statusPtr->nKBytes)); if (strlen(statusPtr->volumeName) != 0) printf(", volume %s", statusPtr->volumeName); diff --git a/src/butc/dump.c b/src/butc/dump.c index 5c08b67f0..e00f02174 100644 --- a/src/butc/dump.c +++ b/src/butc/dump.c @@ -1360,7 +1360,7 @@ Dumper(void *param) sprintf(line, "%-5d %02d/%02d/%04d %02d:%02d:%02d " "%02d/%02d/%04d %02d:%02d:%02d " "%02d:%02d:%02d " - "%s %d of %d volumes dumped (%ld KB)\n", taskId, + "%s %d of %d volumes dumped (%lu KB)\n", taskId, tmstart.tm_mon + 1, tmstart.tm_mday, tmstart.tm_year + 1900, tmstart.tm_hour, tmstart.tm_min, tmstart.tm_sec, tmend.tm_mon + 1, tmend.tm_mday, tmend.tm_year + 1900, diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c index 935aea406..b71e6d428 100644 --- a/src/butc/tcmain.c +++ b/src/butc/tcmain.c @@ -796,7 +796,7 @@ GetConfigParams(char *filename, afs_int32 port) statusSize *= BufferSize; if (statusSize < 0) statusSize = 0x7fffffff; /*max size */ - printf("Status every %ld Bytes\n", statusSize); + printf("Status every %ld Bytes\n", afs_cast_int32(statusSize)); } error_exit: diff --git a/src/config/stds.h b/src/config/stds.h index 43bef0464..d03171f9d 100644 --- a/src/config/stds.h +++ b/src/config/stds.h @@ -293,4 +293,11 @@ typedef struct afsUUID afsUUID; #define AFS_INT64_FMT "lld" #endif +/* Functions to safely cast afs_int32 and afs_uint32 so they can be used in + * printf statemements with %ld and %lu + */ + +static_inline long int afs_cast_int32(afs_int32 d) { return (long int) d; } +static_inline unsigned long int afs_cast_uint32(afs_uint32 d) { return (unsigned long int) d; } + #endif /* OPENAFS_CONFIG_AFS_STDS_H */ diff --git a/src/des/quad_cksum.c b/src/des/quad_cksum.c index 7ca92de26..5035d9fcf 100644 --- a/src/des/quad_cksum.c +++ b/src/des/quad_cksum.c @@ -65,6 +65,7 @@ #include #include +#include RCSID ("$Header$"); diff --git a/src/kauth/admin_tools.c b/src/kauth/admin_tools.c index 0a0f12533..4b233b812 100644 --- a/src/kauth/admin_tools.c +++ b/src/kauth/admin_tools.c @@ -1112,7 +1112,8 @@ Statistics(struct cmd_syndesc *as, void *arock) printf("Hash table utilization = %f%%\n", (double)dynamics.hashTableUtilization / 100.0); ka_timestr(dynamics.start_time, bob, KA_TIMESTR_LEN); - printf("From host %lx started at %s:\n", dynamics.host, bob); + printf("From host %lx started at %s:\n", + afs_cast_uint32(dynamics.host), bob); #define print_stat(name) if (dynamics.name.requests) printf (" of %d requests for %s, %d were aborted.\n", dynamics.name.requests, # name, dynamics.name.aborts) print_stat(Authenticate); @@ -1202,7 +1203,8 @@ DebugInfo(struct cmd_syndesc *as, void *arock) timeOffset, now - start); } ka_timestr(info.startTime, bob, KA_TIMESTR_LEN); - printf("From host %lx started %sat %s:\n", info.host, + printf("From host %lx started %sat %s:\n", + afs_cast_uint32(info.host), (info.noAuth ? "w/o authorization " : ""), bob); ka_timestr(info.lastTrans, bob, KA_TIMESTR_LEN); printf("Last trans was %s at %s\n", info.lastOperation, bob); @@ -1216,8 +1218,9 @@ DebugInfo(struct cmd_syndesc *as, void *arock) printf("Next autoCPW at %s or in %d updates.\n", bob, info.updatesRemaining); if (info.cheader_lock || info.keycache_lock) - printf("locks: cheader %08lx, keycache %08lx\n", info.cheader_lock, - info.keycache_lock); + printf("locks: cheader %08lx, keycache %08lx\n", + afs_cast_uint32(info.cheader_lock), + afs_cast_uint32(info.keycache_lock)); printf("Last authentication for %s, last admin user was %s\n", info.lastAuth, info.lastAdmin); printf("Last TGS op was a %s ticket was for %s\n", info.lastTGSServer, diff --git a/src/kauth/rebuild.c b/src/kauth/rebuild.c index 84d4ae717..2c76fca25 100644 --- a/src/kauth/rebuild.c +++ b/src/kauth/rebuild.c @@ -330,7 +330,7 @@ CheckHeader(struct kaheader *header) if (header->headerSize != sizeof(struct kaheader)) { code++; fprintf(stderr, - "HEADER SIZE WRONG: file indicates %d, should be %d\n", + "HEADER SIZE WRONG: file indicates %d, should be %lu\n", header->headerSize, sizeof(struct kaheader)); } if (header->hashsize != HASHSIZE) { @@ -436,7 +436,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock) if ((info.st_size - UBIK_HEADERSIZE) % UBIK_BUFFERSIZE) fprintf(stderr, "DATABASE SIZE INCONSISTENT: was %d, should be (n*%d + %d), for integral n\n", - info.st_size, UBIK_BUFFERSIZE, UBIK_HEADERSIZE); + (int) info.st_size, UBIK_BUFFERSIZE, UBIK_HEADERSIZE); readUbikHeader(); @@ -503,7 +503,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock) i = NameHash(&entry); if (i != j) { fprintf(stderr, - "Entry %d, %s, found in hash chain %d (should be %d)\n", + "Entry %lu, %s, found in hash chain %d (should be %d)\n", ((index - sizeof(struct kaheader)) / sizeof(struct kaentry)), EntryName(&entry), j, i); diff --git a/src/ptserver/db_verify.c b/src/ptserver/db_verify.c index 0298e79dc..4919deaf3 100644 --- a/src/ptserver/db_verify.c +++ b/src/ptserver/db_verify.c @@ -212,7 +212,7 @@ readUbikHeader(struct misc_data *misc) /* now read the info */ r = read(fd, &uheader, sizeof(uheader)); if (r != sizeof(uheader)) { - printf("error: read of %d bytes failed: %d %d\n", sizeof(uheader), r, + printf("error: read of %lu bytes failed: %d %d\n", sizeof(uheader), r, errno); return (-1); } diff --git a/src/ptserver/ptserver.c b/src/ptserver/ptserver.c index 93ff53f6d..9520df67b 100644 --- a/src/ptserver/ptserver.c +++ b/src/ptserver/ptserver.c @@ -344,7 +344,7 @@ main(int argc, char **argv) rxMaxMTU = atoi(argv[++a]); if ((rxMaxMTU < RX_MIN_PACKET_SIZE) || (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) { - printf("rxMaxMTU %d invalid; must be between %d-%d\n", + printf("rxMaxMTU %d invalid; must be between %d-%lu\n", rxMaxMTU, RX_MIN_PACKET_SIZE, RX_MAX_PACKET_DATA_SIZE); PT_EXIT(1); diff --git a/src/ubik/udebug.c b/src/ubik/udebug.c index 30f5a2667..c8f59cc4d 100644 --- a/src/ubik/udebug.c +++ b/src/ubik/udebug.c @@ -43,6 +43,8 @@ RCSID #include "ubik.h" #include "ubik_int.h" +static_inline int afs_cast_time_t(time_t d) { return (int) d; } + static short PortNumber(register char *aport) { @@ -172,7 +174,7 @@ CommandProc(struct cmd_syndesc *as, void *arock) times = ctime(&now); times[24] = 0; diff = now - udebug.now; - printf("Local time is %s (time differential %d secs)\n", times, (int)diff); + printf("Local time is %s (time differential %d secs)\n", times, afs_cast_time_t(diff)); if (abs((int)diff) >= MAXSKEW) printf("****clock may be bad\n"); @@ -192,14 +194,16 @@ CommandProc(struct cmd_syndesc *as, void *arock) } else { diff = udebug.now - udebug.lastYesTime; printf("Last yes vote for %s was %d secs ago (%ssync site); \n", - afs_inet_ntoa(udebug.lastYesHost), (int)diff, + afs_inet_ntoa(udebug.lastYesHost), + afs_cast_time_t(diff), ((udebug.lastYesState) ? "" : "not ")); diff = udebug.now - udebug.lastYesClaim; newtime = now - diff; times = ctime(&newtime); times[24] = 0; - printf("Last vote started %d secs ago (at %s)\n", (int)diff, times); + printf("Last vote started %d secs ago (at %s)\n", + afs_cast_time_t(diff), times); } printf("Local db version is %d.%d\n", udebug.localVersion.epoch, @@ -216,7 +220,7 @@ CommandProc(struct cmd_syndesc *as, void *arock) times[24] = 0; printf ("I am sync site until %d secs from now (at %s) (%d server%s)\n", - (int)diff, times, udebug.nServers, + afs_cast_time_t(diff), times, udebug.nServers, ((udebug.nServers > 1) ? "s" : "")); } printf("Recovery state %x\n", udebug.recoveryState); @@ -232,12 +236,12 @@ CommandProc(struct cmd_syndesc *as, void *arock) diff = udebug.now - udebug.lowestTime; printf("Lowest host %s was set %d secs ago\n", afs_inet_ntoa(htonl(udebug.lowestHost)), - (int)diff); + afs_cast_time_t(diff)); diff = udebug.now - udebug.syncTime; printf("Sync host %s was set %d secs ago\n", afs_inet_ntoa(htonl(udebug.syncHost)), - (int)diff); + afs_cast_time_t(diff)); } printf("Sync site's db version is %d.%d\n", udebug.syncVersion.epoch, @@ -265,7 +269,7 @@ CommandProc(struct cmd_syndesc *as, void *arock) times[24] = 0; printf ("Last time a new db version was labelled was:\n\t %d secs ago (at %s)\n", - (int)diff, times); + afs_cast_time_t(diff), times); } if (int32p || udebug.amSyncSite) { @@ -305,7 +309,8 @@ CommandProc(struct cmd_syndesc *as, void *arock) newtime = now - diff; times = ctime(&newtime); times[24] = 0; - printf(" last vote rcvd %d secs ago (at %s),\n", (int)diff, + printf(" last vote rcvd %d secs ago (at %s),\n", + afs_cast_time_t(diff), times); } @@ -318,7 +323,7 @@ CommandProc(struct cmd_syndesc *as, void *arock) times[24] = 0; printf (" last beacon sent %d secs ago (at %s), last vote was %s\n", - (int)diff, times, ((usdebug.lastVote) ? "yes" : "no")); + afs_cast_time_t(diff), times, ((usdebug.lastVote) ? "yes" : "no")); } printf(" dbcurrent=%d, up=%d beaconSince=%d\n", diff --git a/src/ubik/utst_client.c b/src/ubik/utst_client.c index 920f1d072..0a1f1d957 100644 --- a/src/ubik/utst_client.c +++ b/src/ubik/utst_client.c @@ -9,6 +9,7 @@ #include #include +#include RCSID ("$Header$"); @@ -124,7 +125,8 @@ main(int argc, char **argv) temp = 0; code = ubik_SAMPLE_Inc(cstruct, 0); if (code != 0) { - printf("SAMPLE_Inc #1 failed with code %ld\n", code); + printf("SAMPLE_Inc #1 failed with code %ld\n", + afs_cast_int32(code)); } else { printf("SAMPLE_Inc #1 succeeded, incremented integer\n"); } @@ -139,7 +141,8 @@ main(int argc, char **argv) temp = 0; code = ubik_SAMPLE_Inc(cstruct, 0); if (code != 0) - printf("SAMPLE_Inc #2 failed with code %ld\n", code); + printf("SAMPLE_Inc #2 failed with code %ld\n", + afs_cast_int32(code)); else printf("SAMPLE_Inc #2 succeeded, incremented integer\n"); diff --git a/src/uss/uss_acl.c b/src/uss/uss_acl.c index 832671d86..0a4170240 100644 --- a/src/uss/uss_acl.c +++ b/src/uss/uss_acl.c @@ -565,7 +565,7 @@ uss_acl_SetAccess(char *a_access, int a_clear, int a_negative) tp = uss_common_FieldCp(path_field, a_access, ' ', sizeof(path_field), &overflow); if (overflow) { - fprintf(stderr, "%s: * Pathname field too long (max is %d chars)\n", + fprintf(stderr, "%s: * Pathname field too long (max is %lu chars)\n", uss_whoami, sizeof(path_field)); return (-1); } diff --git a/src/viced/callback.c b/src/viced/callback.c index cfdd47926..33015e2b4 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -2817,8 +2817,8 @@ main(int argc, char **argv) now = ReadDump(*argv); if (stats || noptions == 0) { time_t uxtfirst = UXtime(tfirst); - printf("The time of the dump was %u %s", now, ctime(&now)); - printf("The last time cleanup ran was %u %s", uxtfirst, + printf("The time of the dump was %u %s", (unsigned int) now, ctime(&now)); + printf("The last time cleanup ran was %u %s", (unsigned int) uxtfirst, ctime(&uxtfirst)); PrintCallBackStats(); } @@ -2882,7 +2882,7 @@ PrintCB(register struct CallBack *cb, afs_uint32 now) if (fe == NULL) return; - printf("vol=%u vn=%u cbs=%d hi=%d st=%d fest=%d, exp in %d secs at %s", + printf("vol=%u vn=%u cbs=%d hi=%d st=%d fest=%d, exp in %lu secs at %s", fe->volid, fe->vnode, fe->ncbs, cb->hhead, cb->status, fe->status, expires - now, ctime(&expires)); } diff --git a/src/vlserver/cnvldb.c b/src/vlserver/cnvldb.c index c03dbd774..f03f68b25 100644 --- a/src/vlserver/cnvldb.c +++ b/src/vlserver/cnvldb.c @@ -335,7 +335,7 @@ printentry(version, addr) if (vl3p->flags == VLFREE) return; - printf("%s\tPos=%d NextIdHash=[%d:%d:%d] NextNameHash=%d\n", + printf("%s\tPos=%lu NextIdHash=[%d:%d:%d] NextNameHash=%d\n", vl3p->name, (oldpos - sizeof(struct vlentry_3)), vl3p->nextIdHash[0], vl3p->nextIdHash[1], vl3p->nextIdHash[2], vl3p->nextNameHash); diff --git a/src/vlserver/vldb_check.c b/src/vlserver/vldb_check.c index 36024256f..8f095eaad 100644 --- a/src/vlserver/vldb_check.c +++ b/src/vlserver/vldb_check.c @@ -139,7 +139,7 @@ readUbikHeader() /* now read the info */ r = read(fd, &uheader, sizeof(uheader)); if (r != sizeof(uheader)) { - log_error(VLDB_CHECK_FATAL,"error: read of %d bytes failed: %d %d\n", sizeof(uheader), r, + log_error(VLDB_CHECK_FATAL,"error: read of %lu bytes failed: %d %d\n", sizeof(uheader), r, errno); return (VLDB_CHECK_FATAL); } @@ -277,7 +277,7 @@ readheader(struct vlheader *headerp) quiet_println("vldb header\n"); quiet_println(" vldbversion = %u\n", headerp->vital_header.vldbversion); - quiet_println(" headersize = %u [actual=%u]\n", + quiet_println(" headersize = %u [actual=%lu]\n", headerp->vital_header.headersize, sizeof(*headerp)); quiet_println(" freePtr = 0x%x\n", headerp->vital_header.freePtr); quiet_println(" eofPtr = %u\n", headerp->vital_header.eofPtr); @@ -302,7 +302,7 @@ readheader(struct vlheader *headerp) /* Check the header size */ if (headerp->vital_header.headersize != sizeof(*headerp)) - log_error(VLDB_CHECK_WARNING,"Header reports its size as %d (should be %d)\n", + log_error(VLDB_CHECK_WARNING,"Header reports its size as %d (should be %lu)\n", headerp->vital_header.headersize, sizeof(*headerp)); return; } @@ -702,7 +702,7 @@ FollowNameHash(struct vlheader *header) if (record[rindex].addr != addr && record[rindex].addr) { log_error - (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %u use same record slot %d\n", + (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %ld and %u use same record slot %d\n", record[rindex].addr, addr, rindex); } if (record[rindex].type & NH) { @@ -777,7 +777,7 @@ FollowIdHash(struct vlheader *header) rindex = addr / sizeof(vlentry); if (record[rindex].addr != addr && record[rindex].addr) { log_error - (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %u use same record slot %d\n", + (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %ld and %u use same record slot %d\n", record[rindex].addr, addr, rindex); } if (record[rindex].type & hash) { @@ -845,7 +845,7 @@ FollowFreeChain(struct vlheader *header) rindex = addr / sizeof(vlentry); if (record[rindex].addr != addr && record[rindex].addr) { log_error - (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %u use same record slot %d\n", + (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %ld use same record slot %d\n", record[rindex].addr, addr, rindex); } if (record[rindex].type & FRC) { @@ -937,7 +937,7 @@ CheckIpAddrs(struct vlheader *header) } if (record[rindex].type & FRC) { log_error - (VLDB_CHECK_ERROR,"MH Blocks Chain %d: Bad entry at %u: Already a MH block\n", + (VLDB_CHECK_ERROR,"MH Blocks Chain %d: Bad entry at %ld: Already a MH block\n", i, record[rindex].addr); break; } @@ -1077,7 +1077,7 @@ void FixBad(afs_uint32 idx, afs_uint32 addr, afs_uint32 type, afs_uint32 tmp, struct nvlentry *vlentry, afs_uint32 hash) { SetHashEnd(addr, type, tmp); - quiet_println("linked unlinked chain %u (index %d) to end of chain %d for %s hash\n", + quiet_println("linked unlinked chain %u (index %lu) to end of chain %d for %s hash\n", tmp, ADDR(tmp), hash, type==NH?"Name":(type==RWH?"RW":(type==ROH?"RO":"BK"))); } @@ -1171,7 +1171,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock) readentry(record[i].addr, &vlentry, &type); if (InvalidVolname(vlentry.name)) - log_error(VLDB_CHECK_ERROR,"Volume '%s' at addr %u has an invalid name\n", + log_error(VLDB_CHECK_ERROR,"Volume '%s' at addr %ld has an invalid name\n", vlentry.name, record[i].addr); if (!(record[i].type & NH)) { @@ -1304,23 +1304,23 @@ WorkerBee(struct cmd_syndesc *as, void *arock) /* A free entry */ } else if (record[i].type & FR) { if (!(record[i].type & FRC)) - log_error(VLDB_CHECK_ERROR,"Free vlentry at %u not on free chain\n", + log_error(VLDB_CHECK_ERROR,"Free vlentry at %ld not on free chain\n", record[i].addr); if (record[i].type & 0xfffffdf0) log_error - (VLDB_CHECK_ERROR,"Free vlentry at %u also found on other chains (0x%x)\n", + (VLDB_CHECK_ERROR,"Free vlentry at %ld also found on other chains (0x%x)\n", record[i].addr, record[i].type); /* A multihomed entry */ } else if (record[i].type & MH) { if (!(record[i].type & MHC)) - log_error(VLDB_CHECK_ERROR,"Multihomed block at %u is orphaned\n", + log_error(VLDB_CHECK_ERROR,"Multihomed block at %ld is orphaned\n", record[i].addr); if (record[i].type & 0xfffffef0) log_error - (VLDB_CHECK_ERROR,"Multihomed block at %u also found on other chains (0x%x)\n", + (VLDB_CHECK_ERROR,"Multihomed block at %ld also found on other chains (0x%x)\n", record[i].addr, record[i].type); } else { @@ -1395,7 +1395,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock) if (record[i].type & VL) { readentry(record[i].addr, &vlentry, &type); if (!(record[i].type & REFN)) { - log_error(VLDB_CHECK_ERROR,"%d: Record %u (type 0x%x) not in a name chain\n", i, + log_error(VLDB_CHECK_ERROR,"%d: Record %ld (type 0x%x) not in a name chain\n", i, record[i].addr, record[i].type); if (strlen(vlentry.name)>0) { if (fix) { @@ -1414,7 +1414,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock) } } if (vlentry.volumeId[0] && !(record[i].type & REFRW)) { - log_error(VLDB_CHECK_ERROR,"%d: Record %u (type 0x%x) not in a RW chain\n", i, + log_error(VLDB_CHECK_ERROR,"%d: Record %ld (type 0x%x) not in a RW chain\n", i, record[i].addr, record[i].type); if (fix) { if (header.VolidHash[0][IdHash(vlentry.volumeId[0])] == 0) @@ -1424,7 +1424,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock) } } if (vlentry.volumeId[1] && !(record[i].type & REFRO)) { - log_error(VLDB_CHECK_ERROR,"%d: Record %u (type 0x%x) not in a RO chain\n", i, + log_error(VLDB_CHECK_ERROR,"%d: Record %ld (type 0x%x) not in a RO chain\n", i, record[i].addr, record[i].type); if (fix) { if (header.VolidHash[1][IdHash(vlentry.volumeId[1])] == 0) @@ -1434,7 +1434,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock) } } if (vlentry.volumeId[2] && !(record[i].type & REFBK)) { - log_error(VLDB_CHECK_ERROR,"%d: Record %u (type 0x%x) not in a BK chain\n", i, + log_error(VLDB_CHECK_ERROR,"%d: Record %ld (type 0x%x) not in a BK chain\n", i, record[i].addr, record[i].type); if (fix) { if (header.VolidHash[2][IdHash(vlentry.volumeId[2])] == 0) diff --git a/src/vlserver/vlserver.c b/src/vlserver/vlserver.c index 1e13db129..a240eff98 100644 --- a/src/vlserver/vlserver.c +++ b/src/vlserver/vlserver.c @@ -201,7 +201,7 @@ main(argc, argv) rxMaxMTU = atoi(argv[++index]); if ((rxMaxMTU < RX_MIN_PACKET_SIZE) || (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) { - printf("rxMaxMTU %d invalid; must be between %d-%d\n", + printf("rxMaxMTU %d invalid; must be between %d-%lu\n", rxMaxMTU, RX_MIN_PACKET_SIZE, RX_MAX_PACKET_DATA_SIZE); return -1; diff --git a/src/volser/volmain.c b/src/volser/volmain.c index 1fc4afebd..a48d57cb4 100644 --- a/src/volser/volmain.c +++ b/src/volser/volmain.c @@ -326,7 +326,7 @@ main(int argc, char **argv) rxMaxMTU = atoi(argv[++code]); if ((rxMaxMTU < RX_MIN_PACKET_SIZE) || (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) { - printf("rxMaxMTU %d% invalid; must be between %d-%d\n", + printf("rxMaxMTU %d invalid; must be between %d-%lu\n", rxMaxMTU, RX_MIN_PACKET_SIZE, RX_MAX_PACKET_DATA_SIZE); exit(1); diff --git a/src/volser/vos.c b/src/volser/vos.c index 765b777b6..73fd5b61b 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -904,7 +904,7 @@ XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP, } fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name); - fprintf(STDOUT, "id\t\t%lu\n", a_xInfoP->volid); + fprintf(STDOUT, "id\t\t%lu\n", afs_cast_uint32(a_xInfoP->volid)); fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname); fprintf(STDOUT, "part\t\t%s\n", pname); switch (a_xInfoP->status) { @@ -918,9 +918,12 @@ XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP, fprintf(STDOUT, "status\t\tUNATTACHABLE\n"); return; } - fprintf(STDOUT, "backupID\t%lu\n", a_xInfoP->backupID); - fprintf(STDOUT, "parentID\t%lu\n", a_xInfoP->parentID); - fprintf(STDOUT, "cloneID\t\t%lu\n", a_xInfoP->cloneID); + fprintf(STDOUT, "backupID\t%lu\n", + afs_cast_uint32(a_xInfoP->backupID)); + fprintf(STDOUT, "parentID\t%lu\n", + afs_cast_uint32(a_xInfoP->parentID)); + fprintf(STDOUT, "cloneID\t\t%lu\n", + afs_cast_uint32(a_xInfoP->cloneID)); fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N"); switch (a_xInfoP->type) { case 0: @@ -936,15 +939,20 @@ XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP, fprintf(STDOUT, "type\t\t?\n"); break; } - fprintf(STDOUT, "creationDate\t%-9lu\t%s", a_xInfoP->creationDate, + fprintf(STDOUT, "creationDate\t%-9lu\t%s", + afs_cast_uint32(a_xInfoP->creationDate), vos_ctime(&a_xInfoP->creationDate)); - fprintf(STDOUT, "accessDate\t%-9lu\t%s", a_xInfoP->accessDate, + fprintf(STDOUT, "accessDate\t%-9lu\t%s", + afs_cast_uint32(a_xInfoP->accessDate), vos_ctime(&a_xInfoP->accessDate)); - fprintf(STDOUT, "updateDate\t%-9lu\t%s", a_xInfoP->updateDate, + fprintf(STDOUT, "updateDate\t%-9lu\t%s", + afs_cast_uint32(a_xInfoP->updateDate), vos_ctime(&a_xInfoP->updateDate)); - fprintf(STDOUT, "backupDate\t%-9lu\t%s", a_xInfoP->backupDate, + fprintf(STDOUT, "backupDate\t%-9lu\t%s", + afs_cast_uint32(a_xInfoP->backupDate), vos_ctime(&a_xInfoP->backupDate)); - fprintf(STDOUT, "copyDate\t%-9lu\t%s", a_xInfoP->copyDate, + fprintf(STDOUT, "copyDate\t%-9lu\t%s", + afs_cast_uint32(a_xInfoP->copyDate), vos_ctime(&a_xInfoP->copyDate)); fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size); @@ -1051,7 +1059,8 @@ DisplayFormat2(server, partition, pntr) partition_cache = partition; } fprintf(STDOUT, "name\t\t%s\n", pntr->name); - fprintf(STDOUT, "id\t\t%lu\n", pntr->volid); + fprintf(STDOUT, "id\t\t%lu\n", + afs_cast_uint32(pntr->volid)); fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname); fprintf(STDOUT, "part\t\t%s\n", pname); switch (pntr->status) { @@ -1065,9 +1074,12 @@ DisplayFormat2(server, partition, pntr) fprintf(STDOUT, "status\t\tUNATTACHABLE\n"); return; } - fprintf(STDOUT, "backupID\t%lu\n", pntr->backupID); - fprintf(STDOUT, "parentID\t%lu\n", pntr->parentID); - fprintf(STDOUT, "cloneID\t\t%lu\n", pntr->cloneID); + fprintf(STDOUT, "backupID\t%lu\n", + afs_cast_uint32(pntr->backupID)); + fprintf(STDOUT, "parentID\t%lu\n", + afs_cast_uint32(pntr->parentID)); + fprintf(STDOUT, "cloneID\t\t%lu\n", + afs_cast_uint32(pntr->cloneID)); fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N"); fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N"); /* 0xD3 is from afs/volume.h since I had trouble including the file */ @@ -1086,25 +1098,35 @@ DisplayFormat2(server, partition, pntr) fprintf(STDOUT, "type\t\t?\n"); break; } - fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate, + fprintf(STDOUT, "creationDate\t%-9lu\t%s", + afs_cast_uint32(pntr->creationDate), vos_ctime(&pntr->creationDate)); - fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate, + fprintf(STDOUT, "accessDate\t%-9lu\t%s", + afs_cast_uint32(pntr->accessDate), vos_ctime(&pntr->accessDate)); - fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate, + fprintf(STDOUT, "updateDate\t%-9lu\t%s", + afs_cast_uint32(pntr->updateDate), vos_ctime(&pntr->updateDate)); - fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate, + fprintf(STDOUT, "backupDate\t%-9lu\t%s", + afs_cast_uint32(pntr->backupDate), vos_ctime(&pntr->backupDate)); - fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate, + fprintf(STDOUT, "copyDate\t%-9lu\t%s", + afs_cast_uint32(pntr->copyDate), vos_ctime(&pntr->copyDate)); - fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags); + fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", + afs_cast_uint32(pntr->flags)); fprintf(STDOUT, "diskused\t%u\n", pntr->size); fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota); - fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", pntr->spare0); + fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", + afs_cast_uint32(pntr->spare0)); fprintf(STDOUT, "filecount\t%u\n", pntr->filecount); fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse); - fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", pntr->spare1); - fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", pntr->spare2); - fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", pntr->spare3); + fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", + afs_cast_uint32(pntr->spare1)); + fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", + afs_cast_uint32(pntr->spare2)); + fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", + afs_cast_uint32(pntr->spare3)); return; } -- 2.39.5