This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix -Wmaybe-uninitialized warning in xdr.c
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Tue, 08 Jul 2014 15:01:39 -0300
- Subject: Re: Fix -Wmaybe-uninitialized warning in xdr.c
- Authentication-results: sourceware.org; auth=none
- References: <20140708175919 dot GL609 at spoyarek dot pnq dot redhat dot com>
On 08-07-2014 14:59, Siddhesh Poyarekar wrote:
> Hi,
>
> While we're at fixing build warnings, here's one unnecessary warning
> that can be fixed fairly easily. The SIZE variable is never actually
> use uninitialized, but the compiler cannot make that out and thinks
> (correctly) that there is a potential for accessing SIZE without
> initializing it. Make this safe by initializing SIZE to 0.
>
> Tested on x86_64.
>
> Siddhesh
>
> * sunrpc/xdr.c (xdr_string): Initialize SIZE to 0.
>
> diff --git a/sunrpc/xdr.c b/sunrpc/xdr.c
> index b3f96ca..129abd8 100644
> --- a/sunrpc/xdr.c
> +++ b/sunrpc/xdr.c
> @@ -739,7 +739,7 @@ xdr_string (xdrs, cpp, maxsize)
> u_int maxsize;
> {
> char *sp = *cpp; /* sp is the actual string pointer */
> - u_int size;
> + u_int size = 0;
> u_int nodesize;
>
> /*
Seems trivial enough.