]> git.feebdaed.xyz Git - 0xmirror/ovs.git/commit
configure: Disable clang 21 warning for uninitialized const fields.
authorIlya Maximets <i.maximets@ovn.org>
Fri, 17 Oct 2025 17:11:07 +0000 (19:11 +0200)
committerIlya Maximets <i.maximets@ovn.org>
Fri, 24 Oct 2025 12:55:45 +0000 (14:55 +0200)
commit28ec95972aeb12c46f416c8b1303daae4402e239
treef36e57a1fb1e7efe35aecfaa7c58b92012007bd8
parent77203b4551e616603441ed9f4f7a191de3d6932e
configure: Disable clang 21 warning for uninitialized const fields.

'default-const-init-field-unsafe' warning complains about allocating
structures on stack if they have any const fields.  We use this for
classifier rules that are embedded into many other structures:

  ofproto/ofproto.c:4980:26:
    error: default initialization of an object of type
    'struct rule_criteria' with const member leaves the
    object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
   4980 |     struct rule_criteria criteria;
        |                          ^
  ./lib/classifier.h:356:15:
    note: member 'priority' declared 'const' here
    356 |     const int priority;
        |               ^

Priority is marked as const as it is not supposed to be changed after
the rule creation, as that would break the classifier logic.  Any code
that changes the value is clearly seen, as it requires the explicit
CONST_CAST.  Initialization functions are the only places where this is
happening.  And these functions are always called for all the instances
allocated on stack, but clang fails to recognize this.

I believe, described code pattern is useful, so it's better to turn
off the warning instead of making the field non-const.  Alternative
would be to use an explicit initializer for every stack allocation
to silence the warning, but it feels like a bit too much.

Acked-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
configure.ac