SQLite Forum

Missing static keyword for some private functions
Login

Missing static keyword for some private functions

(1) By Arfrever Frehtes Taifersar Arahesis (Arfrever) on 2021-11-30 16:04:21 [source]

When reviewing symbols in library, I noticed some symbols which should have been private, but are not due to missing static keyword in source code:

  • idxFindIndexes in ext/expert/sqlite3expert.c
  • SHA1Transform in ext/misc/sha1.c
  • rbuVacuumIndexStart in ext/rbu/sqlite3rbu.c
  • zipfileFinal in ext/misc/zipfile.c
  • zipfileStep in ext/misc/zipfile.c

(2) By Arfrever Frehtes Taifersar Arahesis (Arfrever) on 2021-11-30 21:08:28 in reply to 1 [link] [source]

Another copy of SHA1Transform() function is also in tool/dbhash.c and it can be fixed too.

Full patch for convenience:

--- ext/expert/sqlite3expert.c
+++ ext/expert/sqlite3expert.c
@@ -1168,7 +1168,7 @@
 ** runs all the queries to see which indexes they prefer, and populates
 ** IdxStatement.zIdx and IdxStatement.zEQP with the results.
 */
-int idxFindIndexes(
+static int idxFindIndexes(
   sqlite3expert *p,
   char **pzErr                         /* OUT: Error message (sqlite3_malloc) */
 ){
--- ext/misc/sha1.c
+++ ext/misc/sha1.c
@@ -71,7 +71,7 @@
 /*
  * Hash a single 512-bit block. This is the core of the algorithm.
  */
-void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){
+static void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){
   unsigned int qq[5]; /* a, b, c, d, e; */
   static int one = 1;
   unsigned int block[16];
--- ext/misc/zipfile.c
+++ ext/misc/zipfile.c
@@ -1938,7 +1938,7 @@
 **   SELECT zipfile(name,mode,mtime,data) ...
 **   SELECT zipfile(name,mode,mtime,data,method) ...
 */
-void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
+static void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
   ZipfileCtx *p;                  /* Aggregate function context */
   ZipfileEntry e;                 /* New entry to add to zip archive */
 
@@ -2113,7 +2113,7 @@
 /*
 ** xFinalize() callback for zipfile aggregate function.
 */
-void zipfileFinal(sqlite3_context *pCtx){
+static void zipfileFinal(sqlite3_context *pCtx){
   ZipfileCtx *p;
   ZipfileEOCD eocd;
   sqlite3_int64 nZip;
--- ext/rbu/sqlite3rbu.c
+++ ext/rbu/sqlite3rbu.c
@@ -1563,7 +1563,7 @@
 ** the caller has to use an OFFSET clause to extract only the required 
 ** rows from the sourct table, just as it does for an RBU update operation.
 */
-char *rbuVacuumIndexStart(
+static char *rbuVacuumIndexStart(
   sqlite3rbu *p,                  /* RBU handle */
   RbuObjIter *pIter               /* RBU iterator object */
 ){
--- tool/dbhash.c
+++ tool/dbhash.c
@@ -100,7 +100,7 @@
 #define d qq[3]
 #define e qq[4]
 
-void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){
+static void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){
   unsigned int qq[5]; /* a, b, c, d, e; */
   static int one = 1;
   unsigned int block[16];

(3) By Arfrever Frehtes Taifersar Arahesis (Arfrever) on 2021-12-02 17:53:30 in reply to 1 [link] [source]

These changes (except change in tool/dbhash.c) were applied in revision 8c98678254721109.