Skip to content

fix: clean compiler warnings without redundant initialization - #321

Merged
thweetkomputer merged 2 commits into
mainfrom
fix/compiler-warnings
Oct 13, 2026
Merged

thweetkomputer merged 2 commits into
mainfrom
fix/compiler-warnings

Conversation

@thweetkomputer

@thweetkomputer thweetkomputer commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Context

GCC Release and Clang Debug builds report repeated aggregate-initialization, borrowed-view, unused-value, and range-check warnings. Clean up these diagnostics while preserving intentionally uninitialized storage and avoiding extra writes on command paths.

Uses merged eloqdata/bycorf#14 at 8caaf75cb131b591922af51a19861f92e2ffc893. This mainline pin also includes the previously merged direct BSD-to-DPDK packet-copy optimization in eloqdata/bycorf#12.

Behavior before and after

The checked Linux ARM64 GCC 13 Release and Clang 18 Debug builds now complete with zero compiler warnings. Command replies, recovery formats, and notification failure behavior remain unchanged. GCC's existing LTO ABI compatibility note remains.

Implementation

  • Make existing empty optional/container states explicit. Use call-site aggregate initializers for CompactValueUpdate and StreamGroupSummary where GCC otherwise introduces redundant stores.
  • Construct only the selected recovery metadata union alternative and initialize known score bounds directly.
  • Remove unused digest/owner fields from SortExecKey; retain its argument/name selection contract.
  • Name borrowed group views before binding element references, avoid structured-binding copies, and mark assertion/fault-only parameters as intentionally unused.
  • Preserve overflow checks with explicit size_t operands, remove unnecessary constexpr captures, and explicitly discard results in exception/death tests.
  • Update Bycorf for the fortified read() diagnostic, keeping the output-only counter uninitialized with a nearby explanation.

Design decisions and alternatives

No warning categories are disabled. Empty C++ object state remains initialized where callers rely on it; unused raw output storage stays uninitialized. Optimized assembly checks for seven representative aggregate constructions showed identical instructions under Clang; GCC was identical in six cases and removed stores in StreamTrimResult. The Bycorf notification-drain warning fix generates identical optimized instructions; the separately merged transmit-copy optimization is outside that comparison. These are code-generation checks, not throughput benchmarks.

Documentation and comments

Added comments explaining the no-initialization case, aggregate initialization/code-generation choice, selected recovery union member, and SORT key contract. No architectural claim, module boundary, durable format, or lifecycle changes, so architecture documentation is unchanged.

Test plan

All checks ran on Linux ARM64. Both build directories had LAVIK_ENABLE_WERROR=ON and LAVIK_KERNEL_BYPASS=OFF; build uses GCC 13 Release with optimization, and build_ci uses Clang 18 Debug with fault injection.

cmake --build build --target lavik lavik-meta lavik-ctl --parallel 4
cmake --build build_ci --parallel 4
python3 tests/runtime_backends_smoke.py build/lavik --expect-no-bypass
ctest --test-dir build_ci -R '^(meta\.MetaAuditStore\.|RedisConfigTest\.|CowArray(Test|DeathTest)\.|HashGroupEdits\.|Grouped(Hash|Collection|SortedRewrite|OrderedObject|ObjectIndex)Test\.|CollectionCompactStream\.|Stream(PageMaxKey|Directory)Test\.|ListRingTest\.|Rdb(Test|CollectionTest|CollectionImportTest)\.|lavik_(version|runtime_backends|stream_records|rdb_backup_e2e)$|meta_integration\.gate_managed_sort$)' --output-on-failure --parallel 1

Builds and Release runtime smoke passed. The CTest selection passed 257/258 tests; the SORT gate stopped at its prerequisite check because the system Redis was 7.0.15. Installed the repository-pinned peer and reran that gate successfully in both Single and Cluster modes:

LAVIK_TEST_BUILD_JOBS=4 scripts/install_test_redis.sh /tmp/lavik-warning-test-redis
python3 tests/meta_integration/gate_managed_sort_save.py build_ci/lavik-meta build_ci/lavik build_ci/lavik-ctl /tmp/lavik-warning-test-redis/redis-cli /tmp/lavik-warning-test-redis/redis-server

Additional focused integration coverage passed (4 recovery cases and 10 ordered-collection cases):

