Re: [PATCH 10/11 v2] Fix warnings in nedmalloc when compiling with GCC 4.4.0
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 8, 2009, 16:50 UTC
- Message-ID
- <7vzlcizn3w.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <alpine.DEB.1.00.0906081645490.4461@intel-tinevez-2-302>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 6 quoted lines
> Nedmalloc's source code has a cute #define construct to avoid inserting > an if() statement, because that might interact badly with enclosing if() > statements. However, GCC > 4 complains with a "warning: value computed > is not used". So we cast the result to "void". > > Forgot to send.
Thanks. The description on the pragma is a good thing to add, which you did.
Is Visual C++ happy with casting discarded result to (void)? I'd find it broken if it isn't, but it would not hurt to ask just to make sure.
Steffen, can we move the series, with this patch replaced, to 'next' now? I think it looks good (thanks!) but again it would not hurt to ask just to make sure ;-).
Show 27 quoted lines
> compat/nedmalloc/malloc.c.h | 4 +++-
> compat/nedmalloc/nedmalloc.c | 2 +-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h
> index bb0f482..b5b1495 100644
> --- a/compat/nedmalloc/malloc.c.h
> +++ b/compat/nedmalloc/malloc.c.h
> @@ -1270,7 +1270,9 @@ int mspace_mallopt(int, int);
> /*------------------------------ internal #includes ---------------------- */
>
> #ifdef WIN32
> +#ifndef __GNUC__
> #pragma warning( disable : 4146 ) /* no "unsigned" warnings */
> +#endif
> #endif /* WIN32 */
>
> #include <stdio.h> /* for printing in malloc_stats */
> @@ -2541,7 +2543,7 @@ struct malloc_params {
> static struct malloc_params mparams;
>
> /* Ensure mparams initialized */
> -#define ensure_initialization() (mparams.magic != 0 || init_mparams())
> +#define ensure_initialization() ((void)(mparams.magic == 0 || init_mparams()))
>
> #if !ONLY_MSPACES
>