From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [217.69.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id BDF92469710 for ; Fri, 5 Jun 2020 17:01:38 +0300 (MSK) From: Serge Petrenko Date: Fri, 5 Jun 2020 17:01:25 +0300 Message-Id: <20200605140125.25329-1-sergepetrenko@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH] decimal: fix build with GCC 10 List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: avtikhon@tarantool.org, alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org 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)