From patchwork Sun Jun 26 13:07:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12895758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5FD3C433EF for ; Sun, 26 Jun 2022 13:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234558AbiFZNIE (ORCPT ); Sun, 26 Jun 2022 09:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234280AbiFZNIA (ORCPT ); Sun, 26 Jun 2022 09:08:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A852B5E for ; Sun, 26 Jun 2022 06:07:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 40BD9B80CA6 for ; Sun, 26 Jun 2022 13:07:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F0B3C341CA; Sun, 26 Jun 2022 13:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656248876; bh=lJd1owcsLNjXzJU3+zKE1ZxKKATyb8Vu9aAqVTuMdfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTIzU39rcH/g7I7zmCkjltI7Qen039/3SDxwYMtcsHIgfuR51q9EtB4JFOWG1+eTf gAfFFLNIXq3OemGl2SHXFT5cvwBVq17cxhv1RF98DwHpKlBG30OSLoKBZ3uRkkeH+U GM2hwnXNXK8fl9F36+9StU8IUPkBevjWW/GO0r/+/GwGizxlSP7rrcDYXugu/4li6n bEVCWqKDEi/sOQq1qDfvPkxUjEgrZ/Rn5fqiQ0EVwo6mltMk1bihKRbMqC4KpsLL/l DIY9KhnysCzIrUKjf9aWCZEeE2ZghjsTR0QC75yYujl60XNs8kT08iR00wIImgbtQ7 solWgrREDj4xA== From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/6] inline: add testcases for inlining of variadics Date: Sun, 26 Jun 2022 15:07:43 +0200 Message-Id: <20220626130748.74163-2-lucvoo@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220626130748.74163-1-lucvoo@kernel.org> References: <20220626130748.74163-1-lucvoo@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org From: Luc Van Oostenryck Inlining of variadic functions needs some special cases. Add some testcases for this. Signed-off-by: Luc Van Oostenryck --- validation/inline-early/variadic0.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 validation/inline-early/variadic0.c diff --git a/validation/inline-early/variadic0.c b/validation/inline-early/variadic0.c new file mode 100644 index 000000000000..566e129f029d --- /dev/null +++ b/validation/inline-early/variadic0.c @@ -0,0 +1,13 @@ +static inline void fun(const char *fmt, ...) +{ +} + +void main(void) +{ + fun("abc", 0); // will be a SYM_BASETYPE + fun("ijk", (const int)1); // will be a SYM_NODE +} + +/* + * check-name: variadic0 + */ From patchwork Sun Jun 26 13:07:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12895760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04E16CCA47F for ; Sun, 26 Jun 2022 13:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234487AbiFZNIF (ORCPT ); Sun, 26 Jun 2022 09:08:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234436AbiFZNIA (ORCPT ); Sun, 26 Jun 2022 09:08:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ABBBCC8 for ; Sun, 26 Jun 2022 06:07:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 57C35B80D89 for ; Sun, 26 Jun 2022 13:07:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BB6AC341CB; Sun, 26 Jun 2022 13:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656248877; bh=SlAij8Oqc1K9LT6P0ed20OndAiyw4rHQsfDrSc9ZYDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+EFre2N82CVrP260YbfvgJ2R4eBxeDhuai8ZuI7ZRTLmowVC6XDTXteOOHDv5TNG n8XHNrx4nNunsLNR9I8c76bfBuw/UELxqgcrzuc592NxOVmWZ88luT0udt+qV5mBz6 61k33DnQJVDOtYpvYYmVu81AL724FhDM5W/oe7tIPSjHmIAlqVc4UoEYdB/IrzI9gX niJsBJI/SlrO3bO5d9+OsPTQpPFYDGa5rROgZEHTM72rrajvucL6SXeYEkInyIsUmY 4tQJSNda/nakM1ay4PEf6Nt95eDPg6xvukp0X66FuheG3k773UDkJwlhwKCeMccHjY 0ofcMGbF37Y4Q== From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/6] inline: comment about creating node of node on variadics Date: Sun, 26 Jun 2022 15:07:44 +0200 Message-Id: <20220626130748.74163-3-lucvoo@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220626130748.74163-1-lucvoo@kernel.org> References: <20220626130748.74163-1-lucvoo@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org From: Luc Van Oostenryck When inlining a variadic function (unsupported in general by sparse but OK when the arguments are unused and occurs as such in the kernel), the extra arguments are added in the declaration list as SYM_NODE. But these arguments can already be SYM_NODEs. Sparse doesn't support everywhere such nested nodes (they must be merged) but in this case it's fine as the node will be merged when evaluated. Add a comment telling the situation is fine. Also, move the code to where the variadic arguments are handled since the fixed one will be anyway directly overwritten. Note: Sparse doesn't really support inlining of variadic functions but is fine when the arguments are not used (and such cases occur in the kernel). Signed-off-by: Luc Van Oostenryck --- inline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/inline.c b/inline.c index 0097e4bf620a..d031c9b19128 100644 --- a/inline.c +++ b/inline.c @@ -542,11 +542,15 @@ int inline_function(struct expression *expr, struct symbol *sym) FOR_EACH_PTR(arg_list, arg) { struct symbol *a = alloc_symbol(arg->pos, SYM_NODE); - a->ctype.base_type = arg->ctype; if (name) { *a = *name; set_replace(name, a); add_symbol(&fn_symbol_list, a); + } else { + // This may create a node of a node but it will + // be resolved later when the corresponding + // STMT_DECLARATION will be evaluated. + a->ctype.base_type = arg->ctype; } a->initializer = arg; add_symbol(&arg_decl, a); From patchwork Sun Jun 26 13:07:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12895761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 851FAC433EF for ; Sun, 26 Jun 2022 13:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234436AbiFZNIG (ORCPT ); Sun, 26 Jun 2022 09:08:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234469AbiFZNIB (ORCPT ); Sun, 26 Jun 2022 09:08:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B281810A6 for ; Sun, 26 Jun 2022 06:08:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 59616B80D8D for ; Sun, 26 Jun 2022 13:07:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6769EC34114; Sun, 26 Jun 2022 13:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656248878; bh=sMpPGbTZ1ffXSJzAHnfX/4x/ItATuufRdi3V16c6zVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wn5nWi9CCWaSUfP1XeSjbfrykeg8A6tBjx+gxeeLGsXy2FpjqFtojjA1k1nNVMreO A+vvQFnhdbtHQaSXIBlHnwmi0mfrvdoFtEz+NfeX9RNm8sCdmYVIVxviSx2RTvkLNs 8SCJ0kOzXzcOtoleomBdsbI4IJRBtfIY8JEbsF/MIk10QBl9fiOzgZnmQ7klvLvE0C jPvRMfpfw8DJ5pPjTVYC9U+ADj0wFd1ARRFstMaAjnD1MllvsQtifGTBfLcGbQrmN6 hyF6pKnBJxeI7ryiAd1yq9KvOZv1r1SCNXVieS6+DPaIhjgvEsaWjE3HuC7anQyJ8x 8j0BkY7mkbqSg== From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 3/6] inline: declaration of the variadic vars is useless Date: Sun, 26 Jun 2022 15:07:45 +0200 Message-Id: <20220626130748.74163-4-lucvoo@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220626130748.74163-1-lucvoo@kernel.org> References: <20220626130748.74163-1-lucvoo@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org From: Luc Van Oostenryck When inlining a function call, the arguments of this call must somehow be assigned to the names used in the function definition. This is done via a STMT_DECLARATION associated to the top STMT_COMPOUND which now correspond to the inlined code. This is perfectly fine for the normal case of non-variadic function but when inlining a variadic function there is no corresponding name to assign the non-fixed arguments to (such arguments must either be not used at all or copied via __builtin_va_arg_pack()). What's then happening is essentially that these variables are self-assigned. Not Good. This seems to be relatively harmless but is confusing. So only put the fixed/named arguments in the declaration list. Signed-off-by: Luc Van Oostenryck --- inline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inline.c b/inline.c index d031c9b19128..4696eb509f9a 100644 --- a/inline.c +++ b/inline.c @@ -546,14 +546,14 @@ int inline_function(struct expression *expr, struct symbol *sym) *a = *name; set_replace(name, a); add_symbol(&fn_symbol_list, a); + a->initializer = arg; + add_symbol(&arg_decl, a); } else { // This may create a node of a node but it will // be resolved later when the corresponding // STMT_DECLARATION will be evaluated. a->ctype.base_type = arg->ctype; } - a->initializer = arg; - add_symbol(&arg_decl, a); NEXT_PTR_LIST(name); } END_FOR_EACH_PTR(arg); From patchwork Sun Jun 26 13:07:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12895759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 097F2C43334 for ; Sun, 26 Jun 2022 13:08:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234467AbiFZNIF (ORCPT ); Sun, 26 Jun 2022 09:08:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234487AbiFZNID (ORCPT ); Sun, 26 Jun 2022 09:08:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B97801151 for ; Sun, 26 Jun 2022 06:08:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6E8B3B80D8E for ; Sun, 26 Jun 2022 13:07:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C829C341CA; Sun, 26 Jun 2022 13:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656248879; bh=WViLtkh4M0IfYdsXOjabRJdmXKarw/L4MRoWslmvz48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZoP8EHCSpFJomyP2oC1LGBWmLY+U4ECLLUewSByt0oYjQjy8Lqx5BaTHjGqE1EB8f osD2KhlKSBYim2v0e4WdEaRRShAL44McWQyrhCHxfOMBrJDYvmG8WQsTJiWpXFY6F2 VNuosi3ED6mKe3pX3fKqGusd4u3ADdS7MOd8H/18NaL+OwsiosCAHSaBIpSdlVOCUN 7Zjp148xWsqddN7ENl4hrexNAv5sZUQHeseNVYMq3v2m53QkbQwLXd03h4f75A+Ext mxnZysPzQ9+66gZAyp12tesV6oZzspsFZOiOaz8nksJCSWnoUQAVzOuWj/8e61ZG7C 8Ojlw4g4wx6lw== From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 4/6] inline: avoid needless intermediate vars Date: Sun, 26 Jun 2022 15:07:46 +0200 Message-Id: <20220626130748.74163-5-lucvoo@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220626130748.74163-1-lucvoo@kernel.org> References: <20220626130748.74163-1-lucvoo@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org From: Luc Van Oostenryck In inline_function(), the we need to iterate over the parameters and the (effective) arguments. An itermediate variable is used for each: "name_list" and "arg_list". These confuse me a lot (especially "name_list", "param_list" would be much more OK) and are just used once. So, avoid using an intermediate variable for these. Signed-off-by: Luc Van Oostenryck --- inline.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/inline.c b/inline.c index 4696eb509f9a..a6f9252ab0ff 100644 --- a/inline.c +++ b/inline.c @@ -516,9 +516,8 @@ int inline_function(struct expression *expr, struct symbol *sym) { struct symbol_list * fn_symbol_list; struct symbol *fn = sym->ctype.base_type; - struct expression_list *arg_list = expr->args; struct statement *stmt = alloc_statement(expr->pos, STMT_COMPOUND); - struct symbol_list *name_list, *arg_decl; + struct symbol_list *arg_decl; struct symbol *name; struct expression *arg; @@ -529,8 +528,6 @@ int inline_function(struct expression *expr, struct symbol *sym) if (fn->expanding) return 0; - name_list = fn->arguments; - expr->type = EXPR_STATEMENT; expr->statement = stmt; expr->ctype = fn->ctype.base_type; @@ -538,8 +535,8 @@ int inline_function(struct expression *expr, struct symbol *sym) fn_symbol_list = create_symbol_list(sym->inline_symbol_list); arg_decl = NULL; - PREPARE_PTR_LIST(name_list, name); - FOR_EACH_PTR(arg_list, arg) { + PREPARE_PTR_LIST(fn->arguments, name); + FOR_EACH_PTR(expr->args, arg) { struct symbol *a = alloc_symbol(arg->pos, SYM_NODE); if (name) { From patchwork Sun Jun 26 13:07:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12895762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40818C43334 for ; Sun, 26 Jun 2022 13:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234469AbiFZNIH (ORCPT ); Sun, 26 Jun 2022 09:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234535AbiFZNID (ORCPT ); Sun, 26 Jun 2022 09:08:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29C5125F9 for ; Sun, 26 Jun 2022 06:08:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B39B86121E for ; Sun, 26 Jun 2022 13:08:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D3D0C341CB; Sun, 26 Jun 2022 13:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656248880; bh=UrAkhnFDuSOEuz40PQq0cDjbsCnjbB5GJR+N7s1FoBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BmGRE7g5vgCMrZB8EGhCK3jehwLKW6uMoaDFx8c2Y11+F3HhmueJVNMNoROnSShFq u1TsE4WJTLJgIBYCx+6ddSqhy6dh+Q50DB7L9zYscH1ooUH63ugbmES1GgGqo+N4HE lFKj5VrjQmwG/Wd1T7omhyMAv7eBNub8miYnd0FX3iSAY+B4sTEKkoSPsOk4/Eto5Z LvqOXaPdMi7HJaAV3jEBV7xkv0i99N/qPbrExjkdnN30oyEoonHt/0ALVcM8wAdXBm 2zaP5lTB/sFLfuoOyDhm5fk1xwmOw2lhaohgrIxAxXIbOujoWubOGHQOWtcvXFjRp1 V2eX01frZ8X/w== From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 5/6] inline: allocate statement after guards Date: Sun, 26 Jun 2022 15:07:47 +0200 Message-Id: <20220626130748.74163-6-lucvoo@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220626130748.74163-1-lucvoo@kernel.org> References: <20220626130748.74163-1-lucvoo@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org From: Luc Van Oostenryck In inline_function(), the statement that will correspond to the inlined code is allocated in the function declaration but then it's checked if the function can be allocated or not. This is not much memory and the checks should succeed most of the time but it's clearer if the statement is allocated after the checks. So, move the allocation after the checks. Signed-off-by: Luc Van Oostenryck --- inline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inline.c b/inline.c index a6f9252ab0ff..68f235c21945 100644 --- a/inline.c +++ b/inline.c @@ -516,7 +516,7 @@ int inline_function(struct expression *expr, struct symbol *sym) { struct symbol_list * fn_symbol_list; struct symbol *fn = sym->ctype.base_type; - struct statement *stmt = alloc_statement(expr->pos, STMT_COMPOUND); + struct statement *stmt; struct symbol_list *arg_decl; struct symbol *name; struct expression *arg; @@ -528,6 +528,7 @@ int inline_function(struct expression *expr, struct symbol *sym) if (fn->expanding) return 0; + stmt = alloc_statement(expr->pos, STMT_COMPOUND); expr->type = EXPR_STATEMENT; expr->statement = stmt; expr->ctype = fn->ctype.base_type; From patchwork Sun Jun 26 13:07:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12895763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B6C7CCA47C for ; Sun, 26 Jun 2022 13:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234535AbiFZNIH (ORCPT ); Sun, 26 Jun 2022 09:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234555AbiFZNID (ORCPT ); Sun, 26 Jun 2022 09:08:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ECC52719 for ; Sun, 26 Jun 2022 06:08:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CBF6261237 for ; Sun, 26 Jun 2022 13:08:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83C38C34114; Sun, 26 Jun 2022 13:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656248881; bh=BcKa+Y/z+jxw3qTTzprUgzel8f5e5lWuuMseyr+OUX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EN9bHjSY1JWARtOkbnkn3+GxoGPTxGxC7IgZPMAQhPYVvTKAqyGReOmyDgKvAtn0o IH6l2wc93bRAoMHR+8oT4NhQdTqn923rda2BKPBsynp2R6w6C4DK8OK4BnxHe56j2I 1sN6UiQGoRYZXOlPzhg36BGrvFnoh/TkqmziciBIUWXJfurS/52T8NByzxS4Rpv4Ke sxRkicKgG2Zfko7Hh+ER0SyPX1+9hRkNG6xFzQvmMhsDq3oBPVmtrnrSawPqmWj5jF 9baVCSZYhG9wEH3mjbHyuc+Y9p9K9V3RiSZrk1IXrQPET1PwSJ/PfD9CXn21N72XjJ UEk4/7uvAupBA== From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 6/6] inline: free symbol list after use Date: Sun, 26 Jun 2022 15:07:48 +0200 Message-Id: <20220626130748.74163-7-lucvoo@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220626130748.74163-1-lucvoo@kernel.org> References: <20220626130748.74163-1-lucvoo@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org From: Luc Van Oostenryck We usually don't free allocated memory because it's not known when the allocated objects aren't used anymore. But here it's pretty obvious, so free this symbol list. Signed-off-by: Luc Van Oostenryck --- inline.c | 1 + 1 file changed, 1 insertion(+) diff --git a/inline.c b/inline.c index 68f235c21945..a7ab73d37492 100644 --- a/inline.c +++ b/inline.c @@ -567,6 +567,7 @@ int inline_function(struct expression *expr, struct symbol *sym) stmt->inline_fn = sym; unset_replace_list(fn_symbol_list); + free_ptr_list(&fn_symbol_list); return 1; }