Skip to content

Commit 71ae6c7

Browse files
committed
netmap: silence -Wdefault-const-init-field-unsafe warning
Summary: 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 Reviewers: vmaffione, jhb Subscribers: imp Differential Revision: https://reviews.freebsd.org/D52568
1 parent 4394bb8 commit 71ae6c7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sys/dev/netmap/netmap_kloop.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ netmap_sync_kloop_tx_ring(const struct sync_kloop_ring_args *a)
161161
struct netmap_kring *kring = a->kring;
162162
struct nm_csb_atok *csb_atok = a->csb_atok;
163163
struct nm_csb_ktoa *csb_ktoa = a->csb_ktoa;
164-
struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */
164+
/* shadow copy of the netmap_ring */
165+
struct netmap_ring shadow_ring = {0};
165166
#ifdef SYNC_KLOOP_POLL
166167
bool more_txspace = false;
167168
#endif /* SYNC_KLOOP_POLL */
@@ -317,7 +318,8 @@ netmap_sync_kloop_rx_ring(const struct sync_kloop_ring_args *a)
317318
struct netmap_kring *kring = a->kring;
318319
struct nm_csb_atok *csb_atok = a->csb_atok;
319320
struct nm_csb_ktoa *csb_ktoa = a->csb_ktoa;
320-
struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */
321+
/* shadow copy of the netmap_ring */
322+
struct netmap_ring shadow_ring = {0};
321323
int dry_cycles = 0;
322324
#ifdef SYNC_KLOOP_POLL
323325
bool some_recvd = false;

0 commit comments

Comments
 (0)