]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-volid-cast-unsigned-int32-20090323
authorDerrick Brashear <shadow@dementia.org>
Mon, 23 Mar 2009 18:19:55 +0000 (18:19 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 23 Mar 2009 18:19:55 +0000 (18:19 +0000)
LICENSE IPL10
FIXES 124510

deal with the problem in 1.4.x by casting

src/config/stds.h
src/vol/fssync.c
src/vol/listinodes.c
src/vol/namei_ops.c
src/vol/vol-info.c
src/vol/vol-salvage.c
src/vol/volume.c
src/vol/vutil.c
src/volser/vol-dump.c
src/volser/volprocs.c
src/volser/vos.c

index 2ac240114750e5231b989ee2e4347ee9e2498ed1..7380a8e61d9a6451723df10bedfc706e4bd09f9a 100644 (file)
@@ -255,4 +255,41 @@ struct afsUUID {
 };
 typedef struct afsUUID afsUUID;
 
+/* A macro that can be used when printf'ing 64 bit integers, as Unix and 
+ * windows use a different format string
+ */
+#ifdef AFS_NT40_ENV
+#define AFS_INT64_FMT "l64d"
+#else
+#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
+ */
+#ifdef AFS_NT40_ENV
+#define static_inline __inline static
+#define hdr_static_inline(x) __inline static x
+#elif defined(AFS_HPUX_ENV) || defined(AFS_USR_HPUX_ENV)
+#define static_inline static __inline
+#define hdr_static_inline(x) static __inline x
+#elif defined(AFS_AIX_ENV) || defined(AFS_USR_AIX_ENV)
+#define static_inline static
+#define hdr_static_inline(x) static x
+#elif defined(AFS_SGI_ENV) || defined(AFS_USR_SGI_ENV)
+#define static_inline static
+#define hdr_static_inline(x) x
+#else
+#define static_inline static inline
+#define hdr_static_inline(x) static inline x
+#endif
+
+#ifdef  AFS_64BIT_ENV
+hdr_static_inline(afs_int32) afs_cast_int32(afs_int32 d) { return (afs_int32) d; }
+hdr_static_inline(afs_uint32) afs_cast_uint32(afs_uint32 d) { return (afs_uint32) d; }
+#else
+hdr_static_inline(long) afs_cast_int32(afs_int32 d) { return (long) d; }
+hdr_static_inline(unsigned long) afs_cast_uint32(afs_uint32 d) { return (unsigned long) d; }
+#endif
+
 #endif /* OPENAFS_CONFIG_AFS_STDS_H */
index 5751c2254672264a2984953b3a3ed253c23a0144..ad5830f40efe9d725e2abac7d8fec7019a89290b 100644 (file)
@@ -527,7 +527,7 @@ defect #2080 for details.
        if (v)
            v->volumeID = 0;
        tvolName[0] = '/';
-       sprintf(&tvolName[1], VFORMAT, command.volume);
+       sprintf(&tvolName[1], VFORMAT, afs_cast_uint32(command.volume));
 
        vp = VAttachVolumeByName_r(&error, command.partName, tvolName,
                                   V_VOLUPD);
@@ -667,7 +667,7 @@ FSYNC_Drop(int fd)
            Volume *vp;
 
            tvolName[0] = '/';
-           sprintf(&tvolName[1], VFORMAT, p[i].volumeID);
+           sprintf(&tvolName[1], VFORMAT, afs_cast_uint32(p[i].volumeID));
            vp = VAttachVolumeByName_r(&error, p[i].partName, tvolName,
                                       V_VOLUPD);
            if (vp)
index c50a0a753926915d9c5dae111ee6a492f5e2d5b6..c5afe70bd504fdff0b2eb23201e5ecaaa9f10cf6 100644 (file)
@@ -1664,7 +1664,7 @@ inode_ConvertROtoRWvolume(char *pname, afs_int32 volumeId)
 
     memset(&specinos, 0, sizeof(specinos));
           
-    (void)afs_snprintf(headername, sizeof headername, VFORMAT, volumeId);
+    (void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_cast_uint32(volumeId));
     (void)afs_snprintf(oldpath, sizeof oldpath, "%s/%s", pname, headername);
     fd = open(oldpath, O_RDONLY);
     if (fd < 0) {
@@ -1767,7 +1767,7 @@ inode_ConvertROtoRWvolume(char *pname, afs_int32 volumeId)
     }
 #endif
 
-    (void)afs_snprintf(headername, sizeof headername, VFORMAT, h.id);
+    (void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_cast_uint32(h.id));
     (void)afs_snprintf(newpath, sizeof newpath, "%s/%s", pname, headername);
     fd = open(newpath, O_CREAT | O_EXCL | O_RDWR, 0644);
     if (fd < 0) {
index 7d53751ecf59ed7f9aa66454c86de1c4f8978474..af12fd9c107e6d4ca87958aefe70b7a28fc6b606 100644 (file)
@@ -1572,7 +1572,7 @@ namei_ConvertROtoRWvolume(char *pname, afs_int32 volumeId)
     char headername[16];
     afs_int32 error = 0;
 
-    (void)afs_snprintf(headername, sizeof headername, VFORMAT, volumeId);
+    (void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_cast_uint32(volumeId));
     (void)afs_snprintf(oldpath, sizeof oldpath, "%s/%s", pname, headername);
     fd = open(oldpath, O_RDONLY);
     if (fd < 0) {
@@ -1722,7 +1722,7 @@ namei_ConvertROtoRWvolume(char *pname, afs_int32 volumeId)
     h.smallVnodeIndex_hi = h.id;
     h.largeVnodeIndex_hi = h.id;
     h.linkTable_hi = h.id;
-    (void)afs_snprintf(headername, sizeof headername, VFORMAT, h.id);
+    (void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_cast_uint32(h.id));
     (void)afs_snprintf(newpath, sizeof newpath, "%s/%s", pname, headername);
     fd = open(newpath, O_CREAT | O_EXCL | O_RDWR, 0644);
     if (fd < 0) {
index 7366113978272403b40217ba15392ac547a7fcaf..b5893dcba89bb046fd2f0945681f8c522ac7ec2e 100644 (file)
@@ -322,7 +322,7 @@ handleit(struct cmd_syndesc *as, void *arock)
            }
        }
        (void)afs_snprintf(name1, sizeof name1, VFORMAT,
-                          (unsigned long)volumeId);
+                          afs_cast_uint32(volumeId));
        if (dsizeOnly && !saveinodes)
            printf
                ("Volume-Id\t  Volsize  Auxsize Inodesize  AVolsize SizeDiff                (VolName)\n");
index 4bbc99c191318122ef763a8062759ed9e06d7616..6fa07219b8d6c70f0094e357622811462db6b958 100644 (file)
@@ -1787,7 +1787,7 @@ GetVolumeSummary(VolumeId singleVolumeNumber)
                    || (vsp->header.id == singleVolumeNumber
                        || vsp->header.parent == singleVolumeNumber)) {
                    (void)afs_snprintf(nameShouldBe, sizeof nameShouldBe,
-                                      VFORMAT, vsp->header.id);
+                                      VFORMAT, afs_cast_uint32(vsp->header.id));
                    if (singleVolumeNumber
                        && vsp->header.id != singleVolumeNumber)
                        AskOffline(vsp->header.id);
