From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Wed, 12 Nov 2014 10:51:44 +0000 Subject: Re: [PATCH with SmPL?] staging: rtl8188eu: Adjustments around jump labels Message-Id: <54633BC0.3030700@users.sourceforge.net> List-Id: References: <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <544954FD.8040607@users.sourceforge.net> <20141029084702.GA18675@kroah.com> <5453CD0D.9010206@users.sourceforge.net> <5453D013.9000007@users.sourceforge.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: cocci@systeme.lip6.fr >>>> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 >>>> _size_byte, u8 *pbuf) >>>> exit: >>>> kfree(efuseTbl); >>>> >>>> - if (eFuseWord) >>>> - kfree(eFuseWord); >>>> + kfree(eFuseWord); >>> >>> I think that this code has been updated already. It would be better to >>> add labels so that kfree is only executed when needed. >> >> Are there any chances to achieve the suggested fine-tuning for jump labels >> also with another semantic patch approach? > > No, I don't think so. The pattern is not regular enough. Now I have got a different impression for corresponding improvement possibilities. elfring@Sonne:~/Projekte/Linux/stable-patched> spatch.opt -debug -sp-file ~/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci drivers/staging/rtl8188eu/core/rtw_efuse.c init_defs_builtins: /usr/local/share/coccinelle/standard.h ----------------------------------------------------------------------- processing semantic patch file: /home/elfring/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci with isos from: /usr/local/share/coccinelle/standard.iso ----------------------------------------------------------------------- @move_function_call_before_jump_label@ expression x; identifier fu, label; type t; @@ t fu(...) { ... when any x = kzalloc(...); if (x = NULL) { ... goto label; } ... when any + kfree(x); label: - kfree(x); ... } HANDLING: drivers/staging/rtl8188eu/core/rtw_efuse.c ----------------------------------------------------------------------- let's go ----------------------------------------------------------------------- ----------------------------------------------------------------------- ----------------------------------------------------------------------- move_function_call_before_jump_label = ----------------------------------------------------------------------- dependencies for rule move_function_call_before_jump_label satisfied: binding in = [] binding relevant in = [] (ONCE) USING optional_storage builtin isomorphism transformation info returned: transform state: 5 with rule_elem: <<< kfree(move_function_call_before_jump_label:x); move_function_call_before_jump_label:label: with binding: [move_function_call_before_jump_label.x --> efuseTbl] transform state: 204 with rule_elem: -kfree-(-move_function_call_before_jump_label:x-)-; with binding: [move_function_call_before_jump_label.x --> efuseTbl] binding out = [] transform one node: 204 transform one node: 5 ----------------------------------------------------------------------- Finished ----------------------------------------------------------------------- diff = --- drivers/staging/rtl8188eu/core/rtw_efuse.c +++ /tmp/cocci-output-4498-349827-rtw_efuse.c @@ -209,8 +209,8 @@ efuse_phymap_to_logical(u8 *phymap, u16 /* 5. Calculate Efuse utilization. */ /* */ +kfree(efuseTbl); exit: - kfree(efuseTbl); kfree(eFuseWord); } Check duplication for 1 files Can my update suggestion be generalised a bit more for the movement of specific jump labels towards the end of a function implementation like in the use case "efuse_phymap_to_logical()"? Regards, Markus