GTEST_FILTER='GroupedRecoveryE2e.ManyInlineOrderedRootsRecoverOnSmallStack:GroupedRecoveryE2e.IndexedSortedSetRequiresAndChecksMemberGraph:GroupedRecoveryE2e.CheckpointRestoresAllGroupedTypesWithIndirectKeys:GroupedRecoveryE2e.OrderedRetirementSkipsFreedObsoletePageExtents' ctest --test-dir build_ci -R '^lavik_grouped_recovery_e2e$' --output-on-failure
GTEST_FILTER='GroupedListWriteE2e.RangeReadsFitReplyBudgetAndKeepRankOrder:GroupedListWriteE2e.RangeReadFailureJoinsStartedPages:GroupedDemotionE2e.StringListSetSortedSetGeoAndStreamRecoverCompact:GroupedOrderedWriteE2e.ListReadIntervalsAcrossPagesAndRecovery:GroupedStreamE2e.SmallStreamKeepsCompactStorage:GroupedStreamE2e.DeleteRoutesIdsAndPreservesPendingAndNodeBoundaries:GroupedStreamE2e.EmptyStreamRetainsGroupsAndPendingAcrossRecovery:GroupedStreamE2e.RewoundNoAckAndForceClaimPreserveUnloadedPending:GroupedSortedSetWriteE2e.RandomAndRangeRemovalPreserveSemantics:GroupedSortedSetWriteE2e.GeoPointReadsPreserveRepliesAndExecVisibility' ctest --test-dir build_ci -R '^lavik_grouped_ordered_write_e2e$' --output-on-failure
pre-commit run
git diff --cached --check

The DPDK translation unit also passed GCC 13 and Clang 18 syntax checks with _FORTIFY_SOURCE=3 and -Werror, including at the merged Bycorf pin; details of the original warning check are in the dependency PR.

At the final merged pin, both Lavik builds and the Release runtime smoke were checked again. The existing bypass-enabled Bycorf build also passed with zero warnings, followed by local-connect and TCP-sequence regression checks:

cmake --build /tmp/bycorf-direct-frame-build --target bycorf bycorf_freebsd_port_check bycorf_freebsd_local_connect_check bycorf_freebsd_tcp_sequence_check --parallel 4
ctest --test-dir /tmp/bycorf-direct-frame-build -R '^bycorf_freebsd_local_connect_check$' --output-on-failure
/tmp/bycorf-direct-frame-build/bycorf_freebsd_tcp_sequence_check

Risk assessment

The main review points are recovery union selection and preserving SORT's EXEC/script key selection. Focused recovery and managed SORT tests cover both. Full x86_64 CI and hardware DPDK/SPDK execution were not run locally.

Rollback plan

Revert this PR, including the Bycorf gitlink.

Reviewer guide

Start with src/storage/engine/recovery.cpp, src/redis/sort_command.h, and include/lavik/storage/engine.h; the remaining changes make initialization/discard intent explicit or remove warning-producing expression forms.

Follow-up work

The Bycorf dependency is merged and the submodule pin references its mainline commit. No dependency follow-up remains.

Summary by CodeRabbit

  • Bug Fixes
    • Improved safety when handling large storage and configuration values.
    • Fixed lifetime handling during grouped storage reads and rewrites.
    • Ensured empty pages have valid metadata during recovery.
  • Code Quality
    • Made default and empty states explicit across storage and stream operations, with no intended change to existing behavior.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ef04887-09e9-48a6-bfad-4c2564fbc83a
📥 Commits

Reviewing files that changed from the base of the PR and between 3d6141b and b965d6f.

📒 Files selected for processing (20)
  • app/lavik.cpp
  • bycorf
  • include/lavik/storage/detail/grouped/hash.h
  • include/lavik/storage/engine.h
  • src/config.cpp
  • src/redis/backup.cpp
  • src/redis/command.cpp
  • src/redis/rdb_record_spool.h
  • src/redis/sort_command.h
  • src/redis/stream_command.cpp
  • src/redis/string_command.cpp
  • src/redis/zset_command.cpp
  • src/replication/redis_export.cpp
  • src/storage/engine/compact_api.cpp
  • src/storage/engine/grouped/list.cpp
  • src/storage/engine/grouped/stream.cpp
  • src/storage/engine/grouped/zset.cpp
  • src/storage/engine/recovery.cpp
  • tests/containers/cow_array_test.cpp
  • tests/meta_journal_test.cpp
 ____________________________________
< My Motto: Semper Bug Exterminatus. >
 ------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thweetkomputer
thweetkomputer merged commit 6508dc1 into main Oct 13, 2026
5 of 6 checks passed
@thweetkomputer
thweetkomputer deleted the fix/compiler-warnings branch October 13, 2026 07:16
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.

1 participant