/ Check-in [59ae0020]
Login

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

Overview
Comment:Get rid of more silly compiler warnings. (CVS 5996)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 59ae0020683766993c38e2b76a436d78d3e4bd63
User & Date: drh 2008-12-09 03:55:14
Context
2008-12-09
04:59
Removed some harmless compiler warnings and converted some "double" ops to "int" in date.c. (CVS 5997) check-in: 5eb648a0 user: shane tags: trunk
03:55
Get rid of more silly compiler warnings. (CVS 5996) check-in: 59ae0020 user: drh tags: trunk
02:51
Suppress more silly compiler warnings. (CVS 5995) check-in: 1522c2c6 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/table.c.

    12     12   ** This file contains the sqlite3_get_table() and sqlite3_free_table()
    13     13   ** interface routines.  These are just wrappers around the main
    14     14   ** interface routine of sqlite3_exec().
    15     15   **
    16     16   ** These routines are in a separate files so that they will not be linked
    17     17   ** if they are not used.
    18     18   **
    19         -** $Id: table.c,v 1.36 2008/07/08 22:28:49 shane Exp $
           19  +** $Id: table.c,v 1.37 2008/12/09 03:55:14 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   #include <stdlib.h>
    23     23   #include <string.h>
    24     24   
    25     25   #ifndef SQLITE_OMIT_GET_TABLE
    26     26   
................................................................................
    88     88     /* Copy over the row data
    89     89     */
    90     90     if( argv!=0 ){
    91     91       for(i=0; i<nCol; i++){
    92     92         if( argv[i]==0 ){
    93     93           z = 0;
    94     94         }else{
    95         -        int n = strlen(argv[i])+1;
           95  +        int n = (int)strlen(argv[i])+1;
    96     96           z = sqlite3_malloc( n );
    97     97           if( z==0 ) goto malloc_failed;
    98     98           memcpy(z, argv[i], n);
    99     99         }
   100    100         p->azResult[p->nData++] = z;
   101    101       }
   102    102       p->nRow++;

Changes to src/trigger.c.

     6      6   **    May you do good and not evil.
     7      7   **    May you find forgiveness for yourself and forgive others.
     8      8   **    May you share freely, never taking more than you give.
     9      9   **
    10     10   *************************************************************************
    11     11   **
    12     12   **
    13         -** $Id: trigger.c,v 1.130 2008/11/19 09:05:27 danielk1977 Exp $
           13  +** $Id: trigger.c,v 1.131 2008/12/09 03:55:14 drh Exp $
    14     14   */
    15     15   #include "sqliteInt.h"
    16     16   
    17     17   #ifndef SQLITE_OMIT_TRIGGER
    18     18   /*
    19     19   ** Delete a linked list of TriggerStep structures.
    20     20   */
................................................................................
    60     60     int iDb;                /* The database to store the trigger in */
    61     61     Token *pName;           /* The unqualified db name */
    62     62     DbFixer sFix;
    63     63     int iTabDb;
    64     64   
    65     65     assert( pName1!=0 );   /* pName1->z might be NULL, but not pName1 itself */
    66     66     assert( pName2!=0 );
           67  +  assert( op==TK_INSERT || op==TK_UPDATE || op==TK_DELETE );
           68  +  assert( op>0 && op<0xff );
    67     69     if( isTemp ){
    68     70       /* If TEMP was specified, then the trigger name may not be qualified. */
    69     71       if( pName2->n>0 ){
    70     72         sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name");
    71     73         goto trigger_cleanup;
    72     74       }
    73     75       iDb = 1;
................................................................................
   112    114   
   113    115     /* Check that the trigger name is not reserved and that no trigger of the
   114    116     ** specified name exists */
   115    117     zName = sqlite3NameFromToken(db, pName);
   116    118     if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
   117    119       goto trigger_cleanup;
   118    120     }
   119         -  if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName,strlen(zName)) ){
          121  +  if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),
          122  +                      zName, (int)strlen(zName)) ){
   120    123       if( !noErr ){
   121    124         sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);
   122    125       }
   123    126       goto trigger_cleanup;
   124    127     }
   125    128   
   126    129     /* Do not create a trigger on a system table */
