Skip to content

Commit a21077e

Browse files
dschogitster
authored andcommitted
Fix warnings in nedmalloc when compiling with GCC 4.4.0
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". GCC also does not understand the Visual C++ specific pragmas, so we need to disable them for MinGW. We need to include malloc.h on Windows even if we happen to compile the stuff as a MinGW program. Otherwise the function declaration of alloca() is missing. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f0ed822 commit a21077e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

compat/nedmalloc/malloc.c.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,9 @@ int mspace_mallopt(int, int);
12701270
/*------------------------------ internal #includes ---------------------- */
12711271

12721272
#ifdef WIN32
1273+
#ifndef __GNUC__
12731274
#pragma warning( disable : 4146 ) /* no "unsigned" warnings */
1275+
#endif
12741276
#endif /* WIN32 */
12751277

12761278
#include <stdio.h> /* for printing in malloc_stats */
@@ -2541,7 +2543,7 @@ struct malloc_params {
25412543
static struct malloc_params mparams;
25422544

25432545
/* Ensure mparams initialized */
2544-
#define ensure_initialization() (mparams.magic != 0 || init_mparams())
2546+
#define ensure_initialization() ((void)(mparams.magic == 0 || init_mparams()))
25452547

25462548
#if !ONLY_MSPACES
25472549

compat/nedmalloc/nedmalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DEALINGS IN THE SOFTWARE.
3434
/*#define FULLSANITYCHECKS*/
3535

3636
#include "nedmalloc.h"
37-
#if defined(WIN32) && !defined(__MINGW32__)
37+
#if defined(WIN32)
3838
#include <malloc.h>
3939
#endif
4040
#define MSPACES 1

0 commit comments

Comments
 (0)