@@ -2237,7 +2237,7 @@ SalvageVolumeHeaderFile(register struct InodeSummary *isp,
 
     if (isp->volSummary == NULL) {
        char name[64];
-       (void)afs_snprintf(name, sizeof name, VFORMAT, isp->volumeId);
+       (void)afs_snprintf(name, sizeof name, VFORMAT, afs_cast_uint32(isp->volumeId));
        if (check) {
            Log("No header file for volume %u\n", isp->volumeId);
            return -1;
@@ -2264,7 +2264,7 @@ SalvageVolumeHeaderFile(register struct InodeSummary *isp,
            if (isp->volSummary->fileName) {
                strcpy(name, isp->volSummary->fileName);
            } else {
-               (void)afs_snprintf(name, sizeof name, VFORMAT, isp->volumeId);
+             (void)afs_snprintf(name, sizeof name, VFORMAT, afs_cast_uint32(isp->volumeId));
                isp->volSummary->fileName = ToString(name);
            }
 
index 81e41283c1e76a9af4b8f7007fad4d4ae405b0dc..ffdaf9d5744555a39513a7123a45175b439ce323 100644 (file)
@@ -1680,7 +1680,7 @@ VGetVolumePath(Error * ec, VolId volumeId, char **partitionp, char **namep)
 
     *ec = 0;
     name[0] = '/';
-    (void)afs_snprintf(&name[1], (sizeof name) - 1, VFORMAT, volumeId);
+    (void)afs_snprintf(&name[1], (sizeof name) - 1, VFORMAT, afs_cast_uint32(volumeId));
     for (dp = DiskPartitionList; dp; dp = dp->next) {
        struct afs_stat status;
        strcpy(path, VPartitionPath(dp));
@@ -1712,7 +1712,7 @@ char *
 VolumeExternalName(VolumeId volumeId)
 {
     static char name[VMAXPATHLEN];
-    (void)afs_snprintf(name, sizeof name, VFORMAT, volumeId);
+    (void)afs_snprintf(name, sizeof name, VFORMAT, afs_cast_uint32(volumeId));
     return name;
 }
 
index 1ad0bb84989b957b6165e9cdf3cf6346709de9dc..6d2f21f9c70cb3ea078b98e593bd988bf0a4010c 100644 (file)
@@ -171,7 +171,7 @@ VCreateVolume_r(Error * ec, char *partname, VolId volumeId, VolId parentId)
     vol.stamp.magic = VOLUMEINFOMAGIC;
     vol.stamp.version = VOLUMEINFOVERSION;
     vol.destroyMe = DESTROY_ME;
-    (void)afs_snprintf(headerName, sizeof headerName, VFORMAT, vol.id);
+    (void)afs_snprintf(headerName, sizeof headerName, VFORMAT, afs_cast_uint32(vol.id));
     (void)afs_snprintf(volumePath, sizeof volumePath, "%s/%s",
                       VPartitionPath(partition), headerName);
     fd = afs_open(volumePath, O_CREAT | O_EXCL | O_WRONLY, 0600);
index cd1893c4088b09fd93966f333ef5633528d771fa..484482c169acea20a6bdd0aa881a1136019de875 100644 (file)
@@ -241,7 +241,7 @@ handleit(struct cmd_syndesc *as, void *arock)
        exit(1);
     }
 
-    (void)afs_snprintf(name1, sizeof name1, VFORMAT, (unsigned long)volumeId);
+    (void)afs_snprintf(name1, sizeof name1, VFORMAT, afs_cast_uint32(volumeId));
     HandleVolume(partP, name1, fileName, fromtime);
     return 0;
 }
index c007a61c564d6f9e4d520ebe3fcef5c091ce93ba..e38c7ec5c85a04af75755df42ea1e7e18f807af6 100644 (file)
@@ -152,7 +152,7 @@ ConvertVolume(afs_int32 avol, char *aname, afs_int32 asize)
     if (asize < 18)
        return -1;
     /* It's better using the Generic VFORMAT since otherwise we have to make changes to too many places... The 14 char limitation in names hits us again in AIX; print in field of 9 digits (still 10 for the rest), right justified with 0 padding */
-    (void)afs_snprintf(aname, asize, VFORMAT, (unsigned long)avol);
+    (void)afs_snprintf(aname, asize, VFORMAT, afs_cast_uint32(avol));
     return 0;
 }
 
index 299c100300a0ed1b1bcbb47685af9a11a8040c42..e6ee3d7c26c06b46d64732ac0c3483abff30c570 100644 (file)
@@ -546,13 +546,13 @@ DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
            qPut(&busyHead, pntr->volid);
            if (disp)
                fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-                       (unsigned long)pntr->volid);
+                       afs_cast_uint32(pntr->volid));
        } else {
            *totalNotOK += 1;
            qPut(&notokHead, pntr->volid);
            if (disp)
                fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-                       (unsigned long)pntr->volid);
