Skip to content

Add -Werror=c99-designator and fix brace elision warnings#15168

Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom
roberth:fix-protocol-addToStore-version-comparisons
Feb 6, 2026
Merged

Add -Werror=c99-designator and fix brace elision warnings#15168
Ericson2314 merged 1 commit intoNixOS:masterfrom
roberth:fix-protocol-addToStore-version-comparisons

Conversation

@roberth
Copy link
Member

@roberth roberth commented Feb 6, 2026

Motivation

Originally I just wanted to fix the warnings in src/libstore/remote-store.cc and src/libstore/store-api.cc, but those warnings proved more serious than it would seem on the surface.
See commit message for details.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added the store Issues and pull requests concerning the Nix store label Feb 6, 2026
@xokdvium xokdvium enabled auto-merge February 6, 2026 19:49
@xokdvium
Copy link
Contributor

xokdvium commented Feb 6, 2026

Thanks! Werror is good for maintainability too

@xokdvium xokdvium added this pull request to the merge queue Feb 6, 2026
@xokdvium
Copy link
Contributor

xokdvium commented Feb 6, 2026

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Feb 6, 2026
@xokdvium
Copy link
Contributor

xokdvium commented Feb 6, 2026

@roberth, could you rebase? Thanks
@amaanq, @Ericson2314 cc wet to the regression. I suppose that already got fixed, but Werror is still very nice to have

@Ericson2314
Copy link
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}`
@Ericson2314 Ericson2314 force-pushed the fix-protocol-addToStore-version-comparisons branch from 729faee to e5278ac Compare February 6, 2026 21:24
@Ericson2314 Ericson2314 changed the title Fix protocol add to store version comparisons Add -Werror=c99-designator and fix brace elision warnings Feb 6, 2026
@Ericson2314 Ericson2314 enabled auto-merge February 6, 2026 21:26
@Ericson2314
Copy link
Member

Rebased, combined commit messages, and force-pushed.

@roberth
Copy link
Member Author

roberth commented Feb 6, 2026

Please also review #15164 so that we exercise at least some of this code path in testing.

@Ericson2314 Ericson2314 added this pull request to the merge queue Feb 6, 2026
Merged via the queue into NixOS:master with commit ba3dc07 Feb 6, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants