Fixed compiler warnings, mostly in printf format mismatches. Most of
authorwtc
Mon, 13 Apr 1998 22:00:47 +0000
changeset 24 67b815592209125abd44765be59448cdf121ebe2
parent 23 518e7851e77317c32bb997f6a57e4eb3ad046b38
child 25 c7367d578192f253d503a55eee51dbf899f714ec
push idunknown
push userunknown
push dateunknown
Fixed compiler warnings, mostly in printf format mismatches. Most of the fixes are supplied by Nathan Torkington <gnat@frii.com>.
lib/msgc/src/prmsgc.c
--- a/lib/msgc/src/prmsgc.c
+++ b/lib/msgc/src/prmsgc.c
@@ -419,17 +419,18 @@ static GCSeg* DoGrowHeap(PRInt32 request
     /* No room for more segments */
     return 0;
     }
 
     segInfo = (GCSegInfo*) PR_MALLOC(sizeof(GCSegInfo));
 #ifdef DEBUG
     {
     char str[256];
-    sprintf(str, "[1] Allocated %d bytes at %p\n", sizeof(GCSegInfo), segInfo);
+    sprintf(str, "[1] Allocated %ld bytes at %p\n",
+        (long) sizeof(GCSegInfo), segInfo);
     OutputDebugString(str);
     }
 #endif
     if (!segInfo) {
     return 0;
     }
 
 #if defined(WIN16)