+                       afs_cast_uint32(pntr->volid));
        }
        fprintf(STDOUT, "\n");
     } else {                   /* default listing */
@@ -581,13 +581,13 @@ DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
            qPut(&busyHead, pntr->volid);
            if (disp)
                fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-                       (unsigned long)pntr->volid);
+                       afs_cast_uint32(pntr->volid));
        } else {
            *totalNotOK += 1;
            qPut(&notokHead, pntr->volid);
            if (disp)
                fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-                       (unsigned long)pntr->volid);
+                       afs_cast_uint32(pntr->volid));
        }
     }
 }
@@ -776,14 +776,14 @@ XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
            qPut(&busyHead, a_xInfoP->volid);
            if (a_showProblems)
                fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-                       (unsigned long)a_xInfoP->volid);
+                       afs_cast_uint32(a_xInfoP->volid));
        } /*Busy volume */
        else {
            (*a_totalNotOKP)++;
            qPut(&notokHead, a_xInfoP->volid);
            if (a_showProblems)
                fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-                       (unsigned long)a_xInfoP->volid);
+                       afs_cast_uint32(a_xInfoP->volid));
        }                       /*Screwed volume */
        fprintf(STDOUT, "\n");
     } /*Long listing */
@@ -815,14 +815,14 @@ XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
            qPut(&busyHead, a_xInfoP->volid);
            if (a_showProblems)
                fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-                       (unsigned long)a_xInfoP->volid);
