From: Artem Starshov <artemreyt@tarantool.org> To: Alexander Turenko <alexander.turenko@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH 1/2] sql: fix build with GCC 10 Date: Fri, 20 Nov 2020 05:23:49 +0300 [thread overview] Message-ID: <3229ff8c69e84bd85798c79d382d35ba52640ce4.1605828734.git.artemreyt@tarantool.org> (raw) In-Reply-To: <cover.1605828734.git.artemreyt@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 --- src/box/sql/select.c | 54 +++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/box/sql/select.c b/src/box/sql/select.c index b0554a172..921fab7fc 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -154,13 +154,15 @@ sqlSelectNew(Parse * pParse, /* Parsing context */ Expr * pLimit, /* LIMIT value. NULL means not used */ Expr * pOffset) /* OFFSET value. NULL means no offset */ { - Select *pNew; - Select standin; + Select *pNew; /* Pointer to allocated region by sqlDbMallocRawNN (0 if failed) */ + Select *pNewTmp; /* Pointer to work with */ + Select standin; /* If allocation failed, save it to pNewTmp for filling and futher cleaning */ sql *db = pParse->db; pNew = sqlDbMallocRawNN(db, sizeof(*pNew)); - if (pNew == 0) { + pNewTmp = pNew; + if (pNewTmp == 0) { assert(db->mallocFailed); - pNew = &standin; + pNewTmp = &standin; } if (pEList == 0) { struct Expr *expr = sql_expr_new_anon(db, TK_ASTERISK); @@ -168,11 +170,11 @@ sqlSelectNew(Parse * pParse, /* Parsing context */ pParse->is_aborted = true; pEList = sql_expr_list_append(db, NULL, expr); } - pNew->pEList = pEList; - pNew->op = TK_SELECT; - pNew->selFlags = selFlags; - pNew->iLimit = 0; - pNew->iOffset = 0; + pNewTmp->pEList = pEList; + pNewTmp->op = TK_SELECT; + pNewTmp->selFlags = selFlags; + pNewTmp->iLimit = 0; + pNewTmp->iOffset = 0; #ifdef SQL_DEBUG pNew->zSelName[0] = 0; if ((pParse->sql_flags & SQL_SelectTrace) != 0) @@ -180,30 +182,30 @@ sqlSelectNew(Parse * pParse, /* Parsing context */ else sqlSelectTrace = 0; #endif - pNew->addrOpenEphm[0] = -1; - pNew->addrOpenEphm[1] = -1; - pNew->nSelectRow = 0; + pNewTmp->addrOpenEphm[0] = -1; + pNewTmp->addrOpenEphm[1] = -1; + pNewTmp->nSelectRow = 0; if (pSrc == 0) pSrc = sqlDbMallocZero(db, sizeof(*pSrc)); - pNew->pSrc = pSrc; - pNew->pWhere = pWhere; - pNew->pGroupBy = pGroupBy; - pNew->pHaving = pHaving; - pNew->pOrderBy = pOrderBy; - pNew->pPrior = 0; - pNew->pNext = 0; - pNew->pLimit = pLimit; - pNew->pOffset = pOffset; - pNew->pWith = 0; + pNewTmp->pSrc = pSrc; + pNewTmp->pWhere = pWhere; + pNewTmp->pGroupBy = pGroupBy; + pNewTmp->pHaving = pHaving; + pNewTmp->pOrderBy = pOrderBy; + pNewTmp->pPrior = 0; + pNewTmp->pNext = 0; + pNewTmp->pLimit = pLimit; + pNewTmp->pOffset = pOffset; + pNewTmp->pWith = 0; assert(pOffset == 0 || pLimit != 0 || pParse->is_aborted || db->mallocFailed != 0); if (db->mallocFailed) { - clearSelect(db, pNew, pNew != &standin); - pNew = 0; + clearSelect(db, pNewTmp, pNewTmp != &standin); + pNewTmp = 0; } else { - assert(pNew->pSrc != 0 || pParse->is_aborted); + assert(pNewTmp->pSrc != 0 || pParse->is_aborted); } - assert(pNew != &standin); + assert(pNewTmp != &standin); return pNew; } -- 2.28.0
next prev parent reply other threads:[~2020-11-20 2:23 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-20 2:23 [Tarantool-patches] [PATCH 0/2] GCC 10 warnings Artem Starshov 2020-11-20 2:23 ` Artem Starshov [this message] [not found] ` <20201123231440.GA17397@tarantool.org> 2020-11-25 9:25 ` [Tarantool-patches] [PATCH 1/2] sql: fix build with GCC 10 Artem 2020-11-25 9:52 ` Artem 2020-11-25 11:30 ` Nikita Pettik 2020-11-20 2:23 ` [Tarantool-patches] [PATCH 2/2] bitset: fix GCC 10 build Artem Starshov 2020-11-21 11:29 ` Aleksandr Lyapunov 2020-11-25 11:29 ` Artem
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=3229ff8c69e84bd85798c79d382d35ba52640ce4.1605828734.git.artemreyt@tarantool.org \ --to=artemreyt@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/2] sql: 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