1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Modifications to avoid unsigned/signed comparisons in various files. (CVS 5914)

FossilOrigin-Name: 8009220c36635dd9b6efea7dc13281ca9625c40a
This commit is contained in:
danielk1977
2008-11-17 19:18:54 +00:00
parent 234329761a
commit 00e136135e
21 changed files with 106 additions and 115 deletions

View File

@ -1,5 +1,5 @@
C Modifications\sto\savoid\sunsigned/signed\scomparisons\sin\swhere.c.\s(CVS\s5913)
D 2008-11-17T16:42:01
C Modifications\sto\savoid\sunsigned/signed\scomparisons\sin\svarious\sfiles.\s(CVS\s5914)
D 2008-11-17T19:18:55
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 6cbc7db84c23804c368bc7ffe51367412212d7b2
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -99,14 +99,14 @@ F src/analyze.c 91b958435cbb423721ef2a841dbc459c1959bb3a
F src/attach.c 208881c87160d9e2c73a46cf86116c5a6d66f9d7
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
F src/bitvec.c 9e922b2577b7e46d8f95349bca6a52f7674d7582
F src/btmutex.c 3a90096c3080b9057dc570b8e16e46511e1c788a
F src/btmutex.c 63c5cc4ad5715690767ffcb741e185d7bc35ec1a
F src/btree.c 661d322468f8fd5811a20f24bd85388709773cb0
F src/btree.h 179c3ea813780df78a289a8f5130db18e6d4616e
F src/btreeInt.h f4ed02e58381190d5303edb83cff2cc997ba2fa2
F src/build.c 7723123a571fcf9b0c3362dcfffeb1b64ec4f043
F src/build.c a89e901ea24d8ec845286f9a1fbfd14572a7777e
F src/callback.c e970e5beddbdb23f89a6d05cb1a6419d9f755624
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
F src/date.c 6f4277fa56d8c1b8e70c0bde838c9e99609f5ec0
F src/date.c acae103fc63018707b7a64266ca389a2bf91c461
F src/delete.c 3b156e1d396942fe50664af4e45e14e7de08c312
F src/expr.c 0a23a7f58084a40c38e1fc3afcd8adbbc8950b45
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
@ -115,29 +115,29 @@ F src/global.c 20a3fe46c8287a01ba3a7442558f0eb70c66b19a
F src/hash.c 582c00618efe2051785e66ba1b6430d5a129de3f
F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae
F src/hwtime.h 4a1d45f4cae1f402ea19686acf24acf4f0cb53cb
F src/insert.c d61998cb8d934bd42b77bd362f94cc3368c5d5f7
F src/insert.c 47d2c27396724d5050a5f7d6a54ce44ec163e473
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
F src/loadext.c 3872457afdf25bb174fd383cb4e3e0d2a9e60552
F src/main.c fd93666b883dbe976f8fb9a5b87784bde2eca43d
F src/malloc.c a213fb461b8df08aed7606f6a1e1d3452e089000
F src/malloc.c 4a12eb37983abb2210360ac5e417e0c348b1b4fb
F src/mem0.c f2f84062d1f35814d6535c9f9e33de3bfb3b132c
F src/mem1.c 2091081d1c6bcd4516738f37cd84d42e814cf9a2
F src/mem2.c 5d9968f576ba1babc787adbfb613cf428ab484ec
F src/mem3.c 1594f117fde4cf11a6c16521f3f30af8d04bbe68
F src/mem5.c e7c814fd4cf32f27e5824b61eabbe290a11ef311
F src/mem5.c 528adcfaa78201d60fccdfddaf55b18b6fda9697
F src/memjournal.c e2551e89243b39a972a1fbefeedaf4f74438a0cf
F src/mutex.c e9cb5fbe94afb4328869afaf3ac49bd1327559eb
F src/mutex.h 9e686e83a88838dac8b9c51271c651e833060f1e
F src/mutex_noop.c 0004efdbc2fd48d261d5b3416fe537e888c79a54
F src/mutex_os2.c 9c5637aa4c307c552566d0f0b3bd206245b54a97
F src/mutex_unix.c 0c256ff11848a18443e6c99543c585c240fd9935
F src/mutex_unix.c 3b1c895a044d45812ea1eae9019daeff8cfb27ce
F src/mutex_w32.c 017b522f63ef09b834fefc9daa876c9ec167e7b5
F src/os.c 0b411644b87ad689d7250bbfd1834d99b81a3df4
F src/os.h ef8abeb9afc694b82dbd169a91c9b7e26db3c892
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
F src/os_os2.c 63be0987dbeb42e9b08c831863d2a315953b86e1
F src/os_unix.c a25bea30c5beb2e193d96e1d4f382152c7b11f84
F src/os_unix.c 16b0981836576ad7e0c96f094bd2f41a339d078f
F src/os_win.c b1cd079217818e610d6a62c6c71f1e5366a70efe
F src/pager.c d328fcea0bfb3abbc174dba6e6b1ca7c0e1ed7ba
F src/pager.h 4a57b219c0765fe1870238064e3f46e4eb2cf5af
@ -145,16 +145,16 @@ F src/parse.y 2c4758b4c5ead6de8cf7112f5a7cce7561d313fe
F src/pcache.c 439bcf164f10dd0595cbd63f7472881d46dcbb61
F src/pcache.h b6feb183dea39ede8336bb47c5969403d26fa5c0
F src/pcache1.c 0fa9cce1b5fbaa98bb8ab7dd35dfc4c3845ea4ec
F src/pragma.c 5d4333a27ef4f770fc69ca4f138419d3b462c554
F src/prepare.c ae49b8298eca79acdbc964679962e089b943ec94
F src/printf.c 785f87120589c1db672e37c6eb1087c456e6f84d
F src/pragma.c 0a5051029c5b687e2f2669d91aa3281ebcbe4fdb
F src/prepare.c 445452ce02b8826c9e5a7b6d5c08b00a824b3a42
F src/printf.c 5fe6ba48f897caacc8125e3d16c6bbae6b282214
F src/random.c a87afbd598aa877e23ac676ee92fd8ee5c786a51
F src/resolve.c 266bb03d2b456fe68f5df2dd5687e7e88ff8088d
F src/select.c b03c6fe474ded7bd110ca7b551bf0236133c12da
F src/resolve.c 4af5391d2b4c1d6c583a6805ac6660181de4545b
F src/select.c 18c6d96f4f8c6e43cb35201a1245ff02be8c9378
F src/shell.c 650d1a87408682280d0e9d014d0d328c59c84b38
F src/sqlite.h.in 85e159e1d634c84ddbf87481293d5b1d26e2d27b
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
F src/sqliteInt.h 00d4dacfae38aaeb0c95faaab361e69ec007bb76
F src/sqliteInt.h be78bc4fd05602ef842d72077e3a3495f2dd5bf0
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
@ -190,19 +190,19 @@ F src/tokenize.c aaa5fa6a4536a9dd7c855a3f66f32508f1612138
F src/trigger.c 649940b5bf5838a33721fb72372e7c9d1faf56a9
F src/update.c f22a6f4507f9a0ef082418919382f83b90fd2e63
F src/utf.c 86dc0f8076f606432a01f1498ae054c32de1f9d2
F src/util.c afe659ccc05d1f8af9e8631dabfec3ee3a7144af
F src/vacuum.c fd77433d0c26d3ff1eb96eab017a1787ac5aa642
F src/util.c b9a5d1c4c1a433e17d5828f9717fac763016a2cb
F src/vacuum.c 383d6297bddc011ab04a9eed110db6eaf523e8e9
F src/vdbe.c c5270245fcb5368634a9301481ab94a22e7a21b2
F src/vdbe.h 03516f28bf5aca00a53c4dccd6c313f96adb94f6
F src/vdbeInt.h 6b1082480832d406c57a7f469a1c61f1a8759aca
F src/vdbeapi.c ea22e171704906632cd971668359b8c0c5053001
F src/vdbeaux.c 8915d2367a3f338858b3dd29878a69ecd6904147
F src/vdbeaux.c 18dea7bbaf3657d77331b03a3ec34363348ea5b0
F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
F src/vdbefifo.c 20fda2a7c4c0bcee1b90eb7e545fefcdbf2e1de7
F src/vdbefifo.c e6326ad6d16ccd8c2ef659046e3a509c0ae4990a
F src/vdbemem.c 223e03281855515e9474dbf66f157452093a77c2
F src/vtab.c 02c51eac45dbff1a1d6e73f58febf92ecb563f7f
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
F src/where.c 40a5c31ce7caa1a74a1f9de36039592f2e7f45d6
F src/where.c 96f7c2bd9e83c252d90ee2794f7a902fc5ba505b
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
@ -658,7 +658,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 9939dd839ac13708f9b5b877c48729b1781eedf3
R 6a7f6aa6aef43f251afd6a17aa16c7b7
P f35606d1d8cd6dba541a79dcb1307698b8831854
R 35367fc2f48caed98fa7e0477f12a0ca
U danielk1977
Z 422c90bc38e3d7bda709e1458bd66437
Z 12ae1838afc7465245bdcffb676575ba

