[PATCH] Cygwin: fix build with GCC 7

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Apr 17 20:07:00 GMT 2018


On Apr 17 10:54, Yaakov Selkowitz wrote:
> GCC 7 is able to see straight through this trick, so use a more formal
> method to avoid the warning.
> 
> Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
> ---
>  winsup/cygwin/random.cc | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/winsup/cygwin/random.cc b/winsup/cygwin/random.cc
> index 802c33b8a..163fc040c 100644
> --- a/winsup/cygwin/random.cc
> +++ b/winsup/cygwin/random.cc
> @@ -279,14 +279,6 @@ srandom(unsigned x)
>  		(void)random();
>  }
>  
> -/* Avoid a compiler warning when we really want to get at the junk in
> -   an uninitialized variable. */
> -static unsigned long
> -dummy (unsigned volatile long *x)
> -{
> -  return *x;
> -}
> -
>  /*
>   * srandomdev:
>   *
> @@ -313,7 +305,11 @@ srandomdev()
>  		unsigned long junk;
>  
>  		gettimeofday(&tv, NULL);
> -		srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ dummy(&junk));
> +		/* Avoid a compiler warning when we really want to get at the
> +		   junk in an uninitialized variable. */
> +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> +		srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
> +#pragma GCC diagnostic pop
>  		return;
>  	}
>  
> -- 
> 2.17.0

Yes, please push.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20180417/44e6d845/attachment.sig>


More information about the Cygwin-patches mailing list