From f6f8bdc72dc1923e696de09cda90ab2f3ead695b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 20 Jan 2021 16:19:21 +0000 Subject: Make tclCkalloc.c and tclExecute warning-free on Windows when compiled with --enable-memory=(mem|all). --- generic/tclCkalloc.c | 14 +++++++------- generic/tclExecute.c | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c index 6d661f6..48832d9 100644 --- a/generic/tclCkalloc.c +++ b/generic/tclCkalloc.c @@ -252,7 +252,7 @@ ValidateMemory( if (guard_failed) { TclDumpMemoryInfo((ClientData) stderr, 0); fprintf(stderr, "low guard failed at %lx, %s %d\n", - (long unsigned) memHeaderP->body, file, line); + (unsigned long)(size_t)memHeaderP->body, file, line); fflush(stderr); /* In case name pointer is bad. */ fprintf(stderr, "%ld bytes allocated at (%s %d)\n", memHeaderP->length, memHeaderP->file, memHeaderP->line); @@ -274,7 +274,7 @@ ValidateMemory( if (guard_failed) { TclDumpMemoryInfo((ClientData) stderr, 0); fprintf(stderr, "high guard failed at %lx, %s %d\n", - (long unsigned) memHeaderP->body, file, line); + (unsigned long)(size_t)memHeaderP->body, file, line); fflush(stderr); /* In case name pointer is bad. */ fprintf(stderr, "%ld bytes allocated at (%s %d)\n", memHeaderP->length, memHeaderP->file, @@ -360,8 +360,8 @@ Tcl_DumpActiveMemory( for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink) { address = &memScanP->body[0]; fprintf(fileP, "%8lx - %8lx %7ld @ %s %d %s", - (long unsigned) address, - (long unsigned) address + memScanP->length - 1, + (unsigned long)(size_t)address, + (unsigned long)(size_t)address + memScanP->length - 1, memScanP->length, memScanP->file, memScanP->line, (memScanP->tagPtr == NULL) ? "" : memScanP->tagPtr->string); (void) fputc('\n', fileP); @@ -459,7 +459,7 @@ Tcl_DbCkalloc( if (alloc_tracing) { fprintf(stderr,"ckalloc %lx %u %s %d\n", - (long unsigned int) result->body, size, file, line); + (unsigned long)(size_t)result->body, size, file, line); } if (break_on_malloc && (total_mallocs >= break_on_malloc)) { @@ -548,7 +548,7 @@ Tcl_AttemptDbCkalloc( if (alloc_tracing) { fprintf(stderr,"ckalloc %lx %u %s %d\n", - (long unsigned int) result->body, size, file, line); + (unsigned long)(size_t)result->body, size, file, line); } if (break_on_malloc && (total_mallocs >= break_on_malloc)) { @@ -613,7 +613,7 @@ Tcl_DbCkfree( if (alloc_tracing) { fprintf(stderr, "ckfree %lx %ld %s %d\n", - (long unsigned int) memp->body, memp->length, file, line); + (unsigned long)(size_t)memp->body, memp->length, file, line); } if (validate_memory) { diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 0a293bd..1d5a0e8 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8924,7 +8924,7 @@ ExecuteExtendedBinaryMathOp( * We refuse to accept exponent arguments that exceed one mp_digit * which means the max exponent value is 2**28-1 = 0x0FFFFFFF = * 268435455, which fits into a signed 32 bit int which is within the - * range of the long int type. This means any numeric Tcl_Obj value + * range of the long type. This means any numeric Tcl_Obj value * not using TCL_NUMBER_LONG type must hold a value larger than we * accept. */ @@ -9675,20 +9675,20 @@ ValidatePcAndStackTop( { int stackUpperBound = codePtr->maxStackDepth; /* Greatest legal value for stackTop. */ - unsigned relativePc = (unsigned) (pc - codePtr->codeStart); - unsigned long codeStart = (unsigned long) codePtr->codeStart; - unsigned long codeEnd = (unsigned long) + size_t relativePc = (size_t) (pc - codePtr->codeStart); + size_t codeStart = (size_t) codePtr->codeStart; + size_t codeEnd = (size_t) (codePtr->codeStart + codePtr->numCodeBytes); unsigned char opCode = *pc; - if (((unsigned long) pc < codeStart) || ((unsigned long) pc > codeEnd)) { + if (((size_t) pc < codeStart) || ((size_t) pc > codeEnd)) { fprintf(stderr, "\nBad instruction pc 0x%p in TclNRExecuteByteCode\n", pc); Tcl_Panic("TclNRExecuteByteCode execution failure: bad pc"); } if ((unsigned) opCode > LAST_INST_OPCODE) { - fprintf(stderr, "\nBad opcode %d at pc %u in TclNRExecuteByteCode\n", - (unsigned) opCode, relativePc); + fprintf(stderr, "\nBad opcode %d at pc %lu in TclNRExecuteByteCode\n", + (unsigned) opCode, (unsigned long)relativePc); Tcl_Panic("TclNRExecuteByteCode execution failure: bad opcode"); } if (checkStack && @@ -9696,8 +9696,8 @@ ValidatePcAndStackTop( int numChars; const char *cmd = GetSrcInfoForPc(pc, codePtr, &numChars, NULL, NULL); - fprintf(stderr, "\nBad stack top %d at pc %u in TclNRExecuteByteCode (min 0, max %i)", - stackTop, relativePc, stackUpperBound); + fprintf(stderr, "\nBad stack top %d at pc %lu in TclNRExecuteByteCode (min 0, max %i)", + stackTop, (unsigned long)relativePc, stackUpperBound); if (cmd != NULL) { Tcl_Obj *message; @@ -10284,7 +10284,7 @@ EvalStatsCmd( Tcl_AppendPrintfToObj(objPtr, "\n----------------------------------------------------------------\n"); Tcl_AppendPrintfToObj(objPtr, "Compilation and execution statistics for interpreter %#lx\n", - (long int)iPtr); + (unsigned long)(size_t)iPtr); Tcl_AppendPrintfToObj(objPtr, "\nNumber ByteCodes executed\t%ld\n", statsPtr->numExecutions); -- cgit v0.12