]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: peers: fix build warning with gcc 4.2.1
authorWilly Tarreau <w@1wt.eu>
Fri, 3 Jul 2020 17:09:29 +0000 (19:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Jul 2020 17:09:29 +0000 (19:09 +0200)
Building on OpenBSD 6.7 with gcc-4.2.1 yields the following warnings
which suggest that the initialization is not taken as expected but
that the container member is reset with each initialization:

  src/peers.c: In function 'peer_send_updatemsg':
  src/peers.c:1000: warning: initialized field overwritten
  src/peers.c:1000: warning: (near initialization for 'p.updt')
  src/peers.c:1001: warning: initialized field overwritten
  src/peers.c:1001: warning: (near initialization for 'p.updt')
  src/peers.c:1002: warning: initialized field overwritten
  src/peers.c:1002: warning: (near initialization for 'p.updt')
  src/peers.c:1003: warning: initialized field overwritten
  src/peers.c:1003: warning: (near initialization for 'p.updt')
  src/peers.c:1004: warning: initialized field overwritten
  src/peers.c:1004: warning: (near initialization for 'p.updt')

Fixing this is trivial, we just have to initialize one level at
a time.

src/peers.c

index f16ba8e7e7b7b9ee8fe5468cc595c75e253fdd1a..47582e452b575a407956822e3fc6b1f5220bc954 100644 (file)
@@ -995,12 +995,14 @@ static inline int peer_send_updatemsg(struct shared_table *st, struct appctx *ap
                                       unsigned int updateid, int use_identifier, int use_timed)
 {
        struct peer_prep_params p = {
-               .updt.stksess = ts,
-               .updt.shared_table = st,
-               .updt.updateid = updateid,
-               .updt.use_identifier = use_identifier,
-               .updt.use_timed = use_timed,
-               .updt.peer = appctx->ctx.peers.ptr,
+               .updt = {
+                       .stksess = ts,
+                       .shared_table = st,
+                       .updateid = updateid,
+                       .use_identifier = use_identifier,
+                       .use_timed = use_timed,
+                       .peer = appctx->ctx.peers.ptr,
+               },
        };
 
        return peer_send_msg(appctx, peer_prepare_updatemsg, &p);