+                       afs_cast_uint32(a_xInfoP->volid));
        } /*Busy volume */
        else {
            (*a_totalNotOKP)++;
            qPut(&notokHead, a_xInfoP->volid);
            if (a_showProblems)
                fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-                       (unsigned long)a_xInfoP->volid);
+                       afs_cast_uint32(a_xInfoP->volid));
        }                       /*Screwed volume */
     }                          /*Default listing */
 }                              /*XDisplayFormat */
@@ -977,14 +977,14 @@ XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
            qPut(&busyHead, a_xInfoP->volid);
            if (a_showProblems)
                fprintf(STDOUT, "BUSY_VOL\t%lu\n",
-                       (unsigned long)a_xInfoP->volid);
+                       afs_cast_uint32(a_xInfoP->volid));
        } /*Busy volume */
        else {
            (*a_totalNotOKP)++;
            qPut(&notokHead, a_xInfoP->volid);
            if (a_showProblems)
                fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
-                       (unsigned long)a_xInfoP->volid);
+                       afs_cast_uint32(a_xInfoP->volid));
        }                       /*Screwed volume */
     } /*Long listing */
     else {
@@ -1014,14 +1014,14 @@ XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
            qPut(&busyHead, a_xInfoP->volid);
            if (a_showProblems)
                fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
-                       (unsigned long)a_xInfoP->volid);
+                       afs_cast_uint32(a_xInfoP->volid));
        } /*Busy volume */
        else {
            (*a_totalNotOKP)++;
            qPut(&notokHead, a_xInfoP->volid);
            if (a_showProblems)
                fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
-                       (unsigned long)a_xInfoP->volid);
+                       afs_cast_uint32(a_xInfoP->volid));
        }                       /*Screwed volume */
     }                          /*Default listing */
 }                              /*XDisplayFormat */
@@ -1147,14 +1147,14 @@ DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
        while (busyHead.count) {
            qGet(&busyHead, &volid);
            fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-                   (unsigned long)volid);
+                   afs_cast_uint32(volid));
        }
     }
     if (totalNotOK) {
        while (notokHead.count) {
            qGet(&notokHead, &volid);
            fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-                   (unsigned long)volid);
+                   afs_cast_uint32(volid));
        }
     }
     if (!quiet) {
@@ -1235,14 +1235,14 @@ XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
        while (busyHead.count) {
            qGet(&busyHead, &volid);
            fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-                   (unsigned long)volid);
+                   afs_cast_uint32(volid));
        }
     }
     if (totalNotOK) {
        while (notokHead.count) {
            qGet(&notokHead, &volid);
            fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-                   (unsigned long)volid);
+                   afs_cast_uint32(volid));
        }
     }
 
@@ -1328,14 +1328,14 @@ XDisplayVolumes2(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
        while (busyHead.count) {
            qGet(&busyHead, &volid);
            fprintf(STDOUT, "BUSY_VOL\t%lu\n",
-                   (unsigned long)volid);
+                   afs_cast_uint32(volid));
        }
     }
     if (totalNotOK) {
        while (notokHead.count) {
            qGet(&notokHead, &volid);
            fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
-                   (unsigned long)volid);
+                   afs_cast_uint32(volid));
        }
     }
 
@@ -1556,14 +1556,14 @@ ExamineVolume(register struct cmd_syndesc *as, void *arock)
 
     if (verbose) {
        fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
        fflush(STDOUT);
     }
     vcode = VLDB_GetEntryByID(volid, -1, &entry);
     if (vcode) {
        fprintf(STDERR,
                "Could not fetch the entry for volume number %lu from VLDB \n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
        return (vcode);
     }
     if (verbose)
@@ -1705,7 +1705,7 @@ SetFields(register struct cmd_syndesc *as, void *arock)
     if (code) {
        fprintf(STDERR,
                "Could not fetch the entry for volume number %lu from VLDB \n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
        return (code);
     }
     MapHostToNetwork(&entry);
@@ -1737,7 +1737,7 @@ SetFields(register struct cmd_syndesc *as, void *arock)
     if (code)
        fprintf(STDERR,
                "Could not update volume info fields for volume number %lu\n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
     return (code);
 }
 
@@ -1949,7 +1949,7 @@ CreateVolume(register struct cmd_syndesc *as, void *arock)
     }
     MapPartIdIntoName(pnum, part);
     fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
-           (unsigned long)volid, part, as->parms[0].items->data);
+           afs_cast_uint32(volid), part, as->parms[0].items->data);
 
     return 0;
 }
@@ -2035,7 +2035,7 @@ DeleteVolume(struct cmd_syndesc *as, void *arock)
        if (code) {
            fprintf(STDERR,
                    "Could not fetch the entry for volume %lu from VLDB\n",
-                   (unsigned long)volid);
+                   afs_cast_uint32(volid));
            PrintError("", code);
            return (code);
        }
@@ -2093,7 +2093,7 @@ DeleteVolume(struct cmd_syndesc *as, void *arock)
 
     MapPartIdIntoName(partition, pname);
     fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
-           (unsigned long)volid, pname, hostutil_GetNameByINet(server));
+           afs_cast_uint32(volid), pname, hostutil_GetNameByINet(server));
     return 0;
 }
 
@@ -2188,16 +2188,16 @@ MoveVolume(register struct cmd_syndesc *as, void *arock)
     code = UV_ListOneVolume(fromserver, frompart, volid, &p);
     if (code) {
        fprintf(STDERR, "vos:cannot access volume %lu\n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
        exit(1);
     }
     if (TESTM)
-       fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
+       fprintf(STDOUT, "volume %lu size %d\n", afs_cast_uint32(volid),
                p->size);
     if (partition.free <= p->size) {
        fprintf(STDERR,
                "vos: no space on target partition %s to move volume %lu\n",
-               toPartName, (unsigned long)volid);
+               toPartName, afs_cast_uint32(volid));
        free(p);
        exit(1);
     }
@@ -2219,7 +2219,7 @@ MoveVolume(register struct cmd_syndesc *as, void *arock)
     MapPartIdIntoName(topart, toPartName);
     MapPartIdIntoName(frompart, fromPartName);
     fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
-           (unsigned long)volid, as->parms[1].items->data, fromPartName,
+           afs_cast_uint32(volid), as->parms[1].items->data, fromPartName,
            as->parms[3].items->data, toPartName);
 
     return 0;
@@ -2339,14 +2339,14 @@ CopyVolume(register struct cmd_syndesc *as, void *arock)
     code = UV_ListOneVolume(fromserver, frompart, volid, &p);
     if (code) {
        fprintf(STDERR, "vos:cannot access volume %lu\n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
        exit(1);
     }
 
     if (partition.free <= p->size) {
        fprintf(STDERR,
                "vos: no space on target partition %s to copy volume %lu\n",
-               toPartName, (unsigned long)volid);
+               toPartName, afs_cast_uint32(volid));
        free(p);
        exit(1);
     }
@@ -2364,7 +2364,7 @@ CopyVolume(register struct cmd_syndesc *as, void *arock)
     MapPartIdIntoName(topart, toPartName);
     MapPartIdIntoName(frompart, fromPartName);
     fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
-           (unsigned long)volid, as->parms[1].items->data, fromPartName,
+           afs_cast_uint32(volid), as->parms[1].items->data, fromPartName,
            tovolume, as->parms[4].items->data, toPartName);
 
     return 0;
@@ -2464,7 +2464,7 @@ ShadowVolume(register struct cmd_syndesc *as, void *arock)
        code = UV_ListOneVolume(fromserver, frompart, volid, &p);
        if (code) {
            fprintf(STDERR, "vos:cannot access volume %lu\n",
-               (unsigned long)volid);
+                   afs_cast_uint32(volid));
            exit(1);
        }
        strcpy(toVolName, p->name);
@@ -2525,7 +2525,7 @@ ShadowVolume(register struct cmd_syndesc *as, void *arock)
        code = UV_ListOneVolume(fromserver, frompart, volid, &p);
        if (code) {
            fprintf(STDERR, "vos:cannot access volume %lu\n",
-               (unsigned long)volid);
+                   afs_cast_uint32(volid));
            exit(1);
        }
     }
@@ -2540,7 +2540,7 @@ ShadowVolume(register struct cmd_syndesc *as, void *arock)
     if (partition.free <= p->size) {
        fprintf(STDERR,
                "vos: no space on target partition %s to copy volume %lu\n",
-               toPartName, (unsigned long)volid);
+               toPartName, afs_cast_uint32(volid));
        free(p);
        if (q) free(q);
        exit(1);