................................................................................
   173    176     pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));
   174    177     if( pTrigger==0 ) goto trigger_cleanup;
   175    178     pTrigger->name = zName;
   176    179     zName = 0;
   177    180     pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
   178    181     pTrigger->pSchema = db->aDb[iDb].pSchema;
   179    182     pTrigger->pTabSchema = pTab->pSchema;
   180         -  pTrigger->op = op;
          183  +  pTrigger->op = (u8)op;
   181    184     pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;
   182    185     pTrigger->pWhen = sqlite3ExprDup(db, pWhen);
   183    186     pTrigger->pColumns = sqlite3IdListDup(db, pColumns);
   184    187     sqlite3TokenCopy(db, &pTrigger->nameToken,pName);
   185    188     assert( pParse->pNewTrigger==0 );
   186    189     pParse->pNewTrigger = pTrigger;
   187    190   
................................................................................
   249    252     }
   250    253   
   251    254     if( db->init.busy ){
   252    255       int n;
   253    256       Table *pTab;
   254    257       Trigger *pDel;
   255    258       pDel = sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash, 
   256         -                     pTrig->name, strlen(pTrig->name), pTrig);
          259  +                     pTrig->name, (int)strlen(pTrig->name), pTrig);
   257    260       if( pDel ){
   258    261         assert( pDel==pTrig );
   259    262         db->mallocFailed = 1;
   260    263         goto triggerfinish_cleanup;
   261    264       }
   262         -    n = strlen(pTrig->table) + 1;
          265  +    n = (int)strlen(pTrig->table) + 1;
   263    266       pTab = sqlite3HashFind(&pTrig->pTabSchema->tblHash, pTrig->table, n);
   264    267       assert( pTab!=0 );
   265    268       pTrig->pNext = pTab->pTrigger;
   266    269       pTab->pTrigger = pTrig;
   267    270       pTrig = 0;
   268    271     }
   269    272   
................................................................................
   482    485   }
   483    486   
   484    487   /*
   485    488   ** Return a pointer to the Table structure for the table that a trigger
   486    489   ** is set on.
   487    490   */
   488    491   static Table *tableOfTrigger(Trigger *pTrigger){
   489         -  int n = strlen(pTrigger->table) + 1;
          492  +  int n = (int)strlen(pTrigger->table) + 1;
   490    493     return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n);
   491    494   }
   492    495   
   493    496   
   494    497   /*
   495    498   ** Drop a trigger given a pointer to that trigger. 
   496    499   */