@@ -484,18 +485,18 @@ static GCSeg* DoGrowHeap(PRInt32 request
     segInfo->limit = sp->limit = base + allocSize;
     segInfo->hbits = sp->hbits = hbits;
     sp->info = segInfo;
     segInfo->fromMalloc = exactly;
     memset(base, 0, allocSize);
 
 #ifdef GCMETER
     if (_pr_gcMeter & _GC_METER_GROWTH) {
-        fprintf(stderr, "[GC: new segment base=%p size=%d]\n",
-                sp->base, allocSize);
+        fprintf(stderr, "[GC: new segment base=%p size=%ld]\n",
+                sp->base, (long) allocSize);
     }
 #endif    
 
     _pr_gcData.allocMemory += allocSize;
     _pr_gcData.freeMemory  += allocSize;
 
     if (!exactly) {
     PRInt32 bin;
@@ -636,18 +637,18 @@ static PRBool GrowHeap(PRInt32 requested
 
 /*
 ** Release a segment when it is entirely free.
 */
 static void ShrinkGCHeap(GCSeg *sp)
 {
 #ifdef GCMETER
     if (_pr_gcMeter & _GC_METER_GROWTH) {
-        fprintf(stderr, "[GC: free segment base=%p size=%d]\n",
-                sp->base, sp->limit - sp->base);
+        fprintf(stderr, "[GC: free segment base=%p size=%ld]\n",
+                sp->base, (long) (sp->limit - sp->base));
     }
 #endif    
 
     /*
      * Put segment onto free seginfo list (we can't call free right now
      * because we have the GC lock and all of the other threads are
      * suspended; if one of them has the malloc lock we would deadlock)
      */
@@ -1641,21 +1642,23 @@ static void dogc(void)
     }
 
     PR_SuspendAll();
 
 #ifdef GCMETER
     /* Reset meter info */
     if (_pr_gcMeter & _GC_METER_STATS) {
         fprintf(stderr,
-                "[GCSTATS: busy:%d skipped:%d, alloced:%d+wasted:%d+free:%d = total:%d]\n",
-                _pr_gcData.busyMemory,
-        meter.skippedFreeChunks,
-                meter.allocBytes, meter.wastedBytes, _pr_gcData.freeMemory,
-                _pr_gcData.allocMemory);
+                "[GCSTATS: busy:%ld skipped:%ld, alloced:%ld+wasted:%ld+free:%ld = total:%ld]\n",
+                (long) _pr_gcData.busyMemory,
+                (long) meter.skippedFreeChunks,
+                (long) meter.allocBytes,
+                (long) meter.wastedBytes,
+                (long) _pr_gcData.freeMemory,
+                (long) _pr_gcData.allocMemory);
     }        
     memset(&meter, 0, sizeof(meter));
 #endif
 
     PR_LOG(_pr_msgc_lm, PR_LOG_ALWAYS, ("begin mark phase; busy=%d free=%d total=%d",
                      _pr_gcData.busyMemory, _pr_gcData.freeMemory,
                      _pr_gcData.allocMemory));
 
@@ -1746,22 +1749,23 @@ static void dogc(void)
 #endif
 #ifdef GCMETER
     LL_SUB(diff, end, start);
     PR_LOG(GC, PR_LOG_ALWAYS,
 	   ("done; busy=%d free=%d chunks=%d total=%d time=%lldms",
 	    _pr_gcData.busyMemory, _pr_gcData.freeMemory,
 	    meter.numFreeChunks, _pr_gcData.allocMemory, diff));
     if (_pr_gcMeter & _GC_METER_FREE_LIST) {
-        PRInt32 bin;
+        PRIntn bin;
         fprintf(stderr, "Freelist bins:\n");
         for (bin = 0; bin < NUM_BINS; bin++) {
             GCFreeChunk *cp = bins[bin];
             while (cp != NULL) {
-                fprintf(stderr, "%3d: %p %8d\n", bin, cp, cp->chunkSize);
+                fprintf(stderr, "%3d: %p %8ld\n",
+                        bin, cp, (long) cp->chunkSize);
                 cp = cp->next;
             }
         }
     }
 #endif
 
     if (_pr_endGCHook) {
     (*_pr_endGCHook)(_pr_endGCHookArg);
@@ -1976,55 +1980,57 @@ PR_DumpHexWords(FILE *out, PRWord *p, in
 
     PR_DumpIndent(out, indent);
     i = nWordsPerLine;
     if (i > nWords)
         i = nWords;
     nWords -= i;
     while (i--)
     {
-        fprintf(out, "0x%.8X", *p++);
+        fprintf(out, "0x%.8lX", (long) *p++);
         if (i)
         fputc(' ', out);
     }
     fputc('\n', out);
     }
 }
 
 static void PR_CALLBACK
 pr_DumpObject(FILE *out, GCType* tp, PRWord *p, 
           size_t bytes, PRBool detailed)
 {
     char kindChar = tp->kindChar;
-    fprintf(out, "0x%p: 0x%.6X %c  ", p, bytes, kindChar ? kindChar : '?');
+    fprintf(out, "0x%p: 0x%.6lX %c  ",
+            p, (long) bytes, kindChar ? kindChar : '?');
     if (tp->dump)
     (*tp->dump)(out, (void*) (p + 1), detailed, 0);
     if (detailed)
     PR_DumpHexWords(out, p, bytes>>2, 22, 4);
 }
     
 static void PR_CALLBACK
 pr_DumpUnknown(FILE *out, GCType* tp, PRWord tix, PRWord *p, 
            size_t bytes, PRBool detailed)
 {
     char kindChar = tp->kindChar;
-    fprintf(out, "0x%p: 0x%.6X %c  ", p, bytes, kindChar ? kindChar : '?');
-    fprintf(out, "UNKNOWN KIND %d\n", tix);
+    fprintf(out, "0x%p: 0x%.6lX %c  ",
+            p, (long) bytes, kindChar ? kindChar : '?');
+    fprintf(out, "UNKNOWN KIND %ld\n", (long) tix);
     if (detailed)
     PR_DumpHexWords(out, p, bytes>>2, 22, 4);
 }
 
 static void PR_CALLBACK
 pr_DumpFree(FILE *out, PRWord *p, size_t size, PRBool detailed)
 {
 #if defined(XP_MAC) && XP_MAC
 # pragma unused( detailed )
 #endif
 
-    fprintf(out, "0x%p: 0x%.6X -  FREE\n", p, size);
+    fprintf(out, "0x%p: 0x%.6lX -  FREE\n", p, (long) size);
 }
 
 static void PR_CALLBACK
 pr_DumpSegment(FILE* out, GCSeg* sp, PRBool detailed)
 {
     pr_WalkSegment(out, sp, detailed,
            "\n   Address: Length\n0x%p: Beginning of segment\n",
            "0x%p: End of segment\n\n",
@@ -2170,23 +2176,16 @@ pr_DumpSummary(FILE* out, GCSeg* sp, PRB
 
 PR_IMPLEMENT(void)
 PR_DumpGCSummary(FILE *out, PRBool detailed)
 {
     if (summaryPrinter) {
     pr_WalkSegments(out, pr_DumpSummary, detailed);
     summaryPrinter(out, summaryPrinterClosure);
     }
-#ifdef xxx_WIN32
-    {
-    extern PRInt32 totalVirtual;
-    fprintf(out, "Virtual memory reserve: %ld, in use: %ld (%ld%%)\n",
-        GC_VMLIMIT, totalVirtual, (totalVirtual * 100 / GC_VMLIMIT));
-    }
-#endif
 #if 0
     fprintf(out, "\nFinalizable objects:\n");
     {
     PRCList *qp;
     qp = _pr_pendingFinalQueue.next;
     while (qp != &_pr_pendingFinalQueue) {
         GCFinal* fp = FinalPtr(qp);
         PRWord h = fp->object[0];        /* Grab header word */
@@ -2296,17 +2295,18 @@ pr_ConservativeTraceRootPointer(PRWord *
 static void PR_CALLBACK
 pr_ConservativeTraceRootBlock(void **base, PRInt32 count)
 {
     PRInt32 status;
     ++pr_traceGen;
     status = pr_ConservativeWalkBlock(base, count, pr_TraceRootPointer, NULL);
     if (status) {
 	FILE* out = _pr_gcData.dumpOutput;
-	fprintf(out, "### from root in range 0x%p + 0x%x\n\n", base, count);
+	fprintf(out, "### from root in range 0x%p + 0x%lx\n\n",
+                base, (long) count);
     }
 }
 
 static void
 PR_TraceRoot1(FILE* out, PRBool detailed)
 {
     RootFinder *rf;
     void (*liveBlock)(void **base, PRInt32 count);
@@ -2405,29 +2405,29 @@ static void DumpApplicationHeap(FILE *ou
 }
 #endif
 
 #if defined(DEBUG) && defined(WIN32)
 static void DumpApplicationHeaps(FILE *out)
 {
     HANDLE mainHeap;
     HANDLE heaps[100];
-    PRInt32 nHeaps;
+    DWORD nHeaps;
     PRInt32 i;
 
     mainHeap = GetProcessHeap();
     nHeaps = GetProcessHeaps(100, heaps);
     if (nHeaps > 100)
     nHeaps = 0;
-    fprintf(out, "%d heaps:\n", nHeaps);
+    fprintf(out, "%ld heaps:\n", (long) nHeaps);
     for (i = 0; i<nHeaps; i++)
     {
     HANDLE heap = heaps[i];
 
-    fprintf(out, "Heap at 0x%.8X", heap);
+    fprintf(out, "Heap at 0x%.8lX", (long) heap);
     if (heap == mainHeap)
         fprintf(out, " (main)");
     fprintf(out, ":\n");
     DumpApplicationHeap(out, heap);
     fprintf(out, "\n");
     }
     fprintf(out, "End of heap dump\n\n");
 }
@@ -2710,17 +2710,17 @@ static void CheckHeap(void) {
     }
 }
 
 #endif /* GC_CHECK */
 
 /******************************************************************************/
 
 #ifdef DEBUG
-int gc_thrash = -1;
+long gc_thrash = -1L;
 #endif
 
 /*
 ** Allocate memory from the GC Heap. Performs garbage collections if
 ** memory gets tight and grows the heap as needed. May return NULL if
 ** memory cannot be found.
 */
 PR_IMPLEMENT(PRWord GCPTR *)PR_AllocMemory(
@@ -2826,17 +2826,17 @@ PR_IMPLEMENT(PRWord GCPTR *)PR_AllocMemo
     PR_ASSERT( bytes < MAX_ALLOC_SIZE );
     /*
     ** Java can ask for objects bigger than MAX_ALLOC_SIZE,
     ** but it won't get them.
     */
     if (bytes >= MAX_ALLOC_SIZE) return NULL;
 
 #ifdef DEBUG
-    if (gc_thrash == -1 ? (gc_thrash = (int)PR_GetEnv("GC_THRASH")):gc_thrash) PR_GC();
+    if (gc_thrash == -1L ? (gc_thrash = (long)PR_GetEnv("GC_THRASH")):gc_thrash) PR_GC();
 #endif
 
     ct = &_pr_collectorTypes[tix];
     if (ct->flags & (_GC_TYPE_FINAL|_GC_TYPE_WEAK)) {
     if (0 != ct->gctype.finalize) {
         /*
         ** Allocate a GCFinal struct for this object in advance. Don't put
         ** it on the pending list until we have allocated the object
@@ -3080,18 +3080,18 @@ PR_AllocSimpleMemory(PRWord requestedByt
 #if defined(WIN16)
     PR_ASSERT( bytes < MAX_ALLOC_SIZE );
 #endif
     /* Java can ask for objects bigger than 4M, but it won't get them */
     if (bytes >= MAX_ALLOC_SIZE) {
         return NULL;
     }
 #ifdef DEBUG
-    if (gc_thrash == -1
-	? (gc_thrash = (int)PR_GetEnv("GC_THRASH"))
+    if (gc_thrash == -1L
+	? (gc_thrash = (long)PR_GetEnv("GC_THRASH"))
 	: gc_thrash) {
 	PR_GC();
     }
 #endif
 
     LOCK_GC();
 #ifdef GC_CHECK
     if (_pr_gcData.flags & GC_CHECK) {