Fix harmless compiler warnings.  Improved comments in the query optimizer. (CVS 5982)

FossilOrigin-Name: adedd697b475dadaa2eeae0d0413603195c955cf
diff --git a/src/mem2.c b/src/mem2.c
index 1fce769..aaa58e2 100644
--- a/src/mem2.c
+++ b/src/mem2.c
@@ -19,7 +19,7 @@
 ** This file contains implementations of the low-level memory allocation
 ** routines specified in the sqlite3_mem_methods object.
 **
-** $Id: mem2.c,v 1.40 2008/10/28 18:58:20 drh Exp $
+** $Id: mem2.c,v 1.41 2008/12/05 17:17:08 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -158,11 +158,11 @@
 
   p = (struct MemBlockHdr*)pAllocation;
   p--;
-  assert( p->iForeGuard==FOREGUARD );
+  assert( p->iForeGuard==(int)FOREGUARD );
   nReserve = (p->iSize+7)&~7;
   pInt = (int*)pAllocation;
   pU8 = (u8*)pAllocation;
-  assert( pInt[nReserve/sizeof(int)]==REARGUARD );
+  assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );
   assert( (nReserve-0)<=p->iSize || pU8[nReserve-1]==0x65 );
   assert( (nReserve-1)<=p->iSize || pU8[nReserve-2]==0x65 );
   assert( (nReserve-2)<=p->iSize || pU8[nReserve-3]==0x65 );