View File

@ -1 +1 @@
f35606d1d8cd6dba541a79dcb1307698b8831854
8009220c36635dd9b6efea7dc13281ca9625c40a

View File

@ -10,7 +10,7 @@
**
*************************************************************************
**
** $Id: btmutex.c,v 1.11 2008/10/07 15:25:48 drh Exp $
** $Id: btmutex.c,v 1.12 2008/11/17 19:18:55 danielk1977 Exp $
**
** This file contains code used to implement mutexes on Btree objects.
** This code really belongs in btree.c. But btree.c is getting too
@ -248,7 +248,7 @@ void sqlite3BtreeMutexArrayInsert(BtreeMutexArray *pArray, Btree *pBtree){
}
#endif
assert( pArray->nMutex>=0 );
assert( pArray->nMutex<sizeof(pArray->aBtree)/sizeof(pArray->aBtree[0])-1 );
assert( pArray->nMutex<ArraySize(pArray->aBtree)-1 );
pBt = pBtree->pBt;
for(i=0; i<pArray->nMutex; i++){
assert( pArray->aBtree[i]!=pBtree );

View File

@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
** $Id: build.c,v 1.502 2008/11/13 18:29:51 shane Exp $
** $Id: build.c,v 1.503 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -626,7 +626,7 @@ void sqlite3OpenMasterTable(Parse *p, int iDb){
*/
int sqlite3FindDb(sqlite3 *db, Token *pName){
int i = -1; /* Database number */
int n; /* Number of characters in the name */
size_t n; /* Number of characters in the name */
Db *pDb; /* A database whose name space is being searched */
char *zName; /* Name we are searching for */
@ -1396,7 +1396,7 @@ static char *createTableStmt(sqlite3 *db, Table *p, int isTemp){
identPut(zStmt, &k, pCol->zName);
if( (z = pCol->zType)!=0 ){
zStmt[k++] = ' ';
assert( strlen(z)+k+1<=n );
assert( (int)(strlen(z)+k+1)<=n );
sqlite3_snprintf(n-k, &zStmt[k], "%s", z);
k += strlen(z);
}

View File

@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: date.c,v 1.92 2008/10/13 15:35:09 drh Exp $
** $Id: date.c,v 1.93 2008/11/17 19:18:55 danielk1977 Exp $
**
** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon
@ -521,7 +521,7 @@ static int parseModifier(const char *zMod, DateTime *p){
double r;
char *z, zBuf[30];
z = zBuf;
for(n=0; n<sizeof(zBuf)-1 && zMod[n]; n++){
for(n=0; n<ArraySize(zBuf)-1 && zMod[n]; n++){
z[n] = tolower(zMod[n]);
}
z[n] = 0;
@ -889,7 +889,7 @@ static void strftimeFunc(
}
if( n<sizeof(zBuf) ){
z = zBuf;
}else if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){
}else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){
sqlite3_result_error_toobig(context);
return;
}else{

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
** $Id: insert.c,v 1.251 2008/11/03 20:55:07 drh Exp $
** $Id: insert.c,v 1.252 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -1272,26 +1272,26 @@ void sqlite3GenerateConstraintChecks(
case OE_Fail: {
int j, n1, n2;
char zErrMsg[200];
sqlite3_snprintf(sizeof(zErrMsg), zErrMsg,
sqlite3_snprintf(ArraySize(zErrMsg), zErrMsg,
pIdx->nColumn>1 ? "columns " : "column ");
n1 = strlen(zErrMsg);
for(j=0; j<pIdx->nColumn && n1<sizeof(zErrMsg)-30; j++){
for(j=0; j<pIdx->nColumn && n1<ArraySize(zErrMsg)-30; j++){
char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
n2 = strlen(zCol);
if( j>0 ){
sqlite3_snprintf(sizeof(zErrMsg)-n1, &zErrMsg[n1], ", ");
sqlite3_snprintf(ArraySize(zErrMsg)-n1, &zErrMsg[n1], ", ");
n1 += 2;
}
if( n1+n2>sizeof(zErrMsg)-30 ){
sqlite3_snprintf(sizeof(zErrMsg)-n1, &zErrMsg[n1], "...");
if( n1+n2>ArraySize(zErrMsg)-30 ){
sqlite3_snprintf(ArraySize(zErrMsg)-n1, &zErrMsg[n1], "...");
n1 += 3;
break;
}else{
sqlite3_snprintf(sizeof(zErrMsg)-n1, &zErrMsg[n1], "%s", zCol);
sqlite3_snprintf(ArraySize(zErrMsg)-n1, &zErrMsg[n1], "%s", zCol);
n1 += n2;
}
}
sqlite3_snprintf(sizeof(zErrMsg)-n1, &zErrMsg[n1],
sqlite3_snprintf(ArraySize(zErrMsg)-n1, &zErrMsg[n1],
pIdx->nColumn>1 ? " are not unique" : " is not unique");
sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, zErrMsg,0);
break;

View File

@ -12,7 +12,7 @@
**
** Memory allocation functions used throughout sqlite.
**
** $Id: malloc.c,v 1.45 2008/10/12 00:27:53 shane Exp $
** $Id: malloc.c,v 1.46 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@ -387,7 +387,7 @@ void sqlite3ScratchFree(void *p){
i /= sqlite3GlobalConfig.szScratch;
assert( i>=0 && i<sqlite3GlobalConfig.nScratch );
sqlite3_mutex_enter(mem0.mutex);
assert( mem0.nScratchFree<sqlite3GlobalConfig.nScratch );
assert( mem0.nScratchFree<(u32)sqlite3GlobalConfig.nScratch );
mem0.aScratchFree[mem0.nScratchFree++] = i;
sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);
sqlite3_mutex_leave(mem0.mutex);

View File

@ -23,7 +23,7 @@
** This version of the memory allocation subsystem is included
** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.
**
** $Id: mem5.c,v 1.16 2008/11/13 16:21:50 danielk1977 Exp $
** $Id: mem5.c,v 1.17 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -208,7 +208,7 @@ static void *memsys5MallocUnsafe(int nByte){
/* Keep track of the maximum allocation request. Even unfulfilled
** requests are counted */
if( nByte>mem5.maxRequest ){
if( (u32)nByte>mem5.maxRequest ){
mem5.maxRequest = nByte;
}
@ -264,12 +264,12 @@ static void memsys5FreeUnsafe(void *pOld){
iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE;
size = 1<<iLogsize;
assert( iBlock+size-1<mem5.nBlock );
assert( iBlock+size-1<(u32)mem5.nBlock );
mem5.aCtrl[iBlock] |= CTRL_FREE;
mem5.aCtrl[iBlock+size-1] |= CTRL_FREE;
assert( mem5.currentCount>0 );
assert( mem5.currentOut>=0 );
assert( mem5.currentOut>=(size*mem5.nAtom) );
mem5.currentCount--;
mem5.currentOut -= size*mem5.nAtom;
assert( mem5.currentOut>0 || mem5.currentCount==0 );
@ -385,7 +385,7 @@ static int memsys5Init(void *NotUsed){
nMinLog = memsys5Log(sqlite3GlobalConfig.mnReq);
mem5.nAtom = (1<<nMinLog);
while( sizeof(Mem5Link)>mem5.nAtom ){
while( (int)sizeof(Mem5Link)>mem5.nAtom ){
mem5.nAtom = mem5.nAtom << 1;
}

View File

@ -11,7 +11,7 @@
*************************************************************************
** This file contains the C functions that implement mutexes for pthreads
**
** $Id: mutex_unix.c,v 1.14 2008/11/17 08:05:32 chw Exp $
** $Id: mutex_unix.c,v 1.15 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -157,7 +157,7 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){
}
default: {
assert( iType-2 >= 0 );
assert( iType-2 < sizeof(staticMutexes)/sizeof(staticMutexes[0]) );
assert( iType-2 < ArraySize(staticMutexes) );
p = &staticMutexes[iType-2];
p->id = iType;
break;

View File

@ -12,7 +12,7 @@
**
** This file contains code that is specific to Unix systems.
**
** $Id: os_unix.c,v 1.210 2008/11/17 08:05:32 chw Exp $
** $Id: os_unix.c,v 1.211 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#if SQLITE_OS_UNIX /* This file is used on unix only */
@ -2956,7 +2956,7 @@ static int getTempname(int nBuf, char *zBuf){
SimulateIOError( return SQLITE_IOERR );
azDirs[0] = sqlite3_temp_directory;
for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
for(i=0; i<ArraySize(azDirs); i++){
if( azDirs[i]==0 ) continue;
if( stat(azDirs[i], &buf) ) continue;
if( !S_ISDIR(buf.st_mode) ) continue;
@ -2968,7 +2968,7 @@ static int getTempname(int nBuf, char *zBuf){
/* Check that the output buffer is large enough for the temporary file
** name. If it is not, return SQLITE_ERROR.
*/
if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){
if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 17) >= (size_t)nBuf ){
return SQLITE_ERROR;
}
@ -3311,7 +3311,7 @@ static void unixDlClose(sqlite3_vfs *pVfs, void *pHandle){
*/
static int unixRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
assert(nBuf>=(sizeof(time_t)+sizeof(int)));
assert((size_t)nBuf>=(sizeof(time_t)+sizeof(int)));
/* We have to initialize zBuf to prevent valgrind from reporting
** errors. The reports issued by valgrind are incorrect - we would
@ -3336,7 +3336,7 @@ static int unixRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
memcpy(zBuf, &t, sizeof(t));
pid = getpid();
memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid));
assert( sizeof(t)+sizeof(pid)<=nBuf );
assert( sizeof(t)+sizeof(pid)<=(size_t)nBuf );
nBuf = sizeof(t) + sizeof(pid);
}else{
nBuf = read(fd, zBuf, nBuf);

View File

@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
** $Id: pragma.c,v 1.193 2008/11/10 19:24:38 shane Exp $
** $Id: pragma.c,v 1.194 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -41,7 +41,7 @@ static int getSafetyLevel(const char *z){
return atoi(z);
}
n = strlen(z);
for(i=0; i<sizeof(iLength); i++){
for(i=0; i<ArraySize(iLength); i++){
if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){
return iValue[i];
}
@ -191,7 +191,7 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
};
int i;
const struct sPragmaType *p;
for(i=0, p=aPragma; i<sizeof(aPragma)/sizeof(aPragma[0]); i++, p++){
for(i=0, p=aPragma; i<ArraySize(aPragma); i++, p++){
if( sqlite3StrICmp(zLeft, p->zName)==0 ){
sqlite3 *db = pParse->db;
Vdbe *v;

View File

@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.98 2008/10/31 10:53:23 danielk1977 Exp $
** $Id: prepare.c,v 1.99 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -244,7 +244,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
*/
if( rc==SQLITE_OK ){
int i;
for(i=0; i<sizeof(meta)/sizeof(meta[0]); i++){
for(i=0; i<ArraySize(meta); i++){
rc = sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);
if( rc ){
sqlite3SetString(pzErrMsg, db, "%s", sqlite3ErrStr(rc));

View File

@ -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.94 2008/08/22 14:08:36 drh Exp $
** $Id: printf.c,v 1.95 2008/11/17 19:18:55 danielk1977 Exp $
**
**************************************************************************
**
@ -137,7 +137,6 @@ static const et_info fmtinfo[] = {
{ 'S', 0, 2, etSRCLIST, 0, 0 },
{ 'r', 10, 3, etORDINAL, 0, 0 },
};
#define etNINFO (sizeof(fmtinfo)/sizeof(fmtinfo[0]))
/*
** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point
@ -174,7 +173,7 @@ static int et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
*/
static void appendSpace(StrAccum *pAccum, int N){
static const char zSpaces[] = " ";
while( N>=sizeof(zSpaces)-1 ){
while( N>=(int)sizeof(zSpaces)-1 ){
sqlite3StrAccumAppend(pAccum, zSpaces, sizeof(zSpaces)-1);
N -= sizeof(zSpaces)-1;
}
@ -337,7 +336,7 @@ void sqlite3VXPrintf(
}
/* Fetch the info entry for the field */
infop = 0;
for(idx=0; idx<etNINFO; idx++){
for(idx=0; idx<ArraySize(fmtinfo); idx++){
if( c==fmtinfo[idx].fmttype ){
infop = &fmtinfo[idx];
if( useExtended || (infop->flags & FLAG_INTERN)==0 ){

View File

@ -14,7 +14,7 @@
** resolve all identifiers by associating them with a particular
** table and column.
**
** $Id: resolve.c,v 1.10 2008/10/19 21:03:27 drh Exp $
** $Id: resolve.c,v 1.11 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
@ -349,9 +349,9 @@ static int lookupName(
*/
if( pExpr->iColumn>=0 && pMatch!=0 ){
int n = pExpr->iColumn;
testcase( n==sizeof(Bitmask)*8-1 );
if( n>=sizeof(Bitmask)*8 ){
n = sizeof(Bitmask)*8-1;
testcase( n==BMS-1 );
if( n>=BMS ){
n = BMS-1;
}
assert( pMatch->iCursor==pExpr->iTable );
pMatch->colUsed |= ((Bitmask)1)<<n;

View File

@ -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.484 2008/11/12 12:27:31 drh Exp $
** $Id: select.c,v 1.485 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -144,14 +144,14 @@ int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
apAll[2] = pC;
for(i=0; i<3 && apAll[i]; i++){
p = apAll[i];
for(j=0; j<sizeof(keywords)/sizeof(keywords[0]); j++){
for(j=0; j<ArraySize(keywords); j++){
if( p->n==keywords[j].nChar
&& sqlite3StrNICmp((char*)p->z, keywords[j].zKeyword, p->n)==0 ){
jointype |= keywords[j].code;
break;
}
}
if( j>=sizeof(keywords)/sizeof(keywords[0]) ){
if( j>=ArraySize(keywords) ){
jointype |= JT_ERROR;
break;
}

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.794 2008/11/17 16:42:01 danielk1977 Exp $
** @(#) $Id: sqliteInt.h,v 1.795 2008/11/17 19:18:55 danielk1977 Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@ -1423,6 +1423,11 @@ struct IdList {
*/
typedef u64 Bitmask;
/*
** The number of bits in a Bitmask. "BMS" means "BitMask Size".
*/
#define BMS ((int)(sizeof(Bitmask)*8))
/*
** The following structure describes the FROM clause of a SELECT statement.
** Each table or subquery in the FROM clause is a separate element of

View File

@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.241 2008/07/28 19:34:54 drh Exp $
** $Id: util.c,v 1.242 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@ -57,7 +57,7 @@ int sqlite3IsNaN(double x){
int sqlite3Strlen(sqlite3 *db, const char *z){
const char *z2 = z;
int len;
size_t x;
int x;
while( *z2 ){ z2++; }
x = z2 - z;
len = 0x7fffffff & x;
@ -934,7 +934,7 @@ int sqlite3SafetyOff(sqlite3 *db){
** used as an argument to sqlite3_errmsg() or sqlite3_close().
*/
int sqlite3SafetyCheckOk(sqlite3 *db){
int magic;
u32 magic;
if( db==0 ) return 0;
magic = db->magic;
if( magic!=SQLITE_MAGIC_OPEN &&
@ -942,7 +942,7 @@ int sqlite3SafetyCheckOk(sqlite3 *db){
return 1;
}
int sqlite3SafetyCheckSickOrOk(sqlite3 *db){
int magic;
u32 magic;
if( db==0 ) return 0;
magic = db->magic;
if( magic!=SQLITE_MAGIC_SICK &&

View File

@ -14,7 +14,7 @@
** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro.
**
** $Id: vacuum.c,v 1.83 2008/08/26 21:07:27 drh Exp $
** $Id: vacuum.c,v 1.84 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
@ -251,7 +251,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
assert( 1==sqlite3BtreeIsInTrans(pMain) );
/* Copy Btree meta values */
for(i=0; i<sizeof(aCopy)/sizeof(aCopy[0]); i+=2){
for(i=0; i<ArraySize(aCopy); i+=2){
rc = sqlite3BtreeGetMeta(pMain, aCopy[i], &meta);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], meta+aCopy[i+1]);

View File

@ -14,7 +14,7 @@
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
** $Id: vdbeaux.c,v 1.419 2008/11/13 18:00:15 danielk1977 Exp $
** $Id: vdbeaux.c,v 1.420 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -100,21 +100,23 @@ void sqlite3VdbeTrace(Vdbe *p, FILE *trace){
#endif
/*
** Resize the Vdbe.aOp array so that it contains at least N
** elements.
** Resize the Vdbe.aOp array so that it is at least one op larger than
** it was.
**
** If an out-of-memory error occurs while resizing the array,
** Vdbe.aOp and Vdbe.nOpAlloc remain unchanged (this is so that
** any opcodes already allocated can be correctly deallocated
** along with the rest of the Vdbe).
** If an out-of-memory error occurs while resizing the array, return
** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain
** unchanged (this is so that any opcodes already allocated can be
** correctly deallocated along with the rest of the Vdbe).
*/
static void resizeOpArray(Vdbe *p, int N){
static int growOpArray(Vdbe *p){
VdbeOp *pNew;
pNew = sqlite3DbRealloc(p->db, p->aOp, N*sizeof(Op));
int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));
pNew = sqlite3DbRealloc(p->db, p->aOp, nNew*sizeof(Op));
if( pNew ){
p->nOpAlloc = N;
p->nOpAlloc = nNew;
p->aOp = pNew;
}
return (pNew ? SQLITE_OK : SQLITE_NOMEM);
}
/*
@ -140,8 +142,7 @@ int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){
i = p->nOp;
assert( p->magic==VDBE_MAGIC_INIT );
if( p->nOpAlloc<=i ){
resizeOpArray(p, p->nOpAlloc ? p->nOpAlloc*2 : 1024/sizeof(Op));
if( p->db->mallocFailed ){
if( growOpArray(p) ){
return 0;
}
}
@ -342,11 +343,7 @@ int sqlite3VdbeCurrentAddr(Vdbe *p){
int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp){
int addr;
assert( p->magic==VDBE_MAGIC_INIT );
if( p->nOp + nOp > p->nOpAlloc ){
resizeOpArray(p, p->nOpAlloc ? p->nOpAlloc*2 : 1024/sizeof(Op));
assert( p->nOp+nOp<=p->nOpAlloc || p->db->mallocFailed );
}
if( p->db->mallocFailed ){
if( p->nOp + nOp > p->nOpAlloc && growOpArray(p) ){
return 0;
}
addr = p->nOp;
@ -731,7 +728,7 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
void sqlite3VdbeUsesBtree(Vdbe *p, int i){
int mask;
assert( i>=0 && i<p->db->nDb );
assert( i<sizeof(p->btreeMask)*8 );
assert( i<(int)sizeof(p->btreeMask)*8 );
mask = 1<<i;
if( (p->btreeMask & mask)==0 ){
p->btreeMask |= mask;
@ -1017,11 +1014,7 @@ void sqlite3VdbeMakeReady(
*/
assert( p->nOp>0 );
/* Set the magic to VDBE_MAGIC_RUN sooner rather than later. This
* is because the call to resizeOpArray() below may shrink the
* p->aOp[] array to save memory if called when in VDBE_MAGIC_RUN
* state.
*/
/* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */
p->magic = VDBE_MAGIC_RUN;
/* For each cursor required, also allocate a memory cell. Memory
@ -1041,7 +1034,6 @@ void sqlite3VdbeMakeReady(
if( p->aMem==0 ){
int nArg; /* Maximum number of args passed to a user function. */
resolveP2Values(p, &nArg);
/*resizeOpArray(p, p->nOp);*/
assert( nVar>=0 );
if( isExplain && nMem<10 ){
nMem = 10;
@ -2215,8 +2207,8 @@ UnpackedRecord *sqlite3VdbeRecordUnpack(
){
const unsigned char *aKey = (const unsigned char *)pKey;
UnpackedRecord *p;
int nByte;
int idx, d;
int nByte, d;
u32 idx;
u16 u; /* Unsigned loop counter */
u32 szHdr;
Mem *pMem;
@ -2240,7 +2232,7 @@ UnpackedRecord *sqlite3VdbeRecordUnpack(
while( idx<szHdr && u<p->nField ){
u32 serial_type;
idx += getVarint32( aKey+idx, serial_type);
idx += getVarint32(&aKey[idx], serial_type);
if( d>=nKey && sqlite3VdbeSerialTypeLen(serial_type)>0 ) break;
pMem->enc = pKeyInfo->enc;
pMem->db = pKeyInfo->db;
@ -2305,7 +2297,7 @@ int sqlite3VdbeRecordCompare(
int nKey1, const void *pKey1, /* Left key */
UnpackedRecord *pPKey2 /* Right key */
){
u32 d1; /* Offset into aKey[] of next data element */
int d1; /* Offset into aKey[] of next data element */
u32 idx1; /* Offset into aKey[] of next header element */
u32 szHdr1; /* Number of bytes in header */
int i = 0;

View File

@ -12,7 +12,7 @@
** This file implements a FIFO queue of rowids used for processing
** UPDATE and DELETE statements.
**
** $Id: vdbefifo.c,v 1.8 2008/07/28 19:34:54 drh Exp $
** $Id: vdbefifo.c,v 1.9 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
@ -24,9 +24,9 @@
*/
#define FIFOSIZE_FIRST (((128-sizeof(FifoPage))/8)+1)
#ifdef SQLITE_MALLOC_SOFT_LIMIT
# define FIFOSIZE_MAX (((SQLITE_MALLOC_SOFT_LIMIT-sizeof(FifoPage))/8)+1)
# define FIFOSIZE_MAX (int)(((SQLITE_MALLOC_SOFT_LIMIT-sizeof(FifoPage))/8)+1)
#else
# define FIFOSIZE_MAX (((262144-sizeof(FifoPage))/8)+1)
# define FIFOSIZE_MAX (int)(((262144-sizeof(FifoPage))/8)+1)
#endif
/*

View File

@ -16,15 +16,10 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.329 2008/11/17 16:42:01 danielk1977 Exp $
** $Id: where.c,v 1.330 2008/11/17 19:18:55 danielk1977 Exp $
*/
#include "sqliteInt.h"
/*
** The number of bits in a Bitmask. "BMS" means "BitMask Size".
*/
#define BMS ((int)(sizeof(Bitmask)*8))
/*
** Trace output macros
*/