Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Alexander V. Tikhonov" <avtikhon@tarantool.org>
To: Serge Petrenko <sergepetrenko@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH] decimal: fix build with GCC 10
Date: Sat, 6 Jun 2020 08:31:11 +0300	[thread overview]
Message-ID: <20200606053111.GA14471@hpalx> (raw)
In-Reply-To: <20200605140125.25329-1-sergepetrenko@tarantool.org>

Hi Sergey, thanks a lot for the patch, I've successfully checked it
on Fedora 32 and on the full testing process:
  https://gitlab.com/tarantool/tarantool/-/pipelines/153432554

On Fri, Jun 05, 2020 at 05:01:25PM +0300, Serge Petrenko wrote:
> GCC 10 produces the following error:
> cc1: warning: function may return address of local variable [-Wreturn-local-addr]
> 
> Fix it.
> 
> Part-of #4966
> ---
> https://github.com/tarantool/tarantool/issues/4966
> https://github.com/tarantool/tarantool/tree/sp/gh-4966-decimal-build
> 
>  src/lib/core/decimal.c | 8 ++++----
>  src/lib/core/decimal.h | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/lib/core/decimal.c b/src/lib/core/decimal.c
> index c44b2f6a2..019c68338 100644
> --- a/src/lib/core/decimal.c
> +++ b/src/lib/core/decimal.c
> @@ -176,24 +176,24 @@ decimal_to_integer(decimal_t *dec)
>  	return decimal_check_status(dec, &decimal_context);
>  }
>  
> -decimal_t *
> +const decimal_t *
>  decimal_to_int64(const decimal_t *dec, int64_t *num)
>  {
>  	decimal_t d = *dec;
>  	if (decimal_to_integer(&d) == NULL)
>  		return NULL;
>  	*num = decNumberToInt64(&d, &decimal_context);
> -	return decimal_check_status(&d, &decimal_context);
> +	return decimal_check_status(&d, &decimal_context) != NULL ? dec : NULL;
>  }
>  
> -decimal_t *
> +const decimal_t *
>  decimal_to_uint64(const decimal_t *dec, uint64_t *num)
>  {
>  	decimal_t d = *dec;
>  	if (decimal_to_integer(&d) == NULL)
>  		return NULL;
>  	*num = decNumberToUInt64(&d, &decimal_context);
> -	return decimal_check_status(&d, &decimal_context);
> +	return decimal_check_status(&d, &decimal_context) != NULL ? dec : NULL;
>  }
>  
>  int
> diff --git a/src/lib/core/decimal.h b/src/lib/core/decimal.h
> index 9a162c73c..e276344d2 100644
> --- a/src/lib/core/decimal.h
> +++ b/src/lib/core/decimal.h
> @@ -110,11 +110,11 @@ decimal_to_string(const decimal_t *dec);
>   * \param[out] num - the result
>   * @return NULL if \a dec doesn't fit into int64_t
>   */
> -decimal_t *
> +const decimal_t *
>  decimal_to_int64(const decimal_t *dec, int64_t *num);
>  
>  /** \sa decimal_to_int64 */
> -decimal_t *
> +const decimal_t *
>  decimal_to_uint64(const decimal_t *dec, uint64_t *num);
>  
>  /**
> -- 
> 2.24.3 (Apple Git-128)
> 

  reply	other threads:[~2020-06-06  5:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 14:01 Serge Petrenko
2020-06-06  5:31 ` Alexander V. Tikhonov [this message]
2020-06-08 10:23 ` Kirill Yukhin
2020-06-08 11:22 ` Alexander Turenko
2020-06-08 11:30   ` Serge Petrenko
2020-06-08 11:36     ` Alexander Turenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200606053111.GA14471@hpalx \
    --to=avtikhon@tarantool.org \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] decimal: fix build with GCC 10' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox