Add -Werror=c99-designator and fix brace elision warnings#15168
Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom Feb 6, 2026
Merged
Conversation
xokdvium
approved these changes
Feb 6, 2026
Contributor
|
Thanks! |
Contributor
|
I suppose this will have conflicts with https://github.com/NixOS/nix/pull/15161/changes#diff-e89a2224d1d4c39bf5a2d448b7b2fac1e3e75c7e08e414ee448846266c8bfeabL202. |
Contributor
|
@roberth, could you rebase? Thanks |
Member
|
Oh yes, we just noticed this mistake independently, and did the same fix. |
The recent conversion of WorkerProto::Version from unsigned int to a
struct exposed a latent issue: `.version = 16` was being interpreted
as aggregate initialization `{.major = 16, .minor = 0}` rather than
the intended wire format value.
This commit adds -Werror=c99-designator to catch this class of bugs at
compile time. (The bug itself was fixed in
7eb23c1.)
For background:
The hardcoded version was originally the integer 16, which in the old
wire format (major << 8 | minor) meant version 0.16. However, the
version checks only compared minor versions via GET_PROTOCOL_MINOR(),
so this worked by accident.
After the Version struct conversion, the aggregate initialization
{.major = 16, .minor = 0} happened to still work because 16 > 1 in
lexicographic comparison against {1, 16}.
The correct version is {1, 16} because:
- The worker protocol uses major version 1 (all checks are {1, x})
- Version 1.16 is when ultimate/sigs/ca fields were added
- This matches the serialization check `>= {1, 16}`
729faee to
e5278ac
Compare
Ericson2314
approved these changes
Feb 6, 2026
Member
|
Rebased, combined commit messages, and force-pushed. |
Member
Author
|
Please also review #15164 so that we exercise at least some of this code path in testing. |
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.
Motivation
Originally I just wanted to fix the warnings in
src/libstore/remote-store.ccandsrc/libstore/store-api.cc, but those warnings proved more serious than it would seem on the surface.See commit message for details.
Context
{ .major = 0, .minor = 16 }(not implemented) will be caught by tests: Add Nix 1.11.16 compatibility test #15164Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.