/ Check-in [364ac333]
Login

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

Overview
Comment:Fix compiler warnings.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sqlar-shell-support
Files: files | file ages | folders
SHA3-256: 364ac333b030f0e3372937df723f1098183da87913ba0e8ae162864ee24a50d3
User & Date: drh 2018-01-05 14:55:43
References
2018-01-05
18:51
Fix a bug introduced by efforts to reduce compiler warnings in check-in [364ac333b030f0] Closed-Leaf check-in: 1d6cee9a user: drh tags: sqlar-shell-support
Context
2018-01-05
16:03
Add some missing #ifdefs for building without zlib. check-in: c63fb170 user: mistachkin tags: sqlar-shell-support
14:55
Fix compiler warnings. check-in: 364ac333 user: drh tags: sqlar-shell-support
01:22
Revise detection of 'tclsh.exe' in the Makefile for MSVC. check-in: 45fabd86 user: mistachkin tags: sqlar-shell-support
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/fileio.c.

   172    172   ){
   173    173     char *zCopy = sqlite3_mprintf("%s", zFile);
   174    174     int rc = SQLITE_OK;
   175    175   
   176    176     if( zCopy==0 ){
   177    177       rc = SQLITE_NOMEM;
   178    178     }else{
   179         -    int nCopy = strlen(zCopy);
          179  +    int nCopy = (int)strlen(zCopy);
   180    180       int i = 1;
   181    181   
   182    182       while( rc==SQLITE_OK ){
   183    183         struct stat sStat;
   184         -      int rc;
   185    184   
   186    185         for(; zCopy[i]!='/' && i<nCopy; i++);
   187    186         if( i==nCopy ) break;
   188    187         zCopy[i] = '\0';
   189    188   
   190    189         rc = stat(zCopy, &sStat);
   191    190         if( rc!=0 ){
................................................................................
   630    629       fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument");
   631    630       return SQLITE_ERROR;
   632    631     }
   633    632     if( argc==2 ){
   634    633       pCur->zBase = (const char*)sqlite3_value_text(argv[1]);
   635    634     }
   636    635     if( pCur->zBase ){
   637         -    pCur->nBase = strlen(pCur->zBase)+1;
          636  +    pCur->nBase = (int)strlen(pCur->zBase)+1;
   638    637       pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir);
   639    638     }else{
   640    639       pCur->zPath = sqlite3_mprintf("%s", zDir);
   641    640     }
   642    641   
   643    642     if( pCur->zPath==0 ){
   644    643       return SQLITE_NOMEM;

Changes to src/shell.c.in.

  1951   1951         { "syscw: ",                  "Write() system calls:"     },
  1952   1952         { "read_bytes: ",             "Bytes read from storage:"  },
  1953   1953         { "write_bytes: ",            "Bytes written to storage:" },
  1954   1954         { "cancelled_write_bytes: ",  "Cancelled write bytes:"    },
  1955   1955       };
  1956   1956       int i;
  1957   1957       for(i=0; i<ArraySize(aTrans); i++){
  1958         -      int n = (int)strlen(aTrans[i].zPattern);
         1958  +      int n = strlen30(aTrans[i].zPattern);
  1959   1959         if( strncmp(aTrans[i].zPattern, z, n)==0 ){
  1960   1960           utf8_printf(out, "%-36s %s", aTrans[i].zDesc, &z[n]);
  1961   1961           break;
  1962   1962         }
  1963   1963       }
  1964   1964     }
  1965   1965     fclose(in);
................................................................................
  3130   3130   }
  3131   3131   
  3132   3132   #elif HAVE_LINENOISE
  3133   3133   /*
  3134   3134   ** Linenoise completion callback
  3135   3135   */
  3136   3136   static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
  3137         -  int nLine = (int)strlen(zLine);
         3137  +  int nLine = strlen30(zLine);
  3138   3138     int i, iStart;
  3139   3139     sqlite3_stmt *pStmt = 0;
  3140   3140     char *zSql;
  3141   3141     char zBuf[1000];
  3142   3142   
  3143   3143     if( nLine>sizeof(zBuf)-30 ) return;
  3144   3144     if( zLine[0]=='.' ) return;