@@ -2560,7 +2560,7 @@ ShadowVolume(register struct cmd_syndesc *as, void *arock)
     MapPartIdIntoName(topart, toPartName);
     MapPartIdIntoName(frompart, fromPartName);
     fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
-           (unsigned long)volid, as->parms[1].items->data, fromPartName,
+           afs_cast_uint32(volid), as->parms[1].items->data, fromPartName,
            as->parms[3].items->data, toPartName);
 
     return 0;
@@ -2730,7 +2730,7 @@ BackupVolume(register struct cmd_syndesc *as, void *arock)
        if (!code) {
            fprintf(STDERR,
                    "FATAL ERROR: backup volume %lu exists on server %lu\n",
-                   (unsigned long)buvolid, (unsigned long)buserver);
+                   afs_cast_uint32(buvolid), (unsigned long)buserver);
            exit(1);
        }
     }
@@ -3124,7 +3124,7 @@ RestoreVolume(register struct cmd_syndesc *as, void *arock)
            if (vol_elsewhere) {
                fprintf(STDERR,
                        "%s volume %lu already exists on a different server/part; not allowed\n",
-                       readonly ? "RO" : "RW", (unsigned long)avolid);
+                       readonly ? "RO" : "RW", afs_cast_uint32(avolid));
                exit(1);
            }
        }
@@ -3896,7 +3896,7 @@ VolumeZap(register struct cmd_syndesc *as, void *arock)
            backupid = entry.volumeId[BACKVOL];
        fprintf(STDERR,
                "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
     }
     if (zapbackupid) {
        volintInfo *pntr = (volintInfo *) 0;
@@ -3917,7 +3917,7 @@ VolumeZap(register struct cmd_syndesc *as, void *arock)
                exit(1);
            }
            fprintf(STDOUT, "Backup Volume %lu deleted\n",
-                   (unsigned long)backupid);
+                   afs_cast_uint32(backupid));
        }
     }
     code = UV_VolumeZap(server, part, volid);
@@ -3925,7 +3925,7 @@ VolumeZap(register struct cmd_syndesc *as, void *arock)
        PrintDiagnostics("zap", code);
        exit(1);
     }
-    fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
+    fprintf(STDOUT, "Volume %lu deleted\n", afs_cast_uint32(volid));
 
     return 0;
 }
@@ -4092,7 +4092,7 @@ GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *vo
     if (vcode) {
        fprintf(STDERR,
                "Could not fetch the entry for volume %lu from VLDB \n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
        PrintError("", vcode);
        return (vcode);
     }
@@ -4107,7 +4107,7 @@ GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *vo
        if (index == -1) {
            fprintf(STDERR,
                    "RO volume is not found in VLDB entry for volume %lu\n",
-                   (unsigned long)volid);
+                   afs_cast_uint32(volid));
            return -1;
        }
 
@@ -4120,7 +4120,7 @@ GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *vo
     if (index == -1) {
        fprintf(STDERR,
                "RW Volume is not found in VLDB entry for volume %lu\n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
        return -1;
     }
     if (volid == rentry->volumeId[RWVOL]) {
@@ -4137,7 +4137,7 @@ GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *vo
     }
     fprintf(STDERR,
             "unexpected volume type for volume %lu\n",
-            (unsigned long)volid);
+            afs_cast_uint32(volid));
     return -1;
 }
 
@@ -4939,7 +4939,7 @@ UnlockVLDB(register struct cmd_syndesc *as, void *arock)
     if (totalE)
        fprintf(STDOUT,
                "Could not lock %lu VLDB entries of %lu locked entries\n",
-               (unsigned long)totalE, (unsigned long)nentries);
+               afs_cast_uint32(totalE), (unsigned long)nentries);
     else {
        if (as->parms[0].items) {
            fprintf(STDOUT,
@@ -5406,7 +5406,7 @@ ConvertRO(register struct cmd_syndesc *as, void *arock)
     if (vcode) {
        fprintf(STDERR,
                "Could not fetch the entry for volume %lu from VLDB\n",
-               (unsigned long)volid);
+               afs_cast_uint32(volid));
        PrintError("convertROtoRW", code);
        return vcode;
     }
@@ -5473,7 +5473,7 @@ ConvertRO(register struct cmd_syndesc *as, void *arock)
     if (code) {
        fprintf(STDERR,
                "Converting RO volume %lu to RW volume failed with code %d\n",
-               (unsigned long)volid, code);
+               afs_cast_uint32(volid), code);
        PrintError("convertROtoRW ", code);
        return -1;
     }