From 93fe09cb5fbf68e473d5514adc069d2f6115cc23 Mon Sep 17 00:00:00 2001 From: Carlos O'Donell Date: Sat, 29 Oct 2016 23:45:40 -0400 Subject: Bug 20729: Fix building with -Os. This commit adds a new DIAG_IGNORE_Os_NEEDS_COMMENT which is only enabled when compiling with -Os. This allows developers working on -Os enabled builds to mark false-positive warnings without impacting the warnings emitted at -O2. Then using the new DIAG_IGNORE_Os_NEEDS_COMMENT we fix 6 warnings generated with GCC 5 to get -Os builds working again. --- resolv/res_send.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'resolv/res_send.c') diff --git a/resolv/res_send.c b/resolv/res_send.c index 6d46bb2c15..4ec8c1a16d 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -664,7 +664,7 @@ send_vc(res_state statp, a false-positive. */ DIAG_PUSH_NEEDS_COMMENT; - DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized"); + DIAG_IGNORE_Os_NEEDS_COMMENT (5, "-Wmaybe-uninitialized"); int resplen; DIAG_POP_NEEDS_COMMENT; struct iovec iov[4]; @@ -930,7 +930,16 @@ reopen (res_state statp, int *terrno, int ns) * error message is received. We can thus detect * the absence of a nameserver without timing out. */ + /* With GCC 5.3 when compiling with -Os the compiler + emits a warning that slen may be used uninitialized, + but that is never true. Both slen and + EXT(statp).nssocks[ns] are initialized together or + the function return -1 before control flow reaches + the call to connect with slen. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized"); if (connect(EXT(statp).nssocks[ns], nsap, slen) < 0) { + DIAG_POP_NEEDS_COMMENT; Aerror(statp, stderr, "connect(dg)", errno, nsap); __res_iclose(statp, false); return (0); -- cgit 1.4.1