2014/1/23 Richard Hipp <[email protected]>:
> At this point you are likely to find lots of compiler warnings.  Do not
> worry about those.  I'm looking for incorrect behavior and/or bad
> query-planner decisions, not compiler warnings.  We'll deal with the
> compiler warnings over the coming weeks.

When building tclsqlite.c using the (unmodified) TEA makefiles
on Cygwin (using --with-system-sqlite), I see many warnings like:

/usr/src/sqlite3/sqlite3-3.8.3-1/src/tea/generic/tclsqlite3.c: In
function ‘auth_callback’:
/usr/src/sqlite3/sqlite3-3.8.3-1/src/tea/generic/tclsqlite3.c:893:42:
warning: assignment discards ‘const’ qualifier from pointer target
type [enabled by default]
     case SQLITE_COPY              : zCode="SQLITE_COPY"; break;
                                          ^

And I would like to suggest to change the reference to the
"sqlite3_version" global variable into "sqlite3_libversion()":
Some platforms (e.g. Windows) don't handle accessing
global variables from other modules very well, using
functions is more portable.

Suggested patch below. With that, all warnings are gone.

In additon, I would change all CONST's to const's, as
tclsqlite.c already uses "const" in may places, and
Tcl doesn't support C-compilers without the "const"
keyword anyway.

Regards,
          Jan Nijtmans

Index: src/tclsqlite.c
==================================================================
--- src/tclsqlite.c
+++ src/tclsqlite.c
@@ -871,11 +871,11 @@
   const char *zArg1,
   const char *zArg2,
   const char *zArg3,
   const char *zArg4
 ){
-  char *zCode;
+  const char *zCode;
   Tcl_DString str;
   int rc;
   const char *zReply;
   SqliteDb *pDb = (SqliteDb*)pArg;
   if( pDb->disableAuth ) return SQLITE_OK;
@@ -997,11 +997,11 @@
 static int DbTransPostCmd(
   ClientData data[],                   /* data[0] is the Sqlite3Db* for $db */
   Tcl_Interp *interp,                  /* Tcl interpreter */
   int result                           /* Result of evaluating SCRIPT */
 ){
-  static const char *azEnd[] = {
+  static const char *const azEnd[] = {
     "RELEASE _tcl_transaction",        /* rc==TCL_ERROR, nTransaction!=0 */
     "COMMIT",                          /* rc!=TCL_ERROR, nTransaction==0 */
     "ROLLBACK TO _tcl_transaction ; RELEASE _tcl_transaction",
     "ROLLBACK"                         /* rc==TCL_ERROR, nTransaction==0 */
   };
@@ -1935,11 +1935,11 @@
     }else if( objc==2 ){
       if( pDb->zCommit ){
         Tcl_AppendResult(interp, pDb->zCommit, 0);
       }
     }else{
-      char *zCommit;
+      const char *zCommit;
       int len;
       if( pDb->zCommit ){
         Tcl_Free(pDb->zCommit);
       }
       zCommit = Tcl_GetStringFromObj(objv[2], &len);
@@ -2008,18 +2008,18 @@
     int nSep;                   /* Number of bytes in zSep[] */
     int nNull;                  /* Number of bytes in zNull[] */
     char *zSql;                 /* An SQL statement */
     char *zLine;                /* A single line of input from the file */
     char **azCol;               /* zLine[] broken up into columns */
-    char *zCommit;              /* How to commit changes */
+    const char *zCommit;        /* How to commit changes */
     FILE *in;                   /* The input file */
     int lineno = 0;             /* Line number of input file */
     char zLineNum[80];          /* Line number print buffer */
     Tcl_Obj *pResult;           /* interp result */

-    char *zSep;
-    char *zNull;
+    const char *zSep;
+    const char *zNull;
     if( objc<5 || objc>7 ){
       Tcl_WrongNumArgs(interp, 2, objv,
          "CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?");
       return TCL_ERROR;
     }
@@ -2933,11 +2933,11 @@
 #endif

   if( objc==2 ){
     zArg = Tcl_GetStringFromObj(objv[1], 0);
     if( strcmp(zArg,"-version")==0 ){
-      Tcl_AppendResult(interp,sqlite3_version,0);
+      Tcl_AppendResult(interp,sqlite3_libversion(),0);
       return TCL_OK;
     }
     if( strcmp(zArg,"-has-codec")==0 ){
 #ifdef SQLITE_HAS_CODEC
       Tcl_AppendResult(interp,"1",0);
@@ -3015,11 +3015,11 @@
     return TCL_ERROR;
   }
   zErrMsg = 0;
   p = (SqliteDb*)Tcl_Alloc( sizeof(*p) );
   if( p==0 ){
-    Tcl_SetResult(interp, "malloc failed", TCL_STATIC);
+    Tcl_SetResult(interp, (char *)"malloc failed", TCL_STATIC);
     return TCL_ERROR;
   }
   memset(p, 0, sizeof(*p));
   zFile = Tcl_GetStringFromObj(objv[2], 0);
   zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename);
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to