1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix harmless compiler warnings in lsmtest.

FossilOrigin-Name: bd8a1fb9b33418717c786a7275f636cd4d5facd66de9a416f948b61c6490c743
This commit is contained in:
mistachkin
2017-07-10 21:32:11 +00:00
parent 4a9e14077e
commit b2950c48e1
10 changed files with 54 additions and 49 deletions

View File

@ -200,7 +200,7 @@ static void testOomScan(
int rc;
int iScan = 0;
lsm_cursor *pCsr;
int (*xAdvance)(lsm_cursor *);
int (*xAdvance)(lsm_cursor *) = 0;
rc = lsm_csr_open(pDb, &pCsr);
@ -353,7 +353,7 @@ static int lsmWriteStr(lsm_db *pDb, const char *zKey, const char *zVal){
return lsm_insert(pDb, (void *)zKey, nKey, (void *)zVal, nVal);
}
static void setup_delete_db(){
static void setup_delete_db(void){
testDeleteLsmdb(LSMTEST6_TESTDB);
}
@ -369,7 +369,7 @@ static void setup_delete_db(){
** "seven" -> "fourtynine"
** "eight" -> "sixtyfour"
*/
static void setup_populate_db(){
static void setup_populate_db(void){
const char *azStr[] = {
"one", "one",
"two", "four",
@ -411,7 +411,7 @@ static Datasource *getDatasource(void){
** * Contains 5000 key-value pairs starting at 0 from the
** datasource returned getDatasource().
*/
static void setup_populate_db2(){
static void setup_populate_db2(void){
Datasource *pData;
int ii;
int rc;

View File

@ -92,7 +92,8 @@ void testReadFile(const char *zFile, int iOff, void *pOut, int nByte, int *pRc){
if( 0!=fseek(fd, iOff, SEEK_SET) ){
*pRc = 1;
}else{
if( nByte!=fread(pOut, 1, nByte, fd) ){
assert( nByte>=0 );
if( (size_t)nByte!=fread(pOut, 1, nByte, fd) ){
*pRc = 1;
}
}
@ -117,7 +118,8 @@ void testWriteFile(
if( 0!=fseek(fd, iOff, SEEK_SET) ){
*pRc = 1;
}else{
if( nByte!=fwrite(pOut, 1, nByte, fd) ){
assert( nByte>=0 );
if( (size_t)nByte!=fwrite(pOut, 1, nByte, fd) ){
*pRc = 1;
}
}

View File

@ -147,7 +147,7 @@ static int doOneCmd(
int nPg;
int iPg;
nByte = getNextSize(z, &z, &rc);
nByte = (int)getNextSize(z, &z, &rc);
if( rc || *z!='@' ) goto bad_command;
z++;
iOff = getNextSize(z, &z, &rc);
@ -155,7 +155,7 @@ static int doOneCmd(
if( pzOut ) *pzOut = z;
nPg = (nByte+pgsz-1) / pgsz;
lseek(pCtx->fd, iOff, SEEK_SET);
lseek(pCtx->fd, (off_t)iOff, SEEK_SET);
for(iPg=0; iPg<nPg; iPg++){
write(pCtx->fd, aData, pgsz);
}
@ -211,7 +211,7 @@ int do_io(int nArg, char **azArg){
zFile = azArg[0];
zPgsz = azArg[1];
pgsz = getNextSize(zPgsz, 0, &rc);
pgsz = (int)getNextSize(zPgsz, 0, &rc);
if( pgsz<=0 ){
testPrintError("Ridiculous page size: %d", pgsz);
return -1;

View File

@ -902,7 +902,7 @@ int do_speed_tests(int nArg, char **azArg){
testTimeInit();
for(i=0; i<nRow; i+=nStep){
int iStep;
int nWrite1, nWrite2;
int nWrite1 = 0, nWrite2 = 0;
testCaseProgress(i, nRow, testCaseNDot(), &iDot);
if( pLsm ) lsm_info(pLsm, LSM_INFO_NWRITE, &nWrite1);
for(iStep=0; iStep<nStep; iStep++){

View File

@ -45,9 +45,9 @@ struct TmGlobal {
void (*xDelMutex)(TmGlobal*); /* Call this to delete mutex */
void *pMutex; /* Mutex handle */
void *xSaveMalloc;
void *xSaveRealloc;
void *xSaveFree;
void *(*xSaveMalloc)(void *, size_t);
void *(*xSaveRealloc)(void *, void *, size_t);
void (*xSaveFree)(void *, void *);
/* OOM injection scheduling. If nCountdown is greater than zero when a
** malloc attempt is made, it is decremented. If this means nCountdown
@ -183,7 +183,7 @@ static void tmFree(TmGlobal *pTm, void *p){
u8 *pUser = (u8 *)p;
tmEnterMutex(pTm);
pHdr = (TmBlockHdr *)&pUser[BLOCK_HDR_SIZE * -1];
pHdr = (TmBlockHdr *)(pUser - BLOCK_HDR_SIZE);
assert( pHdr->iForeGuard==FOREGUARD );
assert( 0==memcmp(&pUser[pHdr->nByte], &rearguard, 4) );
@ -218,7 +218,7 @@ static void *tmRealloc(TmGlobal *pTm, void *p, int nByte){
if( pNew && p ){
TmBlockHdr *pHdr;
u8 *pUser = (u8 *)p;
pHdr = (TmBlockHdr *)&pUser[BLOCK_HDR_SIZE * -1];
pHdr = (TmBlockHdr *)(pUser - BLOCK_HDR_SIZE);
memcpy(pNew, p, MIN(nByte, pHdr->nByte));
tmFree(pTm, p);
}
@ -355,9 +355,9 @@ void testMallocInstall(lsm_env *pEnv){
pGlobal->xDelMutex = tmLsmMutexDel;
pGlobal->pMutex = (void *)pMutex;
pGlobal->xSaveMalloc = (void *)pEnv->xMalloc;
pGlobal->xSaveRealloc = (void *)pEnv->xRealloc;
pGlobal->xSaveFree = (void *)pEnv->xFree;
pGlobal->xSaveMalloc = pEnv->xMalloc;
pGlobal->xSaveRealloc = pEnv->xRealloc;
pGlobal->xSaveFree = pEnv->xFree;
/* Set up pEnv to the use the new TmGlobal */
pEnv->pMemCtx = (void *)pGlobal;

View File

@ -767,7 +767,8 @@ int tdb_open(const char *zLib, const char *zDb, int bClear, TestDb **ppDb){
if( *zSpec=='\0' ) zSpec = 0;
for(i=0; i<ArraySize(aLib); i++){
if( strlen(aLib[i].zName)==nLib && 0==memcmp(zLib, aLib[i].zName, nLib) ){
if( (int)strlen(aLib[i].zName)==nLib
&& 0==memcmp(zLib, aLib[i].zName, nLib) ){
rc = aLib[i].xOpen(zSpec, (zDb ? zDb : aLib[i].zDefaultDb), bClear, ppDb);
if( rc==0 ){
(*ppDb)->zLibrary = aLib[i].zName;

View File

@ -199,33 +199,33 @@ static int testEnvWrite(lsm_file *pFile, lsm_i64 iOff, void *pData, int nData){
if( pDb->bCrashed ) return LSM_IOERR;
if( pDb->bPrepareCrash ){
FileData *pData = &pDb->aFile[p->bLog];
FileData *pData2 = &pDb->aFile[p->bLog];
int iFirst;
int iLast;
int iSector;
iFirst = (iOff / pDb->szSector);
iLast = ((iOff + nData - 1) / pDb->szSector);
iFirst = (int)(iOff / pDb->szSector);
iLast = (int)((iOff + nData - 1) / pDb->szSector);
if( pData->nSector<(iLast+1) ){
if( pData2->nSector<(iLast+1) ){
int nNew = ( ((iLast + 1) + 63) / 64 ) * 64;
assert( nNew>iLast );
pData->aSector = (FileSector *)testRealloc(
pData->aSector, nNew*sizeof(FileSector)
pData2->aSector = (FileSector *)testRealloc(
pData2->aSector, nNew*sizeof(FileSector)
);
memset(&pData->aSector[pData->nSector],
0, (nNew - pData->nSector) * sizeof(FileSector)
memset(&pData2->aSector[pData2->nSector],
0, (nNew - pData2->nSector) * sizeof(FileSector)
);
pData->nSector = nNew;
pData2->nSector = nNew;
}
for(iSector=iFirst; iSector<=iLast; iSector++){
if( pData->aSector[iSector].aOld==0 ){
if( pData2->aSector[iSector].aOld==0 ){
u8 *aOld = (u8 *)testMalloc(pDb->szSector);
pRealEnv->xRead(
p->pReal, (lsm_i64)iSector*pDb->szSector, aOld, pDb->szSector
);
pData->aSector[iSector].aOld = aOld;
pData2->aSector[iSector].aOld = aOld;
}
}
}
@ -547,9 +547,9 @@ static int waitOnWorker(LsmDb *pDb){
rc = lsm_config(pDb->db, LSM_CONFIG_AUTOFLUSH, &nLimit);
do {
int nOld, nNew, rc;
rc = lsm_info(pDb->db, LSM_INFO_TREE_SIZE, &nOld, &nNew);
if( rc!=LSM_OK ) return rc;
int nOld, nNew, rc2;
rc2 = lsm_info(pDb->db, LSM_INFO_TREE_SIZE, &nOld, &nNew);
if( rc2!=LSM_OK ) return rc2;
if( nOld==0 || nNew<(nLimit/2) ) break;
#ifdef LSM_MUTEX_PTHREADS
mt_signal_worker(pDb, 0);
@ -888,7 +888,9 @@ int test_lsm_config_str(
int tdb_lsm_config_str(TestDb *pDb, const char *zStr){
int rc = 0;
if( tdb_lsm(pDb) ){
#ifdef LSM_MUTEX_PTHREADS
int i;
#endif
LsmDb *pLsm = (LsmDb *)pDb;
rc = test_lsm_config_str(pLsm, pLsm->db, 0, zStr, 0);