Repository navigation
mdbx: preserve debug callback types across cgo - #265
Merged
AskAlexSharov merged 1 commit intoNov 9, 2026
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the changes preserving C callback types across the cgo boundary.
No open issues 🎉
What changed in this PR
Addresses #264 by preserving C callback types across the cgo boundary, avoiding function-pointer conversion warnings while keeping the public Go API and logger behavior unchanged.
Changes:
- Adds typed C wrappers for debug callbacks and the keep-current sentinel.
- Removes two compiler-specific warning flags while retaining
-Wpedantic. - Adds subprocess regression coverage for custom callbacks, the keep-current sentinel, and nil loggers.
| File | Description |
|---|---|
mdbx/testdata/debuglogger/main.go |
Adds an isolated program checking all three logger behaviors. |
mdbx/mdbxgo.h |
Declares the callback struct and typed bridge functions. |
mdbx/mdbxgo.c |
Implements wrappers that preserve C function-pointer types. |
mdbx/mdbx.go |
Removes two compiler-specific warning flags. |
mdbx/env.go |
Routes logger configuration through the typed wrappers. |
mdbx/env_test.go |
Runs the logger regression program in a subprocess. |
Review effort: Balanced
AskAlexSharov
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #264.
GCC reports
-Wpedanticwarnings because cgo represents direct function-pointer arguments/results asvoid *in its generated C bridge. This affects bothMDBX_LOGGER_DONTCHANGEand the logger argument tomdbx_setup_debug.This change carries
MDBX_debug_funcin a small typed C struct passed and returned by value. The C wrappers forward the original callback without function-pointer/object-pointer casts.LoggerDoNotChangekeeps its Go type, andEnv.SetDebugkeeps its public signature and existing return behavior. Storage and transaction code are unchanged.The two compiler-specific flags
-Wno-unknown-warning-optionand-Wno-enum-int-mismatchare removed from the Go binding CFLAGS.-Wpedanticremains enabled; no warning suppression is added.A subprocess regression test checks a real C callback, the keep-current sentinel, and a nil logger. Isolation is needed because libmdbx logger configuration is process-global and cgo cannot be imported directly from a Go test file.
Validation:
-Werror=pedanticscoped to the mdbx package.go test -race -count=1 ./mdbx ./exp/mdbxpoolandgo vet ./mdbx ./exp/mdbxpoolpassed.0 issues.git diff --checkpassed.macOS and Windows have not been tested locally and still need CI coverage.
@AskAlexSharov, could you review this approach to fixing the warnings while preserving the callback API?