diff mbox

malloc: Fix MALLOC_DEBUG -Wundef warning

Message ID 1396278243-24455-1-git-send-email-will.newton@linaro.org
State Accepted
Headers show

Commit Message

Will Newton March 31, 2014, 3:04 p.m. UTC
MALLOC_DEBUG is set optionally on the command line. Default the value
to zero if it is not set on the command line, and test its value
with #if rather than #ifdef. Verified the code is identical before
and after this change apart from line numbers.

ChangeLog:

2014-03-31  Will Newton  <will.newton@linaro.org>

	* malloc/malloc.c [!MALLOC_DEBUG]: #define MALLOC_DEBUG
	to zero if it is not defined elsewhere.  (mtrim): Test
	the value of MALLOC_DEBUG with #if rather than #ifdef.
---
 malloc/malloc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Will Newton April 8, 2014, 12:34 p.m. UTC | #1
On 31 March 2014 16:04, Will Newton <will.newton@linaro.org> wrote:
> MALLOC_DEBUG is set optionally on the command line. Default the value
> to zero if it is not set on the command line, and test its value
> with #if rather than #ifdef. Verified the code is identical before
> and after this change apart from line numbers.
>
> ChangeLog:
>
> 2014-03-31  Will Newton  <will.newton@linaro.org>
>
>         * malloc/malloc.c [!MALLOC_DEBUG]: #define MALLOC_DEBUG
>         to zero if it is not defined elsewhere.  (mtrim): Test
>         the value of MALLOC_DEBUG with #if rather than #ifdef.
> ---
>  malloc/malloc.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Ping?

> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index 9a45707..1120d4d 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -270,6 +270,10 @@
>    or other mallocs available that do this.
>  */
>
> +#ifndef MALLOC_DEBUG
> +#define MALLOC_DEBUG 0
> +#endif
> +
>  #ifdef NDEBUG
>  # define assert(expr) ((void) 0)
>  #else
> @@ -4477,7 +4481,7 @@ mtrim (mstate av, size_t pad)
>
>                  if (size > psm1)
>                    {
> -#ifdef MALLOC_DEBUG
> +#if MALLOC_DEBUG
>                      /* When debugging we simulate destroying the memory
>                         content.  */
>                      memset (paligned_mem, 0x89, size & ~psm1);
> --
> 1.8.1.4
>
Carlos O'Donell April 10, 2014, 11:33 p.m. UTC | #2
On 04/08/2014 08:34 AM, Will Newton wrote:
> On 31 March 2014 16:04, Will Newton <will.newton@linaro.org> wrote:
>> MALLOC_DEBUG is set optionally on the command line. Default the value
>> to zero if it is not set on the command line, and test its value
>> with #if rather than #ifdef. Verified the code is identical before
>> and after this change apart from line numbers.
>>
>> ChangeLog:
>>
>> 2014-03-31  Will Newton  <will.newton@linaro.org>
>>
>>         * malloc/malloc.c [!MALLOC_DEBUG]: #define MALLOC_DEBUG
>>         to zero if it is not defined elsewhere.  (mtrim): Test
>>         the value of MALLOC_DEBUG with #if rather than #ifdef.
>> ---
>>  malloc/malloc.c | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> Ping?
> 
>> diff --git a/malloc/malloc.c b/malloc/malloc.c
>> index 9a45707..1120d4d 100644
>> --- a/malloc/malloc.c
>> +++ b/malloc/malloc.c
>> @@ -270,6 +270,10 @@
>>    or other mallocs available that do this.
>>  */
>>
>> +#ifndef MALLOC_DEBUG
>> +#define MALLOC_DEBUG 0
>> +#endif
>> +
>>  #ifdef NDEBUG
>>  # define assert(expr) ((void) 0)
>>  #else
>> @@ -4477,7 +4481,7 @@ mtrim (mstate av, size_t pad)
>>
>>                  if (size > psm1)
>>                    {
>> -#ifdef MALLOC_DEBUG
>> +#if MALLOC_DEBUG
>>                      /* When debugging we simulate destroying the memory
>>                         content.  */
>>                      memset (paligned_mem, 0x89, size & ~psm1);

Looks good to me.

Cheers,
Carlos.
diff mbox

Patch

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 9a45707..1120d4d 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -270,6 +270,10 @@ 
   or other mallocs available that do this.
 */
 
+#ifndef MALLOC_DEBUG
+#define MALLOC_DEBUG 0
+#endif
+
 #ifdef NDEBUG
 # define assert(expr) ((void) 0)
 #else
@@ -4477,7 +4481,7 @@  mtrim (mstate av, size_t pad)
 
                 if (size > psm1)
                   {
-#ifdef MALLOC_DEBUG
+#if MALLOC_DEBUG
                     /* When debugging we simulate destroying the memory
                        content.  */
                     memset (paligned_mem, 0x89, size & ~psm1);