diff options
author | drh <drh@noemail.net> | 2008-12-10 18:03:45 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-12-10 18:03:45 +0000 |
commit | b27b7f5d3b5d9d249b9abb258ac0e6cb54b78fdd (patch) | |
tree | f266bfdff1ff55e5405f2bb29424ce7560cfbb8c /src | |
parent | dc5ea5c785bcbd5a623915b47edb42c772439a8d (diff) | |
download | sqlite-b27b7f5d3b5d9d249b9abb258ac0e6cb54b78fdd.tar.gz sqlite-b27b7f5d3b5d9d249b9abb258ac0e6cb54b78fdd.zip |
More explicit type casting to silence VC++. (CVS 6006)
FossilOrigin-Name: 14e6d19c3157ccdce170e769d678c7f472dd3db2
Diffstat (limited to 'src')
-rw-r--r-- | src/parse.y | 24 | ||||
-rw-r--r-- | src/pcache1.c | 6 | ||||
-rw-r--r-- | src/printf.c | 4 | ||||
-rw-r--r-- | src/resolve.c | 4 | ||||
-rw-r--r-- | src/select.c | 12 | ||||
-rw-r--r-- | src/update.c | 10 | ||||
-rw-r--r-- | src/vdbe.c | 14 | ||||
-rw-r--r-- | src/vdbeapi.c | 11 | ||||
-rw-r--r-- | src/vdbemem.c | 6 | ||||
-rw-r--r-- | src/vtab.c | 20 |
10 files changed, 55 insertions, 56 deletions
diff --git a/src/parse.y b/src/parse.y index 5fa11ad5c..e6788b3b7 100644 --- a/src/parse.y +++ b/src/parse.y @@ -14,7 +14,7 @@ ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.264 2008/12/08 16:01:13 drh Exp $ +** @(#) $Id: parse.y,v 1.265 2008/12/10 18:03:46 drh Exp $ */ // All token codes are small integers with #defines that begin with "TK_" @@ -149,7 +149,7 @@ columnlist ::= column. // column(A) ::= columnid(X) type carglist. { A.z = X.z; - A.n = (pParse->sLastToken.z-X.z) + pParse->sLastToken.n; + A.n = (int)(pParse->sLastToken.z-X.z) + pParse->sLastToken.n; } columnid(A) ::= nm(X). { sqlite3AddColumn(pParse,&X); @@ -226,15 +226,15 @@ type ::= typetoken(X). {sqlite3AddColumnType(pParse,&X);} typetoken(A) ::= typename(X). {A = X;} typetoken(A) ::= typename(X) LP signed RP(Y). { A.z = X.z; - A.n = &Y.z[Y.n] - X.z; + A.n = (int)(&Y.z[Y.n] - X.z); } typetoken(A) ::= typename(X) LP signed COMMA signed RP(Y). { A.z = X.z; - A.n = &Y.z[Y.n] - X.z; + A.n = (int)(&Y.z[Y.n] - X.z); } %type typename {Token} typename(A) ::= ids(X). {A = X;} -typename(A) ::= typename(X) ids(Y). {A.z=X.z; A.n=Y.n+(Y.z-X.z);} +typename(A) ::= typename(X) ids(Y). {A.z=X.z; A.n=Y.n+(int)(Y.z-X.z);} signed ::= plus_num. signed ::= minus_num. @@ -377,7 +377,7 @@ select(A) ::= oneselect(X). {A = X;} %ifndef SQLITE_OMIT_COMPOUND_SELECT select(A) ::= select(X) multiselect_op(Y) oneselect(Z). { if( Z ){ - Z->op = Y; + Z->op = (u8)Y; Z->pPrior = X; }else{ sqlite3SelectDelete(pParse->db, X); @@ -456,7 +456,7 @@ from(A) ::= FROM seltablist(X). { // stl_prefix(A) ::= seltablist(X) joinop(Y). { A = X; - if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = Y; + if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = (u8)Y; } stl_prefix(A) ::= . {A = 0;} seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) indexed_opt(I) on_opt(N) using_opt(U). { @@ -546,11 +546,11 @@ orderby_opt(A) ::= . {A = 0;} orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;} sortlist(A) ::= sortlist(X) COMMA sortitem(Y) sortorder(Z). { A = sqlite3ExprListAppend(pParse,X,Y,0); - if( A ) A->a[A->nExpr-1].sortOrder = Z; + if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z; } sortlist(A) ::= sortitem(Y) sortorder(Z). { A = sqlite3ExprListAppend(pParse,0,Y,0); - if( A && A->a ) A->a[0].sortOrder = Z; + if( A && A->a ) A->a[0].sortOrder = (u8)Z; } sortitem(A) ::= expr(X). {A = X;} @@ -950,7 +950,7 @@ idxlist(A) ::= idxlist(X) COMMA nm(Y) collate(C) sortorder(Z). { } A = sqlite3ExprListAppend(pParse,X, p, &Y); sqlite3ExprListCheckLength(pParse, A, "index"); - if( A ) A->a[A->nExpr-1].sortOrder = Z; + if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z; } idxlist(A) ::= nm(Y) collate(C) sortorder(Z). { Expr *p = 0; @@ -960,7 +960,7 @@ idxlist(A) ::= nm(Y) collate(C) sortorder(Z). { } A = sqlite3ExprListAppend(pParse,0, p, &Y); sqlite3ExprListCheckLength(pParse, A, "index"); - if( A ) A->a[A->nExpr-1].sortOrder = Z; + if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z; } %type collate {Token} @@ -1010,7 +1010,7 @@ plus_opt ::= . cmd ::= CREATE trigger_decl(A) BEGIN trigger_cmd_list(S) END(Z). { Token all; all.z = A.z; - all.n = (Z.z - A.z) + Z.n; + all.n = (int)(Z.z - A.z) + Z.n; sqlite3FinishTrigger(pParse, S, &all); } diff --git a/src/pcache1.c b/src/pcache1.c index cfaf5aadb..5f9dfa679 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -16,7 +16,7 @@ ** If the default page cache implementation is overriden, then neither of ** these two features are available. ** -** @(#) $Id: pcache1.c,v 1.5 2008/12/06 14:34:34 drh Exp $ +** @(#) $Id: pcache1.c,v 1.6 2008/12/10 18:03:46 drh Exp $ */ #include "sqliteInt.h" @@ -272,7 +272,7 @@ static int pcache1ResizeHash(PCache1 *p){ for(i=0; i<p->nHash; i++){ PgHdr1 *pPage; PgHdr1 *pNext = p->apHash[i]; - while( (pPage = pNext) ){ + while( (pPage = pNext)!=0 ){ unsigned int h = pPage->iKey % nNew; pNext = pPage->pNext; pPage->pNext = apNew[h]; @@ -364,7 +364,7 @@ static void pcache1TruncateUnsafe( for(h=0; h<pCache->nHash; h++){ PgHdr1 **pp = &pCache->apHash[h]; PgHdr1 *pPage; - while( (pPage = *pp) ){ + while( (pPage = *pp)!=0 ){ if( pPage->iKey>=iLimit ){ pcache1PinPage(pPage); *pp = pPage->pNext; diff --git a/src/printf.c b/src/printf.c index 6798aa7dd..6518ddb22 100644 --- a/src/printf.c +++ b/src/printf.c @@ -5,7 +5,7 @@ ** an historical reference. Most of the "enhancements" have been backed ** out so that the functionality is now the same as standard printf(). ** -** $Id: printf.c,v 1.97 2008/11/22 18:28:51 drh Exp $ +** $Id: printf.c,v 1.98 2008/12/10 18:03:46 drh Exp $ ** ************************************************************************** ** @@ -245,7 +245,7 @@ void sqlite3VXPrintf( const et_info *infop; /* Pointer to the appropriate info structure */ char buf[etBUFSIZE]; /* Conversion buffer */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ - etByte xtype; /* Conversion paradigm */ + etByte xtype = 0; /* Conversion paradigm */ char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ #ifndef SQLITE_OMIT_FLOATING_POINT int exp, e2; /* exponent of real numbers */ diff --git a/src/resolve.c b/src/resolve.c index 77de62c7e..33b0335b5 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -14,7 +14,7 @@ ** resolve all identifiers by associating them with a particular ** table and column. ** -** $Id: resolve.c,v 1.13 2008/12/09 14:03:22 drh Exp $ +** $Id: resolve.c,v 1.14 2008/12/10 18:03:46 drh Exp $ */ #include "sqliteInt.h" #include <stdlib.h> @@ -219,7 +219,7 @@ static int lookupName( if( zDb==0 && zTab!=0 && cnt==0 && pParse->trigStack!=0 ){ TriggerStack *pTriggerStack = pParse->trigStack; Table *pTab = 0; - u32 *piColMask; + u32 *piColMask = 0; if( pTriggerStack->newIdx != -1 && sqlite3StrICmp("new", zTab) == 0 ){ pExpr->iTable = pTriggerStack->newIdx; assert( pTriggerStack->pTab ); diff --git a/src/select.c b/src/select.c index a2b532c77..3468c1fd3 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.491 2008/12/10 17:20:01 drh Exp $ +** $Id: select.c,v 1.492 2008/12/10 18:03:46 drh Exp $ */ #include "sqliteInt.h" @@ -2034,7 +2034,7 @@ static int multiSelectOrderBy( int regOutA; /* Address register for the output-A subroutine */ int regOutB; /* Address register for the output-B subroutine */ int addrOutA; /* Address of the output-A subroutine */ - int addrOutB; /* Address of the output-B subroutine */ + int addrOutB = 0; /* Address of the output-B subroutine */ int addrEofA; /* Address of the select-A-exhausted subroutine */ int addrEofB; /* Address of the select-B-exhausted subroutine */ int addrAltB; /* Address of the A<B subroutine */ @@ -3539,17 +3539,13 @@ int sqlite3Select( p->selFlags &= ~SF_Distinct; } sqlite3SelectPrep(pParse, p, 0); + pTabList = p->pSrc; + pEList = p->pEList; if( pParse->nErr || db->mallocFailed ){ goto select_end; } p->pOrderBy = pOrderBy; - - - /* Make local copies of the parameters for this query. - */ - pTabList = p->pSrc; isAgg = (p->selFlags & SF_Aggregate)!=0; - pEList = p->pEList; if( pEList==0 ) goto select_end; /* diff --git a/src/update.c b/src/update.c index 06b500de5..ff52524fa 100644 --- a/src/update.c +++ b/src/update.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** -** $Id: update.c,v 1.188 2008/12/04 20:40:10 drh Exp $ +** $Id: update.c,v 1.189 2008/12/10 18:03:47 drh Exp $ */ #include "sqliteInt.h" @@ -109,10 +109,10 @@ void sqlite3Update( int isView; /* Trying to update a view */ int triggers_exist = 0; /* True if any row triggers exist */ #endif - int iBeginAfterTrigger; /* Address of after trigger program */ - int iEndAfterTrigger; /* Exit of after trigger program */ - int iBeginBeforeTrigger; /* Address of before trigger program */ - int iEndBeforeTrigger; /* Exit of before trigger program */ + int iBeginAfterTrigger = 0; /* Address of after trigger program */ + int iEndAfterTrigger = 0; /* Exit of after trigger program */ + int iBeginBeforeTrigger = 0; /* Address of before trigger program */ + int iEndBeforeTrigger = 0; /* Exit of before trigger program */ u32 old_col_mask = 0; /* Mask of OLD.* columns in use */ u32 new_col_mask = 0; /* Mask of NEW.* columns in use */ diff --git a/src/vdbe.c b/src/vdbe.c index 5b754da03..84d95746b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.793 2008/12/09 02:51:24 drh Exp $ +** $Id: vdbe.c,v 1.794 2008/12/10 18:03:47 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -538,8 +538,10 @@ int sqlite3VdbeExec( int rc = SQLITE_OK; /* Value to return */ sqlite3 *db = p->db; /* The database */ u8 encoding = ENC(db); /* The database encoding */ - Mem *pIn1, *pIn2, *pIn3; /* Input operands */ - Mem *pOut; /* Output operand */ + Mem *pIn1 = 0; /* 1st input operand */ + Mem *pIn2 = 0; /* 2nd input operand */ + Mem *pIn3 = 0; /* 3rd input operand */ + Mem *pOut = 0; /* Output operand */ u8 opProperty; int iCompare = 0; /* Result of last OP_Compare operation */ int *aPermute = 0; /* Permuation of columns for OP_Compare */ @@ -1977,9 +1979,7 @@ case OP_Column: { Mem *pDest; /* Where to write the extracted value */ Mem sMem; /* For storing the record being decoded */ - sMem.flags = 0; - sMem.db = 0; - sMem.zMalloc = 0; + memset(&sMem, 0, sizeof(sMem)); assert( p1<p->nCursor ); assert( pOp->p3>0 && pOp->p3<=p->nMem ); pDest = &p->aMem[pOp->p3]; @@ -2054,7 +2054,7 @@ case OP_Column: { u8 *zEndHdr; /* Pointer to first byte after the header */ int offset; /* Offset into the data */ int szHdrSz; /* Size of the header size field at start of record */ - int avail; /* Number of bytes of available data */ + int avail = 0; /* Number of bytes of available data */ assert(aType); pC->aOffset = aOffset = &aType[nField]; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 95fbf5c18..8f3c2b388 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -13,7 +13,7 @@ ** This file contains code use to implement APIs that are part of the ** VDBE. ** -** $Id: vdbeapi.c,v 1.149 2008/11/19 09:05:27 danielk1977 Exp $ +** $Id: vdbeapi.c,v 1.150 2008/12/10 18:03:47 drh Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -284,7 +284,7 @@ double sqlite3_value_double(sqlite3_value *pVal){ return sqlite3VdbeRealValue((Mem*)pVal); } int sqlite3_value_int(sqlite3_value *pVal){ - return sqlite3VdbeIntValue((Mem*)pVal); + return (int)sqlite3VdbeIntValue((Mem*)pVal); } sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){ return sqlite3VdbeIntValue((Mem*)pVal); @@ -463,7 +463,7 @@ static int sqlite3Step(Vdbe *p){ if( db->xProfile && !db->init.busy ){ double rNow; sqlite3OsCurrentTime(db->pVfs, &rNow); - p->startTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0; + p->startTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0); } #endif @@ -494,7 +494,8 @@ static int sqlite3Step(Vdbe *p){ u64 elapseTime; sqlite3OsCurrentTime(db->pVfs, &rNow); - elapseTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0 - p->startTime; + elapseTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0); + elapseTime -= p->startTime; db->xProfile(db->pProfileArg, p->aOp[0].p4.z, elapseTime); } #endif @@ -1052,7 +1053,7 @@ static int bindText( const void *zData, /* Pointer to the data to be bound */ int nData, /* Number of bytes of data to be bound */ void (*xDel)(void*), /* Destructor for the data */ - int encoding /* Encoding for the data */ + u8 encoding /* Encoding for the data */ ){ Vdbe *p = (Vdbe *)pStmt; Mem *pVar; diff --git a/src/vdbemem.c b/src/vdbemem.c index 4f9a9cff2..466c24da9 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -15,7 +15,7 @@ ** only within the VDBE. Interface routines refer to a Mem using the ** name sqlite_value ** -** $Id: vdbemem.c,v 1.131 2008/12/10 11:49:06 drh Exp $ +** $Id: vdbemem.c,v 1.132 2008/12/10 18:03:47 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -43,6 +43,8 @@ int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){ int rc; assert( (pMem->flags&MEM_RowSet)==0 ); + assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE + || desiredEnc==SQLITE_UTF16BE ); if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){ return SQLITE_OK; } @@ -54,7 +56,7 @@ int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){ /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, ** then the encoding of the value may not have changed. */ - rc = sqlite3VdbeMemTranslate(pMem, desiredEnc); + rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc); assert(rc==SQLITE_OK || rc==SQLITE_NOMEM); assert(rc==SQLITE_OK || pMem->enc!=desiredEnc); assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc); diff --git a/src/vtab.c b/src/vtab.c index 9dbd0dd2c..ee7bb30ef 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to help implement virtual tables. ** -** $Id: vtab.c,v 1.79 2008/12/10 17:20:01 drh Exp $ +** $Id: vtab.c,v 1.80 2008/12/10 18:03:47 drh Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE #include "sqliteInt.h" @@ -27,7 +27,7 @@ static int createModule( Module *pMod; sqlite3_mutex_enter(db->mutex); - nName = strlen(zName); + nName = (int)strlen(zName); pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1); if( pMod ){ Module *pDel; @@ -193,7 +193,7 @@ void sqlite3VtabBeginParse( addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName)); addModuleArgument(db, pTable, sqlite3DbStrDup(db, db->aDb[iDb].zName)); addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName)); - pParse->sNameToken.n = pModuleName->z + pModuleName->n - pName1->z; + pParse->sNameToken.n = (int)(&pModuleName->z[pModuleName->n] - pName1->z); #ifndef SQLITE_OMIT_AUTHORIZATION /* Creating a virtual table invokes the authorization callback twice. @@ -241,7 +241,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ db = pParse->db; if( pTab->nModuleArg<1 ) return; zModule = pTab->azModuleArg[0]; - pMod = (Module *)sqlite3HashFind(&db->aModule, zModule, strlen(zModule)); + pMod = (Module*)sqlite3HashFind(&db->aModule, zModule, (int)strlen(zModule)); pTab->pMod = pMod; /* If the CREATE VIRTUAL TABLE statement is being entered for the @@ -258,7 +258,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ if( pEnd ){ - pParse->sNameToken.n = pEnd->z - pParse->sNameToken.z + pEnd->n; + pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n; } zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken); @@ -289,7 +289,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ zWhere = sqlite3MPrintf(db, "name='%q'", pTab->zName); sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 1, 0, zWhere, P4_DYNAMIC); sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, - pTab->zName, strlen(pTab->zName) + 1); + pTab->zName, (int)strlen(pTab->zName) + 1); } /* If we are rereading the sqlite_master table create the in-memory @@ -300,7 +300,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ Table *pOld; Schema *pSchema = pTab->pSchema; const char *zName = pTab->zName; - int nName = strlen(zName) + 1; + int nName = (int)strlen(zName) + 1; pOld = sqlite3HashInsert(&pSchema->tblHash, zName, nName, pTab); if( pOld ){ db->mallocFailed = 1; @@ -333,7 +333,7 @@ void sqlite3VtabArgExtend(Parse *pParse, Token *p){ pArg->n = p->n; }else{ assert(pArg->z < p->z); - pArg->n = (p->z + p->n - pArg->z); + pArg->n = (int)(&p->z[p->n] - pArg->z); } } @@ -405,7 +405,7 @@ static int vtabCallConstructor( int nType; int i = 0; if( !zType ) continue; - nType = strlen(zType); + nType = (int)strlen(zType); if( sqlite3StrNICmp("hidden", zType, 6) || (zType[6] && zType[6]!=' ') ){ for(i=0; i<nType; i++){ if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7)) @@ -804,7 +804,7 @@ FuncDef *sqlite3VtabOverloadFunction( /* Create a new ephemeral function definition for the overloaded ** function */ - pNew = sqlite3DbMallocZero(db, sizeof(*pNew) + strlen(pDef->zName) ); + pNew = sqlite3DbMallocZero(db, sizeof(*pNew) + (int)strlen(pDef->zName) ); if( pNew==0 ){ return pDef; } |