................................................................................
  3356   3356     void *pX
  3357   3357   ){
  3358   3358     FILE *f = (FILE*)pArg;
  3359   3359     UNUSED_PARAMETER(mType);
  3360   3360     UNUSED_PARAMETER(pP);
  3361   3361     if( f ){
  3362   3362       const char *z = (const char*)pX;
  3363         -    int i = (int)strlen(z);
         3363  +    int i = strlen30(z);
  3364   3364       while( i>0 && z[i-1]==';' ){ i--; }
  3365   3365       utf8_printf(f, "%.*s;\n", i, z);
  3366   3366     }
  3367   3367     return 0;
  3368   3368   }
  3369   3369   #endif
  3370   3370   #endif
................................................................................
  3545   3545   ){
  3546   3546     sqlite3_stmt *pQuery = 0;
  3547   3547     sqlite3_stmt *pInsert = 0;
  3548   3548     char *zQuery = 0;
  3549   3549     char *zInsert = 0;
  3550   3550     int rc;
  3551   3551     int i, j, n;
  3552         -  int nTable = (int)strlen(zTable);
         3552  +  int nTable = strlen30(zTable);
  3553   3553     int k = 0;
  3554   3554     int cnt = 0;
  3555   3555     const int spinRate = 10000;
  3556   3556   
  3557   3557     zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
  3558   3558     rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
  3559   3559     if( rc ){
................................................................................
  3566   3566     zInsert = sqlite3_malloc64(200 + nTable + n*3);
  3567   3567     if( zInsert==0 ){
  3568   3568       raw_printf(stderr, "out of memory\n");
  3569   3569       goto end_data_xfer;
  3570   3570     }
  3571   3571     sqlite3_snprintf(200+nTable,zInsert,
  3572   3572                      "INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable);
  3573         -  i = (int)strlen(zInsert);
         3573  +  i = strlen30(zInsert);
  3574   3574     for(j=1; j<n; j++){
  3575   3575       memcpy(zInsert+i, ",?", 2);
  3576   3576       i += 2;
  3577   3577     }
  3578   3578     memcpy(zInsert+i, ");", 3);
  3579   3579     rc = sqlite3_prepare_v2(newDb, zInsert, -1, &pInsert, 0);
  3580   3580     if( rc ){
................................................................................
  4148   4148       "LEFT JOIN pragma_table_info AS p ON (pk-1=seq AND p.arg=f.[table]) "
  4149   4149       "GROUP BY s.name, f.id "
  4150   4150       "ORDER BY (CASE WHEN ? THEN f.[table] ELSE s.name END)"
  4151   4151     ;
  4152   4152     const char *zGlobIPK = "SEARCH TABLE * USING INTEGER PRIMARY KEY (rowid=?)";
  4153   4153   
  4154   4154     for(i=2; i<nArg; i++){
  4155         -    int n = (int)strlen(azArg[i]);
         4155  +    int n = strlen30(azArg[i]);
  4156   4156       if( n>1 && sqlite3_strnicmp("-verbose", azArg[i], n)==0 ){
  4157   4157         bVerbose = 1;
  4158   4158       }
  4159   4159       else if( n>1 && sqlite3_strnicmp("-groupbyparent", azArg[i], n)==0 ){
  4160   4160         bGroupByParent = 1;
  4161   4161         zIndent = "    ";
  4162   4162       }
................................................................................
  4251   4251   */
  4252   4252   static int lintDotCommand(
  4253   4253     ShellState *pState,             /* Current shell tool state */
  4254   4254     char **azArg,                   /* Array of arguments passed to dot command */
  4255   4255     int nArg                        /* Number of entries in azArg[] */
  4256   4256   ){
  4257   4257     int n;
  4258         -  n = (nArg>=2 ? (int)strlen(azArg[1]) : 0);
         4258  +  n = (nArg>=2 ? strlen30(azArg[1]) : 0);
  4259   4259     if( n<1 || sqlite3_strnicmp(azArg[1], "fkey-indexes", n) ) goto usage;
  4260   4260     return lintFkeyIndexes(pState, azArg, nArg);
  4261   4261   
  4262   4262    usage:
  4263   4263     raw_printf(stderr, "Usage %s sub-command ?switches...?\n", azArg[0]);
  4264   4264     raw_printf(stderr, "Where sub-commands are:\n");
  4265   4265     raw_printf(stderr, "    fkey-indexes\n");
................................................................................
  4513   4513           z = azArg[iArg];
  4514   4514           if( z[0]!='-' ){
  4515   4515             /* All remaining command line words are command arguments. */
  4516   4516             pAr->azArg = &azArg[iArg];
  4517   4517             pAr->nArg = nArg-iArg;
  4518   4518             break;
  4519   4519           }
  4520         -        n = strlen(z);
         4520  +        n = strlen30(z);
  4521   4521   
  4522   4522           if( z[1]!='-' ){
  4523   4523             int i;
  4524   4524             /* One or more short options */
  4525   4525             for(i=1; i<n; i++){
  4526   4526               const char *zArg = 0;
  4527   4527               struct ArSwitch *pOpt;
................................................................................
  4553   4553           }else{
  4554   4554             /* A long option */
  4555   4555             const char *zArg = 0;             /* Argument for option, if any */
  4556   4556             struct ArSwitch *pMatch = 0;      /* Matching option */
  4557   4557             struct ArSwitch *pOpt;            /* Iterator */
  4558   4558             for(pOpt=&aSwitch[0]; pOpt<pEnd; pOpt++){
  4559   4559               const char *zLong = pOpt->zLong;
  4560         -            if( (n-2)<=(int)strlen(zLong) && 0==memcmp(&z[2], zLong, n-2) ){
         4560  +            if( (n-2)<=strlen30(zLong) && 0==memcmp(&z[2], zLong, n-2) ){
  4561   4561                 if( pMatch ){
  4562   4562                   return arErrorMsg("ambiguous option: %s",z);
  4563   4563                 }else{
  4564   4564                   pMatch = pOpt;
  4565   4565                 }
  4566   4566               }
  4567   4567             }
................................................................................
  4606   4606           pAr->bZip ? "zipfile(?2)" : "sqlar"
  4607   4607       );
  4608   4608       if( rc==SQLITE_OK && pAr->bZip ){
  4609   4609         sqlite3_bind_text(pTest, 2, pAr->zFile, -1, SQLITE_TRANSIENT);
  4610   4610       }
  4611   4611       for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
  4612   4612         char *z = pAr->azArg[i];
  4613         -      int n = strlen(z);
         4613  +      int n = strlen30(z);
  4614   4614         int bOk = 0;
  4615   4615         while( n>0 && z[n-1]=='/' ) n--;
  4616   4616         z[n] = '\0';
  4617   4617         sqlite3_bind_text(pTest, 1, z, -1, SQLITE_STATIC);
  4618   4618         if( SQLITE_ROW==sqlite3_step(pTest) ){
  4619   4619           bOk = 1;
  4620   4620         }
................................................................................
  5021   5021     assert( pState->expert.pExpert==0 );
  5022   5022     memset(&pState->expert, 0, sizeof(ExpertInfo));
  5023   5023   
  5024   5024     for(i=1; rc==SQLITE_OK && i<nArg; i++){
  5025   5025       char *z = azArg[i];
  5026   5026       int n;
  5027   5027       if( z[0]=='-' && z[1]=='-' ) z++;
  5028         -    n = strlen(z);
         5028  +    n = strlen30(z);
  5029   5029       if( n>=2 && 0==strncmp(z, "-verbose", n) ){
  5030   5030         pState->expert.bVerbose = 1;
  5031   5031       }
  5032   5032       else if( n>=2 && 0==strncmp(z, "-sample", n) ){
  5033   5033         if( i==(nArg-1) ){
  5034   5034           raw_printf(stderr, "option requires an argument: %s\n", z);
  5035   5035           rc = SQLITE_ERROR;
................................................................................
  5904   5904         output_file_close(p->pLog);
  5905   5905         p->pLog = output_file_open(zFile);
  5906   5906       }
  5907   5907     }else
  5908   5908   
  5909   5909     if( c=='m' && strncmp(azArg[0], "mode", n)==0 ){
  5910   5910       const char *zMode = nArg>=2 ? azArg[1] : "";
  5911         -    int n2 = (int)strlen(zMode);
         5911  +    int n2 = strlen30(zMode);
  5912   5912       int c2 = zMode[0];
  5913   5913       if( c2=='l' && n2>2 && strncmp(azArg[1],"lines",n2)==0 ){
  5914   5914         p->mode = MODE_Line;
  5915   5915         sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
  5916   5916       }else if( c2=='c' && strncmp(azArg[1],"columns",n2)==0 ){
  5917   5917         p->mode = MODE_Column;
  5918   5918         sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
................................................................................
  7143   7143       open_db(p, 0);
  7144   7144       if( strcmp(azArg[1],"login")==0 ){
  7145   7145         if( nArg!=4 ){
  7146   7146           raw_printf(stderr, "Usage: .user login USER PASSWORD\n");
  7147   7147           rc = 1;
  7148   7148           goto meta_command_exit;
  7149   7149         }
  7150         -      rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],
  7151         -                                    (int)strlen(azArg[3]));
         7150  +      rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3], strlen30(azArg[3]));
  7152   7151         if( rc ){
  7153   7152           utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]);
  7154   7153           rc = 1;
  7155   7154         }
  7156   7155       }else if( strcmp(azArg[1],"add")==0 ){
  7157   7156         if( nArg!=5 ){
  7158   7157           raw_printf(stderr, "Usage: .user add USER PASSWORD ISADMIN\n");
  7159   7158           rc = 1;
  7160   7159           goto meta_command_exit;
  7161   7160         }
  7162         -      rc = sqlite3_user_add(p->db, azArg[2],
  7163         -                            azArg[3], (int)strlen(azArg[3]),
         7161  +      rc = sqlite3_user_add(p->db, azArg[2], azArg[3], strlen30(azArg[3]),
  7164   7162                               booleanValue(azArg[4]));
  7165   7163         if( rc ){
  7166   7164           raw_printf(stderr, "User-Add failed: %d\n", rc);
  7167   7165           rc = 1;
  7168   7166         }
  7169   7167       }else if( strcmp(azArg[1],"edit")==0 ){
  7170   7168         if( nArg!=5 ){
  7171   7169           raw_printf(stderr, "Usage: .user edit USER PASSWORD ISADMIN\n");
  7172   7170           rc = 1;
  7173   7171           goto meta_command_exit;
  7174   7172         }
  7175         -      rc = sqlite3_user_change(p->db, azArg[2],
  7176         -                              azArg[3], (int)strlen(azArg[3]),
         7173  +      rc = sqlite3_user_change(p->db, azArg[2], azArg[3], strlen30(azArg[3]),
  7177   7174                                 booleanValue(azArg[4]));
  7178   7175         if( rc ){
  7179   7176           raw_printf(stderr, "User-Edit failed: %d\n", rc);
  7180   7177           rc = 1;
  7181   7178         }
  7182   7179       }else if( strcmp(azArg[1],"delete")==0 ){
  7183   7180         if( nArg!=3 ){