................................................................................
   547    550   }
   548    551   
   549    552   /*
   550    553   ** Remove a trigger from the hash tables of the sqlite* pointer.
   551    554   */
   552    555   void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){
   553    556     Trigger *pTrigger;
   554         -  int nName = strlen(zName);
          557  +  int nName = (int)strlen(zName);
   555    558     pTrigger = sqlite3HashInsert(&(db->aDb[iDb].pSchema->trigHash),
   556    559                                  zName, nName, 0);
   557    560     if( pTrigger ){
   558    561       Table *pTable = tableOfTrigger(pTrigger);
   559    562       assert( pTable!=0 );
   560    563       if( pTable->pTrigger == pTrigger ){
   561    564         pTable->pTrigger = pTrigger->pNext;
................................................................................
   638    641     int iDb;             /* Index of the database to use */
   639    642     SrcList *pSrc;       /* SrcList to be returned */
   640    643   
   641    644     iDb = sqlite3SchemaToIndex(pParse->db, pStep->pTrig->pSchema);
   642    645     if( iDb==0 || iDb>=2 ){
   643    646       assert( iDb<pParse->db->nDb );
   644    647       sDb.z = (u8*)pParse->db->aDb[iDb].zName;
   645         -    sDb.n = strlen((char*)sDb.z);
          648  +    sDb.n = (int)strlen((char*)sDb.z);
   646    649       pSrc = sqlite3SrcListAppend(pParse->db, 0, &sDb, &pStep->target);
   647    650     } else {
   648    651       pSrc = sqlite3SrcListAppend(pParse->db, 0, &pStep->target, 0);
   649    652     }
   650    653     return pSrc;
   651    654   }
   652    655   

Changes to src/utf.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used to translate between UTF-8, 
    13     13   ** UTF-16, UTF-16BE, and UTF-16LE.
    14     14   **
    15         -** $Id: utf.c,v 1.67 2008/12/08 21:37:15 drh Exp $
           15  +** $Id: utf.c,v 1.68 2008/12/09 03:55:14 drh Exp $
    16     16   **
    17     17   ** Notes on UTF-8:
    18     18   **
    19     19   **   Byte-0    Byte-1    Byte-2    Byte-3    Value
    20     20   **  0xxxxxxx                                 00000000 00000000 0xxxxxxx
    21     21   **  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx
    22     22   **  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx
................................................................................
    61     61     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    62     62     0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,
    63     63   };
    64     64   
    65     65   
    66     66   #define WRITE_UTF8(zOut, c) {                          \
    67     67     if( c<0x00080 ){                                     \
    68         -    *zOut++ = (c&0xFF);                                \
           68  +    *zOut++ = (u8)(c&0xFF);                            \
    69     69     }                                                    \
    70     70     else if( c<0x00800 ){                                \
    71         -    *zOut++ = 0xC0 + ((c>>6)&0x1F);                    \
    72         -    *zOut++ = 0x80 + (c & 0x3F);                       \
           71  +    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \
           72  +    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \
    73     73     }                                                    \
    74     74     else if( c<0x10000 ){                                \
    75         -    *zOut++ = 0xE0 + ((c>>12)&0x0F);                   \
    76         -    *zOut++ = 0x80 + ((c>>6) & 0x3F);                  \
    77         -    *zOut++ = 0x80 + (c & 0x3F);                       \
           75  +    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \
           76  +    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \
           77  +    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \
    78     78     }else{                                               \
    79         -    *zOut++ = 0xF0 + ((c>>18) & 0x07);                 \
    80         -    *zOut++ = 0x80 + ((c>>12) & 0x3F);                 \
    81         -    *zOut++ = 0x80 + ((c>>6) & 0x3F);                  \
    82         -    *zOut++ = 0x80 + (c & 0x3F);                       \
           79  +    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \
           80  +    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \
           81  +    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \
           82  +    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \
    83     83     }                                                    \
    84     84   }
    85     85   
    86         -#define WRITE_UTF16LE(zOut, c) {                                \
    87         -  if( c<=0xFFFF ){                                              \
    88         -    *zOut++ = (c&0x00FF);                                       \
    89         -    *zOut++ = ((c>>8)&0x00FF);                                  \
    90         -  }else{                                                        \
    91         -    *zOut++ = (((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \
    92         -    *zOut++ = (0x00D8 + (((c-0x10000)>>18)&0x03));              \
    93         -    *zOut++ = (c&0x00FF);                                       \
    94         -    *zOut++ = (0x00DC + ((c>>8)&0x03));                         \
    95         -  }                                                             \
           86  +#define WRITE_UTF16LE(zOut, c) {                                    \
           87  +  if( c<=0xFFFF ){                                                  \
           88  +    *zOut++ = (u8)(c&0x00FF);                                       \
           89  +    *zOut++ = (u8)((c>>8)&0x00FF);                                  \
           90  +  }else{                                                            \
           91  +    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \
           92  +    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \
           93  +    *zOut++ = (u8)(c&0x00FF);                                       \
           94  +    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \
           95  +  }                                                                 \
    96     96   }
    97     97   
    98         -#define WRITE_UTF16BE(zOut, c) {                                \
    99         -  if( c<=0xFFFF ){                                              \
   100         -    *zOut++ = ((c>>8)&0x00FF);                                  \
   101         -    *zOut++ = (c&0x00FF);                                       \
   102         -  }else{                                                        \
   103         -    *zOut++ = (0x00D8 + (((c-0x10000)>>18)&0x03));              \
   104         -    *zOut++ = (((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \
   105         -    *zOut++ = (0x00DC + ((c>>8)&0x03));                         \
   106         -    *zOut++ = (c&0x00FF);                                       \
   107         -  }                                                             \
           98  +#define WRITE_UTF16BE(zOut, c) {                                    \
           99  +  if( c<=0xFFFF ){                                                  \
          100  +    *zOut++ = (u8)((c>>8)&0x00FF);                                  \
          101  +    *zOut++ = (u8)(c&0x00FF);                                       \
          102  +  }else{                                                            \
          103  +    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \
          104  +    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \
          105  +    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \
          106  +    *zOut++ = (u8)(c&0x00FF);                                       \
          107  +  }                                                                 \
   108    108   }
   109    109   
   110    110   #define READ_UTF16LE(zIn, c){                                         \
   111    111     c = (*zIn++);                                                       \
   112    112     c += ((*zIn++)<<8);                                                 \
   113    113     if( c>=0xD800 && c<0xE000 ){                                       \
   114    114       int c2 = (*zIn++);                                                \
................................................................................
   301    301       }else{
   302    302         /* UTF-16 Big-endian -> UTF-8 */
   303    303         while( zIn<zTerm ){
   304    304           READ_UTF16BE(zIn, c); 
   305    305           WRITE_UTF8(z, c);
   306    306         }
   307    307       }
   308         -    pMem->n = z - zOut;
          308  +    pMem->n = (int)(z - zOut);
   309    309     }
   310    310     *z = 0;
   311    311     assert( (pMem->n+(desiredEnc==SQLITE_UTF8?1:2))<=len );
   312    312   
   313    313     sqlite3VdbeMemRelease(pMem);
   314    314     pMem->flags &= ~(MEM_Static|MEM_Dyn|MEM_Ephem);
   315    315     pMem->enc = desiredEnc;
................................................................................
   471    471       }
   472    472     }else{
   473    473       while( c && ((nChar<0) || n<nChar) ){
   474    474         READ_UTF16LE(z, c);
   475    475         n++;
   476    476       }
   477    477     }
   478         -  return (z-(char const *)zIn)-((c==0)?2:0);
          478  +  return (int)(z-(char const *)zIn)-((c==0)?2:0);
   479    479   }
   480    480   
   481    481   #if defined(SQLITE_TEST)
   482    482   /*
   483    483   ** This routine is called from the TCL test function "translate_selftest".
   484    484   ** It checks that the primitives for serializing and deserializing
   485    485   ** characters in each encoding are inverses of each other.

Changes to src/util.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Utility functions used throughout sqlite.
    13     13   **
    14     14   ** This file contains functions for allocating memory, comparing
    15     15   ** strings, and stuff like that.
    16     16   **
    17         -** $Id: util.c,v 1.242 2008/11/17 19:18:55 danielk1977 Exp $
           17  +** $Id: util.c,v 1.243 2008/12/09 03:55:14 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdarg.h>
    21     21   #include <ctype.h>
    22     22   
    23     23   
    24     24   /*
................................................................................
    55     55   ** to exceed the SQLITE_LIMIT_LENGTH setting.
    56     56   */
    57     57   int sqlite3Strlen(sqlite3 *db, const char *z){
    58     58     const char *z2 = z;
    59     59     int len;
    60     60     int x;
    61     61     while( *z2 ){ z2++; }
    62         -  x = z2 - z;
           62  +  x = (int)(z2 - z);
    63     63     len = 0x7fffffff & x;
    64     64     if( len!=x || len > db->aLimit[SQLITE_LIMIT_LENGTH] ){
    65     65       return db->aLimit[SQLITE_LIMIT_LENGTH];
    66     66     }else{
    67     67       return len;
    68     68     }
    69     69   }
