coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] expr: fix build failure with -Werror=suggest-attribute=mallo


From: Carlos Santos
Subject: Re: [PATCH] expr: fix build failure with -Werror=suggest-attribute=malloc
Date: Mon, 25 Jun 2018 00:25:11 -0300 (BRT)

> From: "Pádraig Brady" <address@hidden>
> To: "DATACOM" <address@hidden>, "Coreutils" <address@hidden>
> Sent: Monday, June 25, 2018 12:11:14 AM
> Subject: Re: [PATCH] expr: fix build failure with 
> -Werror=suggest-attribute=malloc

> On 24/06/18 20:00, Carlos Santos wrote:
>> Add attribute 'malloc' to mpz_get_str to prevent a compilation error:
>> 
>>   src/expr.c:117:1: error: function might be candidate for attribute
>>     'malloc' if it is known to return normally
>>       [-Werror=suggest-attribute=malloc]
>>    mpz_get_str (char const *str, int base, mpz_t z)
>>    ^~~~~~~~~~~
>>   cc1: all warnings being treated as errors
>> ---
>>  src/expr.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/src/expr.c b/src/expr.c
>> index f4dbf1792..94eb9e78f 100644
>> --- a/src/expr.c
>> +++ b/src/expr.c
>> @@ -113,7 +113,7 @@ mpz_tdiv_r (mpz_t r, mpz_t a0, mpz_t b0)
>>    /* Some x86-style hosts raise an exception for INT_MIN % -1.  */
>>    r[0] = a < - INTMAX_MAX && b == -1 ? 0 : a % b;
>>  }
>> -static char *
>> +static char * _GL_ATTRIBUTE_MALLOC
>>  mpz_get_str (char const *str, int base, mpz_t z)
>>  {
>>    (void) str; (void) base;
>> 
> 
> This looks good.
> Though there was a recent report of GCC 9 being clean wrt warnings.
> What compiler (version) gave this warning?

$ gcc --version
gcc (GCC) 8.1.1 20180502 (Red Hat 8.1.1-1)
Copyright (C) 2018 Free Software Foundation, Inc.

On Fedrora 28.

-- 
Carlos Santos (Casantos) - DATACOM, P&D
“Marched towards the enemy, spear upright, armed with the certainty
that only the ignorant can have.” — Epitaph of a volunteer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]