From f2a1ea5dbae4b3440723227e75a0c9da1d88ff93 Mon Sep 17 00:00:00 2001 From: das Date: Thu, 20 Jul 2006 06:17:38 +0000 Subject: * generic/regc_locale.c (cclass): * generic/tclExecute.c (TclExecuteByteCode): * generic/tclIOCmd.c (Tcl_ExecObjCmd): * generic/tclListObj.c (NewListIntRep): * generic/tclObj.c (Tcl_GetLongFromObj, Tcl_GetWideIntFromObj, FreeBignum, Tcl_SetBignumObj): * generic/tclParseExpr.c (Tcl_ParseExpr): * generic/tclStrToD.c (TclParseNumber): * generic/tclStringObj.c (TclAppendFormattedObjs): * unix/tclUnixPipe.c (TclpCreateProcess): fix signed-with-unsigned comparison and other warnings from gcc4 -Wextra. --- generic/regc_locale.c | 38 +++++++++++++++++++------------------- generic/tclExecute.c | 10 +++++----- generic/tclIOCmd.c | 4 ++-- generic/tclListObj.c | 4 ++-- generic/tclObj.c | 16 ++++++++-------- generic/tclParseExpr.c | 4 ++-- generic/tclStrToD.c | 14 +++++++------- generic/tclStringObj.c | 4 ++-- unix/tclUnixPipe.c | 7 ++++--- 9 files changed, 51 insertions(+), 50 deletions(-) diff --git a/generic/regc_locale.c b/generic/regc_locale.c index 1b573d8..e6eb12a 100644 --- a/generic/regc_locale.c +++ b/generic/regc_locale.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: regc_locale.c,v 1.13 2006/04/12 14:13:30 dkf Exp $ + * RCS: @(#) $Id: regc_locale.c,v 1.14 2006/07/20 06:17:38 das Exp $ */ /* ASCII character-name table */ @@ -891,10 +891,10 @@ cclass( case CC_PRINT: cv = getcvec(v, NUM_PRINT_CHAR, NUM_PRINT_RANGE, 0); if (cv) { - for (i=0 ; i ", O2S(valuePtr), O2S(value2Ptr))); - if ((type1 == TCL_NUMBER_LONG) && (shift < CHAR_BIT*sizeof(long)) + if ((type1 == TCL_NUMBER_LONG) && ((size_t)shift < CHAR_BIT*sizeof(long)) && (l1 = *((CONST long *)ptr1)) && !(((l1>0) ? l1 : ~l1) & -(1<<(CHAR_BIT*sizeof(long)-1-shift)))) { @@ -3951,7 +3951,7 @@ TclExecuteByteCode( /* Handle shifts within the native wide range */ TRACE(("%s %s => ", O2S(valuePtr), O2S(value2Ptr))); if ((type1 != TCL_NUMBER_BIG) - && (shift < CHAR_BIT*sizeof(Tcl_WideInt))) { + && ((size_t)shift < CHAR_BIT*sizeof(Tcl_WideInt))) { Tcl_WideInt w; TclGetWideIntFromObj(NULL, valuePtr, &w); @@ -4007,7 +4007,7 @@ TclExecuteByteCode( /* Handle shifts within the native long range */ if (type1 == TCL_NUMBER_LONG) { l1 = *((CONST long *)ptr1); - if (shift >= CHAR_BIT*sizeof(long)) { + if ((size_t)shift >= CHAR_BIT*sizeof(long)) { if (l1 >= (long)0) { objResultPtr = eePtr->constants[0]; } else { @@ -4023,7 +4023,7 @@ TclExecuteByteCode( /* Handle shifts within the native wide range */ if (type1 == TCL_NUMBER_WIDE) { Tcl_WideInt w = *((CONST Tcl_WideInt *)ptr1); - if (shift >= CHAR_BIT*sizeof(Tcl_WideInt)) { + if ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideInt)) { if (w >= (Tcl_WideInt)0) { objResultPtr = eePtr->constants[0]; } else { diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 276ccf5..4b5974b 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOCmd.c,v 1.33 2005/11/04 22:38:38 msofer Exp $ + * RCS: @(#) $Id: tclIOCmd.c,v 1.34 2006/07/20 06:17:39 das Exp $ */ #include "tclInt.h" @@ -852,7 +852,7 @@ Tcl_ExecObjCmd( argv = argStorage; argc = objc - skip; - if ((argc + 1) > sizeof(argv) / sizeof(argv[0])) { + if ((size_t)(argc + 1) > sizeof(argv) / sizeof(argv[0])) { argv = (CONST char **) ckalloc((unsigned)(argc + 1) * sizeof(char *)); } diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 1bc0344..d4da0e8 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclListObj.c,v 1.31 2005/12/13 22:43:18 kennykb Exp $ + * RCS: @(#) $Id: tclListObj.c,v 1.32 2006/07/20 06:17:39 das Exp $ */ #include "tclInt.h" @@ -90,7 +90,7 @@ NewListIntRep( * requires API changes to fix. */ - if (objc > INT_MAX/sizeof(Tcl_Obj *)) { + if ((size_t)objc > INT_MAX/sizeof(Tcl_Obj *)) { return NULL; } diff --git a/generic/tclObj.c b/generic/tclObj.c index 7d89f98..521a49b 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclObj.c,v 1.108 2006/06/21 03:10:39 dgp Exp $ + * RCS: @(#) $Id: tclObj.c,v 1.109 2006/07/20 06:17:39 das Exp $ */ #include "tclInt.h" @@ -158,7 +158,7 @@ static Tcl_ThreadDataKey pendingObjDataKey; } #define UNPACK_BIGNUM(objPtr, bignum) \ - if ((objPtr)->internalRep.ptrAndLongRep.value == -1) { \ + if ((objPtr)->internalRep.ptrAndLongRep.value == (unsigned long)(-1)) { \ (bignum) = *((mp_int *) ((objPtr)->internalRep.ptrAndLongRep.ptr)); \ } else { \ (bignum).dp = (mp_digit*) (objPtr)->internalRep.ptrAndLongRep.ptr; \ @@ -2171,7 +2171,7 @@ Tcl_GetLongFromObj( mp_int big; UNPACK_BIGNUM(objPtr, big); - if (big.used <= (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) + if ((size_t)(big.used) <= (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT) { unsigned long value = 0, numBytes = sizeof(long); long scratch; @@ -2470,8 +2470,8 @@ Tcl_GetWideIntFromObj( mp_int big; UNPACK_BIGNUM(objPtr, big); - if (big.used <= (CHAR_BIT * sizeof(Tcl_WideInt) + DIGIT_BIT - 1) - / DIGIT_BIT) { + if ((size_t)(big.used) <= (CHAR_BIT * sizeof(Tcl_WideInt) + + DIGIT_BIT - 1) / DIGIT_BIT) { Tcl_WideUInt value = 0; unsigned long numBytes = sizeof(Tcl_WideInt); Tcl_WideInt scratch; @@ -2524,7 +2524,7 @@ FreeBignum( UNPACK_BIGNUM(objPtr, toFree); mp_clear(&toFree); - if (objPtr->internalRep.ptrAndLongRep.value < 0) { + if ((long)(objPtr->internalRep.ptrAndLongRep.value) < 0) { ckfree((char *)objPtr->internalRep.ptrAndLongRep.ptr); } } @@ -2871,7 +2871,7 @@ Tcl_SetBignumObj( if (Tcl_IsShared(objPtr)) { Tcl_Panic("Tcl_SetBignumObj called with shared object"); } - if (bignumValue->used + if ((size_t)(bignumValue->used) <= (CHAR_BIT * sizeof(long) + DIGIT_BIT - 1) / DIGIT_BIT) { unsigned long value = 0, numBytes = sizeof(long); long scratch; @@ -2895,7 +2895,7 @@ Tcl_SetBignumObj( } tooLargeForLong: #ifndef NO_WIDE_TYPE - if (bignumValue->used + if ((size_t)(bignumValue->used) <= (CHAR_BIT * sizeof(Tcl_WideInt) + DIGIT_BIT - 1) / DIGIT_BIT) { Tcl_WideUInt value = 0; unsigned long numBytes = sizeof(Tcl_WideInt); diff --git a/generic/tclParseExpr.c b/generic/tclParseExpr.c index 9cbc34f..4453f2b 100644 --- a/generic/tclParseExpr.c +++ b/generic/tclParseExpr.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclParseExpr.c,v 1.34 2006/07/05 20:42:15 dgp Exp $ + * RCS: @(#) $Id: tclParseExpr.c,v 1.35 2006/07/20 06:17:39 das Exp $ */ #define OLD_EXPR_PARSER 0 @@ -2107,7 +2107,7 @@ Tcl_ParseExpr( Tcl_Obj *msg = NULL; unsigned char precedence; CONST char *space, *operand, *end; - int scanned, size, limit = 25, code = TCL_OK; + int scanned = 0, size, limit = 25, code = TCL_OK; if (numBytes < 0) { numBytes = (start ? strlen(start) : 0); diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 5b7993c..7d03c2b 100755 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclStrToD.c,v 1.23 2006/06/21 03:10:39 dgp Exp $ + * RCS: @(#) $Id: tclStrToD.c,v 1.24 2006/07/20 06:17:39 das Exp $ * *---------------------------------------------------------------------- */ @@ -450,7 +450,7 @@ TclParseNumber( */ if ((octalSignificandWide != 0) - && ((shift >= CHAR_BIT*sizeof(Tcl_WideUInt)) + && (((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt)) || (octalSignificandWide > (~(Tcl_WideUInt)0 >> shift)))) { octalSignificandOverflow = 1; @@ -569,7 +569,7 @@ TclParseNumber( */ if (significandWide != 0 && - (shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || + ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (~(Tcl_WideUInt)0 >> shift))) { significandOverflow = 1; TclBNInitBignumFromWideUInt(&significandBig, @@ -609,7 +609,7 @@ TclParseNumber( */ if (significandWide != 0 && - (shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || + ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (~(Tcl_WideUInt)0 >> shift))) { significandOverflow = 1; TclBNInitBignumFromWideUInt(&significandBig, @@ -930,7 +930,7 @@ TclParseNumber( case BINARY: shift = numTrailZeros; if (!significandOverflow && significandWide != 0 && - (shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || + ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (MOST_BITS + signum) >> shift)) { significandOverflow = 1; TclBNInitBignumFromWideUInt(&significandBig, significandWide); @@ -951,7 +951,7 @@ TclParseNumber( shift = 4 * numTrailZeros; if (!significandOverflow && significandWide !=0 && - (shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || + ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || significandWide > (MOST_BITS + signum) >> shift)) { significandOverflow = 1; TclBNInitBignumFromWideUInt(&significandBig, significandWide); @@ -972,7 +972,7 @@ TclParseNumber( shift = 3 * numTrailZeros; if (!octalSignificandOverflow && octalSignificandWide != 0 && - (shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || + ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || octalSignificandWide > (MOST_BITS + signum) >> shift)) { octalSignificandOverflow = 1; TclBNInitBignumFromWideUInt(&octalSignificandBig, diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index d119176..953cacb 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -33,7 +33,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclStringObj.c,v 1.53 2006/03/23 14:24:57 dgp Exp $ */ + * RCS: @(#) $Id: tclStringObj.c,v 1.54 2006/07/20 06:17:39 das Exp $ */ #include "tclInt.h" #include "tommath.h" @@ -2145,7 +2145,7 @@ TclAppendFormattedObjs( int digitOffset; if (useBig) { - if (shift