................................................................................
   151    151   ** is a no-op.
   152    152   **
   153    153   ** 2002-Feb-14: This routine is extended to remove MS-Access style
   154    154   ** brackets from around identifers.  For example:  "[a-b-c]" becomes
   155    155   ** "a-b-c".
   156    156   */
   157    157   void sqlite3Dequote(char *z){
   158         -  int quote;
          158  +  char quote;
   159    159     int i, j;
   160    160     if( z==0 ) return;
   161    161     quote = z[0];
   162    162     switch( quote ){
   163    163       case '\'':  break;
   164    164       case '"':   break;
   165    165       case '`':   break;                /* For MySQL compatibility */
................................................................................
   310    310       while( eval>=1 ){ scale *= 1.0e+1; eval -= 1; }
   311    311       if( esign<0 ){
   312    312         v1 /= scale;
   313    313       }else{
   314    314         v1 *= scale;
   315    315       }
   316    316     }
   317         -  *pResult = sign<0 ? -v1 : v1;
   318         -  return z - zBegin;
          317  +  *pResult = (double)(sign<0 ? -v1 : v1);
          318  +  return (int)(z - zBegin);
   319    319   #else
   320    320     return sqlite3Atoi64(z, pResult);
   321    321   #endif /* SQLITE_OMIT_FLOATING_POINT */
   322    322   }
   323    323   
   324    324   /*
   325    325   ** Compare the 19-character string zNum against the text representation
................................................................................
   497    497   ** bit clear.  Except, if we get to the 9th byte, it stores the full
   498    498   ** 8 bits and is the last byte.
   499    499   */
   500    500   int sqlite3PutVarint(unsigned char *p, u64 v){
   501    501     int i, j, n;
   502    502     u8 buf[10];
   503    503     if( v & (((u64)0xff000000)<<32) ){
   504         -    p[8] = v;
          504  +    p[8] = (u8)v;
   505    505       v >>= 8;
   506    506       for(i=7; i>=0; i--){
   507         -      p[i] = (v & 0x7f) | 0x80;
          507  +      p[i] = (u8)((v & 0x7f) | 0x80);
   508    508         v >>= 7;
   509    509       }
   510    510       return 9;
   511    511     }    
   512    512     n = 0;
   513    513     do{
   514         -    buf[n++] = (v & 0x7f) | 0x80;
          514  +    buf[n++] = (u8)((v & 0x7f) | 0x80);
   515    515       v >>= 7;
   516    516     }while( v!=0 );
   517    517     buf[0] &= 0x7f;
   518    518     assert( n<=9 );
   519    519     for(i=0, j=n-1; j>=0; j--, i++){
   520    520       p[i] = buf[j];
   521    521     }
................................................................................
   534    534   #ifndef putVarint32
   535    535     if( (v & ~0x7f)==0 ){
   536    536       p[0] = v;
   537    537       return 1;
   538    538     }
   539    539   #endif
   540    540     if( (v & ~0x3fff)==0 ){
   541         -    p[0] = (v>>7) | 0x80;
   542         -    p[1] = v & 0x7f;
          541  +    p[0] = (u8)((v>>7) | 0x80);
          542  +    p[1] = (u8)(v & 0x7f);
   543    543       return 2;
   544    544     }
   545    545     return sqlite3PutVarint(p, v);
   546    546   }
   547    547   
   548    548   /*
   549    549   ** Read a 64-bit variable-length integer from memory starting at p[0].
................................................................................
   807    807   /*
   808    808   ** Read or write a four-byte big-endian integer value.
   809    809   */
   810    810   u32 sqlite3Get4byte(const u8 *p){
   811    811     return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
   812    812   }
   813    813   void sqlite3Put4byte(unsigned char *p, u32 v){
   814         -  p[0] = v>>24;
   815         -  p[1] = v>>16;
   816         -  p[2] = v>>8;
   817         -  p[3] = v;
          814  +  p[0] = (u8)(v>>24);
          815  +  p[1] = (u8)(v>>16);
          816  +  p[2] = (u8)(v>>8);
          817  +  p[3] = (u8)v;
   818    818   }
   819    819   
   820    820   
   821    821   
   822    822   #if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC)
   823    823   /*
   824    824   ** Translate a single byte of Hex into an integer.
   825    825   ** This routinen only works if h really is a valid hexadecimal
   826    826   ** character:  0..9a..fA..F
   827    827   */
   828         -static int hexToInt(int h){
          828  +static u8 hexToInt(int h){
   829    829     assert( (h>='0' && h<='9') ||  (h>='a' && h<='f') ||  (h>='A' && h<='F') );
   830    830   #ifdef SQLITE_ASCII
   831    831     h += 9*(1&(h>>6));
   832    832   #endif
   833    833   #ifdef SQLITE_EBCDIC
   834    834     h += 9*(1&~(h>>4));
   835    835   #endif
   836         -  return h & 0xf;
          836  +  return (u8)(h & 0xf);
   837    837   }
   838    838   #endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */
   839    839   
   840    840   #if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC)
   841    841   /*
   842    842   ** Convert a BLOB literal of the form "x'hhhhhh'" into its binary
   843    843   ** value.  Return a pointer to its binary value.  Space to hold the