public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/master-posix_clock] Fix build warnings in resolv/res_send.c Date: Tue, 02 Jul 2019 17:26:00 -0000 [thread overview] Message-ID: <20190702172611.34113.qmail@sourceware.org> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3221 bytes --] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d1bc2cbbed9aea2017ef941f63c8786571da5b4f commit d1bc2cbbed9aea2017ef941f63c8786571da5b4f Author: Stefan Liebler <stli@linux.ibm.com> Date: Tue Jul 2 14:07:44 2019 +0200 Fix build warnings in resolv/res_send.c This patch fixes the gcc warnings seen with gcc 9 -march>=z13 on s390x: res_send.c: In function â__res_context_sendâ: res_send.c:498:7: error: âresplenâ may be used uninitialized in this function [-Werror=maybe-uninitialized] 498 | if (n == 0 && (buf2 == NULL || *resplen2 == 0)) | ^ In this case send_vc is inlined into __res_context_send and the maybe uninitialized resplen belongs to the one in send_vc. In send_vc there is already a DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized") and a comment which explains that this is a false-positive. Note that resplen is used as return value. This patch adds a further DIAG_IGNORE_NEEDS_COMMENT around the declaration of n in __res_context_send and the comparison after n was set to the return value of send_vc. ChangeLog: * resolv/res_send.c (__res_context_send): Disable maybe-uninitialized warning. Diff: --- ChangeLog | 5 +++++ resolv/res_send.c | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0c7bdd0..3e4d87f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-07-02 Stefan Liebler <stli@linux.ibm.com> + + * resolv/res_send.c (__res_context_send): Disable maybe-uninitialized + warning. + 2019-07-01 Florian Weimer <fweimer@redhat.com> * scripts/build-many-glibcs.py (Context.add_all_configs): Add v4t diff --git a/resolv/res_send.c b/resolv/res_send.c index eeeb8ac..ed27f3a 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -401,7 +401,18 @@ __res_context_send (struct resolv_context *ctx, int *nansp2, int *resplen2, int *ansp2_malloced) { struct __res_state *statp = ctx->resp; - int gotsomewhere, terrno, try, v_circuit, resplen, n; + int gotsomewhere, terrno, try, v_circuit, resplen; + /* On some architectures send_vc is inlined and the compiler might emit + a warning indicating 'resplen' may be used uninitialized. Note that + the warning belongs to resplen in send_vc which is used as return + value! There the maybe-uninitialized warning is already ignored as + it is a false-positive - see comment in send_vc. + Here the variable n is set to the return value of send_vc. + See below. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (9, "-Wmaybe-uninitialized"); + int n; + DIAG_POP_NEEDS_COMMENT; if (statp->nscount == 0) { __set_errno (ESRCH); @@ -495,8 +506,12 @@ __res_context_send (struct resolv_context *ctx, ansp2_malloced); if (n < 0) return (-1); + /* See comment at the declaration of n. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (9, "-Wmaybe-uninitialized"); if (n == 0 && (buf2 == NULL || *resplen2 == 0)) goto next_ns; + DIAG_POP_NEEDS_COMMENT; } else { /* Use datagrams. */ n = send_dg(statp, buf, buflen, buf2, buflen2,
reply other threads:[~2019-07-02 17:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190702172611.34113.qmail@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).