This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] powerpc: Fix unitialized variable
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 11 Dec 2014 14:40:17 +0000
- Subject: Re: [PATCH] powerpc: Fix unitialized variable
- Authentication-results: sourceware.org; auth=none
- References: <54889AAC dot 3060404 at linux dot vnet dot ibm dot com> <alpine dot DEB dot 2 dot 10 dot 1412102119230 dot 26602 at digraph dot polyomino dot org dot uk> <5488DA58 dot 9010505 at linux dot vnet dot ibm dot com> <m6bvp4$tus$1 at ger dot gmane dot org> <mvmsigmpfku dot fsf at hawking dot suse dot de> <m6c0u2$o15$1 at ger dot gmane dot org> <54898F5B dot 2000904 at linux dot vnet dot ibm dot com> <5489925D dot 5010609 at linux dot vnet dot ibm dot com>
On Thu, 11 Dec 2014, Adhemerval Zanella wrote:
> + int truncating, connreset, n;
> + /* There is the following warning on some architectures:
> + 'resplen' may be used uninitialized in this function
> + [-Wmaybe-uninitialized]
> + This is a false positive according to:
> + https://www.sourceware.org/ml/libc-alpha/2014-12/msg00323.html
> + */
> + DIAG_PUSH_NEEDS_COMMENT;
> + DIAG_IGNORE_NEEDS_COMMENT (4.7, "-Wmaybe-uninitialized");
> + int resplen;
> + DIAG_POP_NEEDS_COMMENT;
* Do you actually need this here, or only around the use of the variable?
* An actual analysis of why the variable can't be used uninitialized would
be better than a URL. I.e., if buf2 == NULL then this code won't be
executed; if buf2 != NULL, then first time round the loop recvresp1 and
recvresp2 will be 0 so this code won't be executed but "thisresplenp =
&resplen;" followed by "*thisresplenp = rlen;" will be executed so that
subsequent times round the loop resplen has been initialized.
* The version number in DIAG_IGNORE_NEEDS_COMMENT is the most recent GCC
version with which the issue has been observed, not the oldest.
* A conditional __GNUC_PREREQ (4, 7) is needed around the
DIAG_IGNORE_NEEDS_COMMENT call because 4.6 doesn't have
-Wmaybe-uninitialized (if the warnings appear with 4.6, a #else case to
use -Wuninitialized instead with 4.6 will be needed).
--
Joseph S. Myers
joseph@codesourcery.com