/ Check-in [bd8a1fb9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix harmless compiler warnings in lsmtest.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bd8a1fb9b33418717c786a7275f636cd4d5facd66de9a416f948b61c6490c743
User & Date: mistachkin 2017-07-10 21:32:11
Context
2017-07-11
00:09
Incomplete implementation of the COMPLETION table-valued function. So far it only works for SQL keywords. check-in: caefbc72 user: drh tags: trunk
2017-07-10
21:32
Fix harmless compiler warnings in lsmtest. check-in: bd8a1fb9 user: mistachkin tags: trunk
20:39
Fix errors in comments in the STMT virtual table. No code changes. check-in: 9a8f045d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/lsm1/Makefile.msc.

    37     37                $(LSMDIR)\lsm-test\lsmtest_func.c $(LSMDIR)\lsm-test\lsmtest_io.c  \
    38     38                $(LSMDIR)\lsm-test\lsmtest_main.c $(LSMDIR)\lsm-test\lsmtest_mem.c \
    39     39                $(LSMDIR)\lsm-test\lsmtest_tdb.c $(LSMDIR)\lsm-test\lsmtest_tdb3.c \
    40     40                $(LSMDIR)\lsm-test\lsmtest_util.c $(LSMDIR)\lsm-test\lsmtest_win32.c
    41     41   
    42     42   # all: lsm.dll
    43     43   
    44         -LSMOPTS = -DLSM_MUTEX_WIN32=1 -I$(LSMDIR)
           44  +LSMOPTS = $(NO_WARN) -DLSM_MUTEX_WIN32=1 -I$(LSMDIR)
    45     45   
    46     46   !IF $(DEBUG)>2
    47     47   LSMOPTS = $(LSMOPTS) -DLSM_DEBUG=1
    48     48   !ENDIF
    49     49   
    50     50   !IF $(MEMDEBUG)!=0
    51     51   LSMOPTS = $(LSMOPTS) -DLSM_DEBUG_MEM=1

Changes to ext/lsm1/lsm-test/lsmtest6.c.

   196    196     int nScan,
   197    197     int *pRc
   198    198   ){
   199    199     if( *pRc==0 ){
   200    200       int rc;
   201    201       int iScan = 0;
   202    202       lsm_cursor *pCsr;
   203         -    int (*xAdvance)(lsm_cursor *);
          203  +    int (*xAdvance)(lsm_cursor *) = 0;
   204    204       
   205    205   
   206    206       rc = lsm_csr_open(pDb, &pCsr);
   207    207       testOomAssertRc(pOom, rc);
   208    208   
   209    209       if( rc==LSM_OK ){
   210    210         if( bReverse ){
................................................................................
   349    349   
   350    350   static int lsmWriteStr(lsm_db *pDb, const char *zKey, const char *zVal){
   351    351     int nKey = strlen(zKey);
   352    352     int nVal = strlen(zVal);
   353    353     return lsm_insert(pDb, (void *)zKey, nKey, (void *)zVal, nVal);
   354    354   }
   355    355   
   356         -static void setup_delete_db(){
          356  +static void setup_delete_db(void){
   357    357     testDeleteLsmdb(LSMTEST6_TESTDB);
   358    358   }
   359    359   
   360    360   /*
   361    361   ** Create a small database. With the following content:
   362    362   **
   363    363   **    "one"   -> "one"
................................................................................
   365    365   **    "three" -> "nine"
   366    366   **    "four"  -> "sixteen"
   367    367   **    "five"  -> "twentyfive"
   368    368   **    "six"   -> "thirtysix"
   369    369   **    "seven" -> "fourtynine"
   370    370   **    "eight" -> "sixtyfour"
   371    371   */
   372         -static void setup_populate_db(){
          372  +static void setup_populate_db(void){
   373    373     const char *azStr[] = {
   374    374       "one",   "one",
   375    375       "two",   "four",
   376    376       "three", "nine",
   377    377       "four",  "sixteen",
   378    378       "five",  "twentyfive",
   379    379       "six",   "thirtysix",
................................................................................
   407    407   ** Set up a database file with the following properties:
   408    408   **
   409    409   **   * Page size is 1024 bytes.
   410    410   **   * Block size is 64 KB.
   411    411   **   * Contains 5000 key-value pairs starting at 0 from the
   412    412   **     datasource returned getDatasource().
   413    413   */
   414         -static void setup_populate_db2(){
          414  +static void setup_populate_db2(void){
   415    415     Datasource *pData;
   416    416     int ii;
   417    417     int rc;
   418    418     int nBlocksize = 64*1024;
   419    419     int nPagesize = 1024;
   420    420     int nWritebuffer = 4*1024;
   421    421     lsm_db *pDb;

Changes to ext/lsm1/lsm-test/lsmtest8.c.

    88     88       fd = fopen(zFile, "r");
    89     89       if( fd==0 ){
    90     90         *pRc = 1;
    91     91       }else{
    92     92         if( 0!=fseek(fd, iOff, SEEK_SET) ){
    93     93           *pRc = 1;
    94     94         }else{
    95         -        if( nByte!=fread(pOut, 1, nByte, fd) ){
           95  +        assert( nByte>=0 );
           96  +        if( (size_t)nByte!=fread(pOut, 1, nByte, fd) ){
    96     97             *pRc = 1;
    97     98           }
    98     99         }
    99    100         fclose(fd);
   100    101       }
   101    102     }
   102    103   }
................................................................................
   113    114       fd = fopen(zFile, "r+");
   114    115       if( fd==0 ){
   115    116         *pRc = 1;
   116    117       }else{
   117    118         if( 0!=fseek(fd, iOff, SEEK_SET) ){
   118    119           *pRc = 1;
   119    120         }else{
   120         -        if( nByte!=fwrite(pOut, 1, nByte, fd) ){
          121  +        assert( nByte>=0 );
          122  +        if( (size_t)nByte!=fwrite(pOut, 1, nByte, fd) ){
   121    123             *pRc = 1;
   122    124           }
   123    125         }
   124    126         fclose(fd);
   125    127       }
   126    128     }
   127    129   }

Changes to ext/lsm1/lsm-test/lsmtest_io.c.

   143    143     if( safe_isdigit(c) ){
   144    144       i64 iOff = 0;
   145    145       int nByte = 0;
   146    146       int rc = 0;
   147    147       int nPg;
   148    148       int iPg;
   149    149   
   150         -    nByte = getNextSize(z, &z, &rc);
          150  +    nByte = (int)getNextSize(z, &z, &rc);
   151    151       if( rc || *z!='@' ) goto bad_command;
   152    152       z++;
   153    153       iOff = getNextSize(z, &z, &rc);
   154    154       if( rc || (safe_isspace(*z)==0 && *z!='\0') ) goto bad_command;
   155    155       if( pzOut ) *pzOut = z;
   156    156   
   157    157       nPg = (nByte+pgsz-1) / pgsz;
   158         -    lseek(pCtx->fd, iOff, SEEK_SET);
          158  +    lseek(pCtx->fd, (off_t)iOff, SEEK_SET);
   159    159       for(iPg=0; iPg<nPg; iPg++){
   160    160         write(pCtx->fd, aData, pgsz);
   161    161       }
   162    162       pCtx->nWrite += nByte/1024;
   163    163   
   164    164       return 0;
   165    165     }
................................................................................
   207    207     if( nArg<2 ){
   208    208       testPrintUsage("FILE PGSZ ?CMD-1 ...?");
   209    209       return -1;
   210    210     }
   211    211     zFile = azArg[0];
   212    212     zPgsz = azArg[1];
   213    213   
   214         -  pgsz = getNextSize(zPgsz, 0, &rc);
          214  +  pgsz = (int)getNextSize(zPgsz, 0, &rc);
   215    215     if( pgsz<=0 ){
   216    216       testPrintError("Ridiculous page size: %d", pgsz);
   217    217       return -1;
   218    218     }
   219    219     aData = malloc(pgsz);
   220    220     memset(aData, 0x77, pgsz);
   221    221   

Changes to ext/lsm1/lsm-test/lsmtest_main.c.

   898    898         pLog = fopen("/tmp/speed.log", "w");
   899    899         tdb_lsm_write_hook(pDb, do_speed_write_hook2, (void *)pLog);
   900    900   #endif
   901    901     
   902    902         testTimeInit();
   903    903         for(i=0; i<nRow; i+=nStep){
   904    904           int iStep;
   905         -        int nWrite1, nWrite2;
          905  +        int nWrite1 = 0, nWrite2 = 0;
   906    906           testCaseProgress(i, nRow, testCaseNDot(), &iDot);
   907    907           if( pLsm ) lsm_info(pLsm, LSM_INFO_NWRITE, &nWrite1);
   908    908           for(iStep=0; iStep<nStep; iStep++){
   909    909             u32 aKey[4];                  /* 16-byte key */
   910    910             u32 aVal[25];                 /* 100 byte value */
   911    911             testPrngArray(i+iStep, aKey, ArraySize(aKey));
   912    912             testPrngArray(i+iStep, aVal, ArraySize(aVal));

Changes to ext/lsm1/lsm-test/lsmtest_mem.c.

    41     41   
    42     42     /* Mutex to protect pFirst and aHash */
    43     43     void (*xEnterMutex)(TmGlobal*); /* Call this to enter the mutex */
    44     44     void (*xLeaveMutex)(TmGlobal*); /* Call this to leave mutex */
    45     45     void (*xDelMutex)(TmGlobal*);   /* Call this to delete mutex */
    46     46     void *pMutex;                   /* Mutex handle */
    47     47   
    48         -  void *xSaveMalloc;
    49         -  void *xSaveRealloc;
    50         -  void *xSaveFree;
           48  +  void *(*xSaveMalloc)(void *, size_t);
           49  +  void *(*xSaveRealloc)(void *, void *, size_t);
           50  +  void (*xSaveFree)(void *, void *);
    51     51   
    52     52     /* OOM injection scheduling. If nCountdown is greater than zero when a 
    53     53     ** malloc attempt is made, it is decremented. If this means nCountdown 
    54     54     ** transitions from 1 to 0, then the allocation fails. If bPersist is true 
    55     55     ** when this happens, nCountdown is then incremented back to 1 (so that the 
    56     56     ** next attempt fails too).  
    57     57     */
................................................................................
   179    179   
   180    180   static void tmFree(TmGlobal *pTm, void *p){
   181    181     if( p ){
   182    182       TmBlockHdr *pHdr;
   183    183       u8 *pUser = (u8 *)p;
   184    184   
   185    185       tmEnterMutex(pTm);
   186         -    pHdr = (TmBlockHdr *)&pUser[BLOCK_HDR_SIZE * -1];
          186  +    pHdr = (TmBlockHdr *)(pUser - BLOCK_HDR_SIZE);
   187    187       assert( pHdr->iForeGuard==FOREGUARD );
   188    188       assert( 0==memcmp(&pUser[pHdr->nByte], &rearguard, 4) );
   189    189   
   190    190       if( pHdr->pPrev ){
   191    191         assert( pHdr->pPrev->pNext==pHdr );
   192    192         pHdr->pPrev->pNext = pHdr->pNext;
   193    193       }else{
................................................................................
   214    214   static void *tmRealloc(TmGlobal *pTm, void *p, int nByte){
   215    215     void *pNew;
   216    216   
   217    217     pNew = tmMalloc(pTm, nByte);
   218    218     if( pNew && p ){
   219    219       TmBlockHdr *pHdr;
   220    220       u8 *pUser = (u8 *)p;
   221         -    pHdr = (TmBlockHdr *)&pUser[BLOCK_HDR_SIZE * -1];
          221  +    pHdr = (TmBlockHdr *)(pUser - BLOCK_HDR_SIZE);
   222    222       memcpy(pNew, p, MIN(nByte, pHdr->nByte));
   223    223       tmFree(pTm, p);
   224    224     }
   225    225     return pNew;
   226    226   }
   227    227   
   228    228   static void tmMallocOom(
................................................................................
   351    351     pMutex->pEnv = pEnv;
   352    352     pEnv->xMutexStatic(pEnv, LSM_MUTEX_HEAP, &pMutex->pMutex);
   353    353     pGlobal->xEnterMutex = tmLsmMutexEnter;
   354    354     pGlobal->xLeaveMutex = tmLsmMutexLeave;
   355    355     pGlobal->xDelMutex = tmLsmMutexDel;
   356    356     pGlobal->pMutex = (void *)pMutex;
   357    357   
   358         -  pGlobal->xSaveMalloc = (void *)pEnv->xMalloc;
   359         -  pGlobal->xSaveRealloc = (void *)pEnv->xRealloc;
   360         -  pGlobal->xSaveFree = (void *)pEnv->xFree;
          358  +  pGlobal->xSaveMalloc = pEnv->xMalloc;
          359  +  pGlobal->xSaveRealloc = pEnv->xRealloc;
          360  +  pGlobal->xSaveFree = pEnv->xFree;
   361    361   
   362    362     /* Set up pEnv to the use the new TmGlobal */
   363    363     pEnv->pMemCtx = (void *)pGlobal;
   364    364     pEnv->xMalloc = tmLsmEnvMalloc;
   365    365     pEnv->xRealloc = tmLsmEnvRealloc;
   366    366     pEnv->xFree = tmLsmEnvFree;
   367    367   }

Changes to ext/lsm1/lsm-test/lsmtest_tdb.c.

   763    763       nLib++;
   764    764     }
   765    765     zSpec = &zLib[nLib];
   766    766     while( *zSpec==' ' ) zSpec++;
   767    767     if( *zSpec=='\0' ) zSpec = 0;
   768    768   
   769    769     for(i=0; i<ArraySize(aLib); i++){
   770         -    if( strlen(aLib[i].zName)==nLib && 0==memcmp(zLib, aLib[i].zName, nLib) ){
          770  +    if( (int)strlen(aLib[i].zName)==nLib
          771  +        && 0==memcmp(zLib, aLib[i].zName, nLib) ){
   771    772         rc = aLib[i].xOpen(zSpec, (zDb ? zDb : aLib[i].zDefaultDb), bClear, ppDb);
   772    773         if( rc==0 ){
   773    774           (*ppDb)->zLibrary = aLib[i].zName;
   774    775         }
   775    776         break;
   776    777       }
   777    778     }

Changes to ext/lsm1/lsm-test/lsmtest_tdb3.c.

   195    195     lsm_env *pRealEnv = tdb_lsm_env();
   196    196     LsmFile *p = (LsmFile *)pFile;
   197    197     LsmDb *pDb = p->pDb;
   198    198   
   199    199     if( pDb->bCrashed ) return LSM_IOERR;
   200    200   
   201    201     if( pDb->bPrepareCrash ){
   202         -    FileData *pData = &pDb->aFile[p->bLog];
          202  +    FileData *pData2 = &pDb->aFile[p->bLog];
   203    203       int iFirst;                 
   204    204       int iLast;
   205    205       int iSector;
   206    206   
   207         -    iFirst = (iOff / pDb->szSector);
   208         -    iLast =  ((iOff + nData - 1) / pDb->szSector);
          207  +    iFirst = (int)(iOff / pDb->szSector);
          208  +    iLast =  (int)((iOff + nData - 1) / pDb->szSector);
   209    209   
   210         -    if( pData->nSector<(iLast+1) ){
          210  +    if( pData2->nSector<(iLast+1) ){
   211    211         int nNew = ( ((iLast + 1) + 63) / 64 ) * 64;
   212    212         assert( nNew>iLast );
   213         -      pData->aSector = (FileSector *)testRealloc(
   214         -          pData->aSector, nNew*sizeof(FileSector)
          213  +      pData2->aSector = (FileSector *)testRealloc(
          214  +          pData2->aSector, nNew*sizeof(FileSector)
   215    215         );
   216         -      memset(&pData->aSector[pData->nSector], 
   217         -          0, (nNew - pData->nSector) * sizeof(FileSector)
          216  +      memset(&pData2->aSector[pData2->nSector], 
          217  +          0, (nNew - pData2->nSector) * sizeof(FileSector)
   218    218         );
   219         -      pData->nSector = nNew;
          219  +      pData2->nSector = nNew;
   220    220       }
   221    221   
   222    222       for(iSector=iFirst; iSector<=iLast; iSector++){
   223         -      if( pData->aSector[iSector].aOld==0 ){
          223  +      if( pData2->aSector[iSector].aOld==0 ){
   224    224           u8 *aOld = (u8 *)testMalloc(pDb->szSector);
   225    225           pRealEnv->xRead(
   226    226               p->pReal, (lsm_i64)iSector*pDb->szSector, aOld, pDb->szSector
   227    227           );
   228         -        pData->aSector[iSector].aOld = aOld;
          228  +        pData2->aSector[iSector].aOld = aOld;
   229    229         }
   230    230       }
   231    231     }
   232    232   
   233    233     if( pDb->xWriteHook ){
   234    234       int rc;
   235    235       int nUs;
................................................................................
   543    543   static int waitOnWorker(LsmDb *pDb){
   544    544     int rc;
   545    545     int nLimit = -1;
   546    546     int nSleep = 0;
   547    547   
   548    548     rc = lsm_config(pDb->db, LSM_CONFIG_AUTOFLUSH, &nLimit);
   549    549     do {
   550         -    int nOld, nNew, rc;
   551         -    rc = lsm_info(pDb->db, LSM_INFO_TREE_SIZE, &nOld, &nNew);
   552         -    if( rc!=LSM_OK ) return rc;
          550  +    int nOld, nNew, rc2;
          551  +    rc2 = lsm_info(pDb->db, LSM_INFO_TREE_SIZE, &nOld, &nNew);
          552  +    if( rc2!=LSM_OK ) return rc2;
   553    553       if( nOld==0 || nNew<(nLimit/2) ) break;
   554    554   #ifdef LSM_MUTEX_PTHREADS
   555    555       mt_signal_worker(pDb, 0);
   556    556   #endif
   557    557       usleep(5000);
   558    558       nSleep += 5;
   559    559     }while( 1 );
................................................................................
   884    884     testPrintError("syntax error at: \"%s\"\n", z);
   885    885     return 1;
   886    886   }
   887    887   
   888    888   int tdb_lsm_config_str(TestDb *pDb, const char *zStr){
   889    889     int rc = 0;
   890    890     if( tdb_lsm(pDb) ){
          891  +#ifdef LSM_MUTEX_PTHREADS
   891    892       int i;
          893  +#endif
   892    894       LsmDb *pLsm = (LsmDb *)pDb;
   893    895   
   894    896       rc = test_lsm_config_str(pLsm, pLsm->db, 0, zStr, 0);
   895    897   #ifdef LSM_MUTEX_PTHREADS
   896    898       for(i=0; rc==0 && i<pLsm->nWorker; i++){
   897    899         rc = test_lsm_config_str(0, pLsm->aWorker[i].pWorker, 1, zStr, 0);
   898    900       }