Hi,
In sqlite3.c, I see that most of the times, but not always, all
members of the sqlite3_module struct are initialized:
static const sqlite3_module fts5Vocab = ...
static const sqlite3_module fts3Module = ...
static const sqlite3_module pragmaVtabModule = ...
...
0, /* xRename - rename the table */
0, /* xSavepoint */
0, /* xRelease */
0 /* xRollbackTo */
};
But at some places, and also in shell.c and foci.c, the last 3 members
are not initialized.
static sqlite3_module stmtModule = {
...
0, /* xRename */
};
The code says:
/* The methods above are in version 1 of the sqlite_module object. Those
** below are for version 2 and greater. */
int (*xSavepoint)(sqlite3_vtab *pVTab, int);
int (*xRelease)(sqlite3_vtab *pVTab, int);
int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
Is this why these last three members are left uninitialized on
purpose, or is it irrelevant if they are initialized or not?
Just in case they *should* be initialized, a patch is attached (and
included at the end of this mail, just in case the attachment is
scrubbed).
How I reproduced the warnings:
auto.def:
define EXTRA_CFLAGS "-Wmissing-field-initializers"
./configure
make
./src/db.c:125:1: warning: missing initializer for field ‘aHook’ of
‘struct DbLocalData’ [-Wmissing-field-initializers]
./src/foci.c:269:3: warning: missing initializer for field
‘xSavepoint’ of ‘sqlite3_module {aka struct sqlite3_module}’
[-Wmissing-field-initializers]
./src/sqlite3.c:175743:3: warning: missing initializer for field
‘xSavepoint’ of ‘sqlite3_module {aka struct sqlite3_module}’
[-Wmissing-field-initializers]
./src/sqlite3.c:204225:1: warning: missing initializer for field
‘xSavepoint’ of ‘sqlite3_module {aka struct sqlite3_module}’
[-Wmissing-field-initializers]
./src/shell.c:2114:1: warning: missing initializer for field
‘xSavepoint’ of ‘sqlite3_module {aka struct sqlite3_module}’
[-Wmissing-field-initializers]
Best Regards,
Johan
Index: src/db.c
==================================================================
--- src/db.c
+++ src/db.c
@@ -120,11 +120,11 @@
} aHook[5];
char *azDeleteOnFail[3]; /* Files to delete on a failure */
char *azBeforeCommit[5]; /* Commands to run prior to COMMIT */
int nBeforeCommit; /* Number of entries in azBeforeCommit */
int nPriorChanges; /* sqlite3_total_changes() at transaction start */
-} db = {0, 0, 0, 0, 0, 0, };
+} db = {0};
/*
** Arrange for the given file to be deleted on a failure.
*/
void db_delete_on_failure(const char *zFilename){
Index: src/foci.c
==================================================================
--- src/foci.c
+++ src/foci.c
@@ -264,9 +264,12 @@
0, /* xSync */
0, /* xCommit */
0, /* xRollback */
0, /* xFindMethod */
0, /* xRename */
+ 0, /* xSavepoint */
+ 0, /* xRelease */
+ 0 /* xRollbackTo */
};
sqlite3_create_module(db, "files_of_checkin", &foci_module, 0);
return SQLITE_OK;
}
Index: src/shell.c
==================================================================
--- src/shell.c
+++ src/shell.c
@@ -2109,10 +2109,13 @@
0, /* xSync */
0, /* xCommit */
0, /* xRollback */
0, /* xFindMethod */
0, /* xRename */
+ 0, /* xSavepoint */
+ 0, /* xRelease */
+ 0 /* xRollbackTo */
};
#endif /* SQLITE_OMIT_VIRTUALTABLE */
int sqlite3CompletionVtabInit(sqlite3 *db){
Index: src/sqlite3.c
==================================================================
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -175738,10 +175738,13 @@
0, /* xSync */
0, /* xCommit */
0, /* xRollback */
0, /* xFindMethod */
0, /* xRename */
+ 0, /* xSavepoint */
+ 0, /* xRelease */
+ 0 /* xRollbackTo */
};
return sqlite3_create_module(db, "dbstat", &dbstat_module, 0);
}
#elif defined(SQLITE_ENABLE_DBSTAT_VTAB)
SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; }
@@ -204220,10 +204223,13 @@
0, /* xSync */
0, /* xCommit */
0, /* xRollback */
0, /* xFindMethod */
0, /* xRename */
+ 0, /* xSavepoint */
+ 0, /* xRelease */
+ 0 /* xRollbackTo */
};
#endif /* SQLITE_OMIT_VIRTUALTABLE */
SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){
_______________________________________________
fossil-dev mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/fossil-dev