windows-64bit-printf-sanity-20090218
authorSimon Wilkinson <sxw@sxw.org.uk>
Wed, 18 Feb 2009 17:48:39 +0000 (17:48 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 18 Feb 2009 17:48:39 +0000 (17:48 +0000)
LICENSE IPL10
FIXES 124265

don't assume %lld works for 64 bit ints on windows

12 files changed:
src/afsd/afsd.c
src/config/stds.h
src/sys/iopen.c
src/venus/fstrace.c
src/venus/kdump.c
src/vfsck/inode.c
src/vfsck/pass1.c
src/viced/afsfileprocs.c
src/vol/fssync-debug.c
src/vol/namei_ops.c
src/volser/restorevol.c
src/volser/vos.c

index 72e1857..17b3e32 100644 (file)
@@ -991,7 +991,7 @@ doSweepAFSCache(vFilesFound, directory, dirNum, maxDir)
        if (afsd_debug) {
            printf("%s: Current directory entry:\n", rn);
 #ifdef AFS_SGI62_ENV
-           printf("\tinode=%lld, reclen=%d, name='%s'\n", currp->d_ino,
+           printf("\tinode=%" AFS_INT64_FMT ", reclen=%d, name='%s'\n", currp->d_ino,
                   currp->d_reclen, currp->d_name);
 #else
            printf("\tinode=%d, reclen=%d, name='%s'\n", currp->d_ino,
index 176be3b..43bef04 100644 (file)
@@ -284,4 +284,13 @@ typedef struct afsUUID afsUUID;
 #define static_inline static inline
 #endif
 
+/* 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
+
 #endif /* OPENAFS_CONFIG_AFS_STDS_H */
index dace6ff..f6b933d 100644 (file)
@@ -57,7 +57,7 @@ main(argc, argv)
        perror("stat");
        exit(1);
     }
-    printf("ino=%lld\n", ino);
+    printf("ino=%" AFS_INT64_FMT "\n", ino);
     printf("About to iopen(dev=(%d,%d), inode=%s, mode=%d\n",
           major(status.st_dev), minor(status.st_dev), PrintInode(NULL, ino),
           O_RDONLY);
index 95d6bb2..c8cfc58 100644 (file)
@@ -396,7 +396,7 @@ DisplayRecord(outFilep, alp, rsize)
                        fprintf(outFilep, "%s", printfStrings[pfpix++]);
                        break;
                    case 2:     /* signed integer */
-                       fprintf(outFilep, "%lld", printfParms[pfpix++]);
+                       fprintf(outFilep, "%" AFS_INT64_FMT, printfParms[pfpix++]);
                        break;
                    case 3:     /* unsigned integer */
                        fprintf(outFilep, "%llu", printfParms[pfpix++]);
@@ -470,7 +470,7 @@ DisplayRecord(outFilep, alp, rsize)
                    tempParam = alp[pix];
                    tempParam <<= 32;
                    tempParam |= alp[pix + 1];
-                   fprintf(outFilep, "p%d:%lld ", i, tempParam);
+                   fprintf(outFilep, "p%d:%" AFS_INT64_FMT " ", i, tempParam);
 #else /* AFS_SGI61_ENV */
                    fprintf(outFilep, "p%d:%d ", i, alp[pix]);
 #endif /* AFS_SGI61_ENV */
index 5701e8c..4297782 100644 (file)
@@ -3019,7 +3019,7 @@ print_dcache(kmem, dcp, dp, pnt)
 #endif
 #ifdef AFS_SGI62_ENV
     printf
-       ("\tf.chunk=%d, f.inode=%lld, f.chunkBytes=%d, f.states=%x",
+       ("\tf.chunk=%d, f.inode=%" AFS_INT64_FMT ", f.chunkBytes=%d, f.states=%x",
         dcp->f.chunk, dcp->f.inode, dcp->f.chunkBytes, dcp->f.states);
 #else
     printf
@@ -3345,10 +3345,10 @@ print_global_afs_cache(kmem)
 #ifdef AFS_SGI62_ENV
     findsym("cacheInode", &symoff);
     kread(kmem, symoff, (char *)&inode, sizeof inode);
-    printf("\tcacheInode = 0x%llx (%lld)\n", inode, inode);
+    printf("\tcacheInode = 0x%llx (%" AFS_INT64_FMT ")\n", inode, inode);
     findsym("volumeInode", &symoff);
     kread(kmem, symoff, (char *)&inode, sizeof inode);
-    printf("\tvolumeInode = 0x%llx (%lld)\n", inode, inode);
+    printf("\tvolumeInode = 0x%llx (%" AFS_INT64_FMT ")\n", inode, inode);
 #else
     findsym("cacheInode", &symoff);
     kread(kmem, symoff, (char *)&count, sizeof count);
index c93e451..28683c4 100644 (file)
@@ -492,7 +492,7 @@ pinode(ino)
     if (preen)
        printf("%s: ", devname);
 #if    defined(AFS_SUN56_ENV)
-    printf("SIZE=%lld ", dp->di_size);
+    printf("SIZE=%" AFS_INT64_FMT " ", dp->di_size);
 #else
     printf("SIZE=%ld ", dp->di_size);
 #endif
index 876f8f8..b30b407 100644 (file)
@@ -242,7 +242,7 @@ pass1()
            if (ndb < 0) {
                if (debug)
 #if    defined(AFS_SUN56_ENV)
-                   printf("bad size %lld ndb %d:",
+                   printf("bad size %" AFS_INT64_FMT " ndb %d:",
 #else
                    printf("bad size %d ndb %d:",
 #endif
index 2a7bf0b..f48c01b 100644 (file)
@@ -1657,7 +1657,7 @@ Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
         AdjustDiskUsage(volptr, BlocksPreallocatedForVnode,
                         BlocksPreallocatedForVnode))) {
        ViceLog(25,
-               ("Insufficient space to allocate %lld blocks\n",
+               ("Insufficient space to allocate %" AFS_INT64_FMT " blocks\n",
                 (afs_intmax_t) BlocksPreallocatedForVnode));
        return (errorCode);
     }
index 651c943..abbc457 100644 (file)
@@ -1284,10 +1284,10 @@ static void
 print_vol_stats_viceP(struct DiskPartitionStats64 * stats)
 {
     printf("DiskPartitionStats64 = {\n");
-    printf("\tfree = %lld\n", stats->free);
-    printf("\tminFree = %lld\n", stats->minFree);
-    printf("\ttotalUsable = %lld\n", stats->totalUsable);
-    printf("\tf_files = %lld\n", stats->f_files);
+    printf("\tfree = %" AFS_INT64_FMT "\n", stats->free);
+    printf("\tminFree = %" AFS_INT64_FMT "\n", stats->minFree);
+    printf("\ttotalUsable = %" AFS_INT64_FMT "\n", stats->totalUsable);
+    printf("\tf_files = %" AFS_INT64_FMT "\n", stats->f_files);
 #ifdef AFS_DEMAND_ATTACH_FS
     printf("\tvol_list_len = %d\n", stats->vol_list_len);
 #endif
index 4d37b78..ec54258 100644 (file)
@@ -732,7 +732,7 @@ namei_dec(IHandle_t * ih, Inode ino, int p1)
        } else {
            IHandle_t *th;
            IH_INIT(th, ih->ih_dev, ih->ih_vid, ino);
-           Log("Warning: Lost ref on ihandle dev %d vid %d ino %lld\n",
+           Log("Warning: Lost ref on ihandle dev %d vid %d ino %" AFS_INT64_FMT "\n",
                th->ih_dev, th->ih_vid, (int64_t) th->ih_ino);
            IH_RELEASE(th);
          
index aadac4c..c04f8ea 100644 (file)
@@ -140,7 +140,7 @@ readdata(buffer, size)
            if (code < 0)
                fprintf(stderr, "Code = %d; Errno = %d\n", code, errno);
            else
-               fprintf(stderr, "Read %d bytes out of %lld\n", code, (afs_uintmax_t)size);
+               fprintf(stderr, "Read %d bytes out of %" AFS_INT64_FMT "\n", code, (afs_uintmax_t)size);
        }
        if ((code >= 0) && (code < BUFSIZE))
            buffer[size] = 0;   /* Add null char at end */
index cff091d..765b777 100644 (file)
@@ -2184,7 +2184,7 @@ MoveVolume(register struct cmd_syndesc *as, void *arock)
        exit(1);
     }
     if (TESTM)
-       fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
+       fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
                partition.free);
 
     p = (volintInfo *) 0;
@@ -2335,7 +2335,7 @@ CopyVolume(register struct cmd_syndesc *as, void *arock)
        exit(1);
     }
     if (TESTM)
-       fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
+       fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
                partition.free);
 
     p = (volintInfo *) 0;
@@ -2519,7 +2519,7 @@ ShadowVolume(register struct cmd_syndesc *as, void *arock)
        exit(1);
     }
     if (TESTM)
-       fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
+       fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
                partition.free);
 
     /* Don't do this again if we did it above */
@@ -5063,7 +5063,7 @@ PartitionInfo(register struct cmd_syndesc *as, void *arock)
                exit(1);
            }
            fprintf(STDOUT,
-                   "Free space on partition %s: %lld K blocks out of total %lld\n",
+                   "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
                    pname, partition.free, partition.minFree);
            sumPartitions++;
             AddUInt64(sumFree,partition.free,&sumFree);