@@ -185,6 +185,7 @@
 ** Initialize the memory allocation subsystem.
 */
 static int sqlite3MemInit(void *NotUsed){
+  UNUSED_PARAMETER(NotUsed);
   if( !sqlite3GlobalConfig.bMemstat ){
     /* If memory status is enabled, then the malloc.c wrapper will already
     ** hold the STATIC_MEM mutex when the routines here are invoked. */
@@ -197,6 +198,7 @@
 ** Deinitialize the memory allocation subsystem.
 */
 static void sqlite3MemShutdown(void *NotUsed){
+  UNUSED_PARAMETER(NotUsed);
   mem.mutex = 0;
 }
 
@@ -361,7 +363,7 @@
 ** Set the title string for subsequent allocations.
 */
 void sqlite3MemdebugSettitle(const char *zTitle){
-  int n = strlen(zTitle) + 1;
+  unsigned int n = strlen(zTitle) + 1;
   sqlite3_mutex_enter(mem.mutex);
   if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1;
   memcpy(mem.zTitle, zTitle, n);
diff --git a/src/mutex_noop.c b/src/mutex_noop.c
index ecee9a9..7c13244 100644
--- a/src/mutex_noop.c
+++ b/src/mutex_noop.c
@@ -25,7 +25,7 @@
 ** that does error checking on mutexes to make sure they are being
 ** called correctly.
 **
-** $Id: mutex_noop.c,v 1.2 2008/10/15 19:03:03 drh Exp $
+** $Id: mutex_noop.c,v 1.3 2008/12/05 17:17:08 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -116,7 +116,7 @@
     }
     default: {
       assert( id-2 >= 0 );
-      assert( id-2 < sizeof(aStatic)/sizeof(aStatic[0]) );
+      assert( id-2 < (int)(sizeof(aStatic)/sizeof(aStatic[0])) );
       pNew = &aStatic[id-2];
       pNew->id = id;
       break;
diff --git a/src/shell.c b/src/shell.c
index 0581807..141b125 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -12,7 +12,7 @@
 ** This file contains code to implement the "sqlite" command line
 ** utility for accessing SQLite databases.
 **
-** $Id: shell.c,v 1.189 2008/12/04 12:26:01 drh Exp $
+** $Id: shell.c,v 1.190 2008/12/05 17:17:08 drh Exp $
 */
 #include <stdlib.h>
 #include <string.h>
@@ -66,6 +66,12 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 
+/*
+** Used to prevent warnings about unused parameters
+*/
+#define UNUSED_PARAMETER(x) (void)(x)
+
+
 /* Saved resource information for the beginning of an operation */
 static struct rusage sBegin;
 
@@ -216,6 +222,7 @@
 ){
   assert( 0==argc );
   assert( zShellStatic );
+  UNUSED_PARAMETER(argv);
   sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
 }
 
@@ -355,7 +362,7 @@
 /*
 ** Number of elements in an array
 */
-#define ArraySize(X)  (sizeof(X)/sizeof(X[0]))
+#define ArraySize(X)  (int)(sizeof(X)/sizeof(X[0]))
 
 /*
 ** Output the given string as a quoted string using SQL quoting conventions.
@@ -502,6 +509,7 @@
 ** This routine runs when the user presses Ctrl-C
 */
 static void interrupt_handler(int NotUsed){
+  UNUSED_PARAMETER(NotUsed);
   seenInterrupt = 1;
   if( db ) sqlite3_interrupt(db);
 }
@@ -574,7 +582,7 @@
         }else{
            w = 10;
         }
-        if( p->mode==MODE_Explain && azArg[i] && strlen(azArg[i])>w ){
+        if( p->mode==MODE_Explain && azArg[i] && strlen(azArg[i])>(unsigned)w ){
           w = strlen(azArg[i]);
         }
         fprintf(p->out,"%-*.*s%s",w,w,
@@ -793,6 +801,7 @@
   const char *zSql;
   struct callback_data *p = (struct callback_data *)pArg;
 
+  UNUSED_PARAMETER(azCol);
   if( nArg!=3 ) return 1;
   zTable = azArg[0];
   zType = azArg[1];
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index c03b6b4..5758aa4 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.801 2008/12/05 02:36:34 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.802 2008/12/05 17:17:08 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -1517,7 +1517,7 @@
 */
 struct WhereLevel {
   int iFrom;            /* Which entry in the FROM clause */
-  int wsFlags;          /* "Where-Scan Flags" associated with this level */
+  int wsFlags;          /* "Where-Scan" flags show the choosen scan strategy */
   int iMem;             /* First memory cell used by this level */
   int iLeftJoin;        /* Memory cell used to implement LEFT OUTER JOIN */
   Index *pIdx;          /* Index used.  NULL if no index */
diff --git a/src/test1.c b/src/test1.c
index 807ad61..4e7ba56 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.335 2008/12/03 22:32:45 drh Exp $
+** $Id: test1.c,v 1.336 2008/12/05 17:17:08 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -3915,7 +3915,7 @@
     db->magic = SQLITE_MAGIC_BUSY;
   }else if( strcmp(argv[2], "SQLITE_MAGIC_ERROR")==0 ){
     db->magic = SQLITE_MAGIC_ERROR;
-  }else if( Tcl_GetInt(interp, argv[2], &db->magic) ){
+  }else if( Tcl_GetInt(interp, argv[2], (int*)&db->magic) ){
     return TCL_ERROR;
   }
   return TCL_OK;
@@ -4516,9 +4516,7 @@
   int objc,              /* Number of arguments */
   Tcl_Obj *CONST objv[]  /* Command arguments */
 ){
-  int iArg = 0;
   sqlite3 *db;
-  int rc;
   
   if( objc!=2 ){
     Tcl_AppendResult(interp, "wrong # args: should be \"",
diff --git a/src/where.c b/src/where.c
index c2693ba..2794d4f 100644
--- a/src/where.c
+++ b/src/where.c
@@ -16,7 +16,7 @@
 ** 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.332 2008/12/05 15:24:17 drh Exp $
+** $Id: where.c,v 1.333 2008/12/05 17:17:08 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -280,7 +280,7 @@
 ** does is make slot[] entries point to substructure within pExpr.
 **
 ** In the previous sentence and in the diagram, "slot[]" refers to
-** the WhereClause.a[] array.  This array grows as needed to contain
+** the WhereClause.a[] array.  The slot[] array grows as needed to contain
 ** all terms of the WHERE clause.
 */
 static void whereSplit(WhereClause *pWC, Expr *pExpr, int op){
@@ -391,7 +391,7 @@
 }
 
 /*
-** Swap two objects of type T.
+** Swap two objects of type TYPE.
 */
 #define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}