Skip to content

Mark the init functions' pApi unused under SQLITE_CORE - #9

Closed
MayCXC wants to merge 1 commit into
photostructure:mainfrom
MayCXC:core-unused-api-photostructure
Closed

MayCXC wants to merge 1 commit into
photostructure:mainfrom
MayCXC:core-unused-api-photostructure

Conversation

@MayCXC

@MayCXC MayCXC commented Oct 23, 2026 •

Copy link
Copy Markdown

Compiled with -DSQLITE_CORE, as when sqlite-vec.c is built into SQLite or into an application, sqlite3_vec_init(), sqlite3_vec_numpy_init() and sqlite3_vec_static_blobs_init() never read their pApi parameter: SQLITE_EXTENSION_INIT2() is its only use, and SQLITE_CORE leaves it out. A project that compiles the file into its own binary with -Wall -Wextra gets three warnings from main, with gcc 14.2 and with clang 19.1:

$ ./scripts/vendor.sh
$ gcc -Ivendor -Wall -Wextra -DSQLITE_CORE -DSQLITE_VEC_STATIC -c sqlite-vec.c -o vec.o
sqlite-vec.c:12525:65: warning: unused parameter 'pApi' [-Wunused-parameter]
sqlite-vec.c:12610:71: warning: unused parameter 'pApi' [-Wunused-parameter]
sqlite-vec.c:12629:59: warning: unused parameter 'pApi' [-Wunused-parameter]

(gcc's source excerpts under each warning are trimmed.) The Makefile's static target compiles without -Wall -Wextra, so the project's own builds do not print them.

Each function now marks pApi with UNUSED_PARAMETER() in the SQLITE_CORE case, as sqlite3_vec_numpy_init() and sqlite3_vec_static_blobs_init() already do for pzErrMsg. The commit adds a ### Fixed entry under [Unreleased] in CHANGELOG.md, at the head of the list, where it merges cleanly with main at a791836 and with #4, #7, #8, #11 and #12.

Test. The command above prints the three warnings on main and none on this branch, with either compiler. UNUSED_PARAMETER() is a (void) cast, so the object files are byte-identical before and after, both for the loadable extension and with -DSQLITE_CORE. make test-loadable (449 passed, 3 skipped) and make test-unit pass.

The same change is open on vlasky/sqlite-vec as vlasky#23, and on asg017/sqlite-vec as asg017#341, where only sqlite3_vec_init() remains of the three.

…CORE

Compiled with -DSQLITE_CORE, as when sqlite-vec.c is built into SQLite or
an application, sqlite3_vec_init(), sqlite3_vec_numpy_init() and
sqlite3_vec_static_blobs_init() never read their pApi parameter, since
SQLITE_EXTENSION_INIT2() is its only use and SQLITE_CORE leaves it out. With
-Wall -Wextra each of them warns:

    gcc -Ivendor -Wall -Wextra -DSQLITE_CORE -DSQLITE_VEC_STATIC \
        -c sqlite-vec.c -o vec.o

    sqlite-vec.c:12525:65: warning: unused parameter 'pApi'
    sqlite-vec.c:12610:71: warning: unused parameter 'pApi'
    sqlite-vec.c:12629:59: warning: unused parameter 'pApi'

Each now marks it with UNUSED_PARAMETER() in that case, as two of them do
for pzErrMsg. The command prints no warning with gcc 14.2 or clang 19.1, and
the loadable extension, built without SQLITE_CORE, is unchanged.
@mceachen

Copy link
Copy Markdown
Member

Landed as 20cea6b, thanks. Follow-up 0fbb507 limits the CHANGELOG entry to the pApi warning: gcc -O3 still reports eight -Wmaybe-uninitialized warnings in -DSQLITE_CORE builds.

@mceachen mceachen closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants