git: 5d64055eaaf2 - stable/14 - netmap: silence -Wdefault-const-init-field-unsafe warning
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 May 2026 21:46:38 UTC
The branch stable/14 has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=5d64055eaaf259ccb72a785bf5c2297e87dfa103
commit 5d64055eaaf259ccb72a785bf5c2297e87dfa103
Author: Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2025-12-16 18:09:57 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-05-27 21:41:14 +0000
netmap: silence -Wdefault-const-init-field-unsafe warning
The netmap_ring struct starts with various const members and rencent
clang warns about leaving them uninitialized. Having them const in the
first place is highly suspicious since they are updated with various
macros but using hand-coded __DECONST(). But fixing that is a more
invasive change that I am unable to test.
```
.../freebsd/sys/dev/netmap/netmap_kloop.c:320:21: error: default initialization of an object of type 'struct netmap_ring' with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
320 | struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */
| ^
.../freebsd/sys/net/netmap.h:290:16: note: member 'buf_ofs' declared 'const' here
290 | const int64_t buf_ofs;
| ^
```
Test Plan: Compiles
Reviewed by: vmaffione, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D52568
(cherry picked from commit 2ed21f90906b230476d3f12ff9dce0e2c4642af2)
---
sys/dev/netmap/netmap_kloop.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sys/dev/netmap/netmap_kloop.c b/sys/dev/netmap/netmap_kloop.c
index 005b9af2a3da..65c4fd89e0d5 100644
--- a/sys/dev/netmap/netmap_kloop.c
+++ b/sys/dev/netmap/netmap_kloop.c
@@ -161,7 +161,8 @@ netmap_sync_kloop_tx_ring(const struct sync_kloop_ring_args *a)
struct netmap_kring *kring = a->kring;
struct nm_csb_atok *csb_atok = a->csb_atok;
struct nm_csb_ktoa *csb_ktoa = a->csb_ktoa;
- struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */
+ /* shadow copy of the netmap_ring */
+ struct netmap_ring shadow_ring = {0};
#ifdef SYNC_KLOOP_POLL
bool more_txspace = false;
#endif /* SYNC_KLOOP_POLL */
@@ -317,7 +318,8 @@ netmap_sync_kloop_rx_ring(const struct sync_kloop_ring_args *a)
struct netmap_kring *kring = a->kring;
struct nm_csb_atok *csb_atok = a->csb_atok;
struct nm_csb_ktoa *csb_ktoa = a->csb_ktoa;
- struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */
+ /* shadow copy of the netmap_ring */
+ struct netmap_ring shadow_ring = {0};
int dry_cycles = 0;
#ifdef SYNC_KLOOP_POLL
bool some_recvd = false;