From: Markus Elfring <Markus.Elfring@web.de>
To: Nicolas Ferre <nicolas.ferre@microchip.com>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] clk: at91: pmc: Use common error handling code in pmc_register_ops()
Date: Wed, 18 Sep 2024 16:32:29 +0200 [thread overview]
Message-ID: <ec3de20e-92cc-4e22-a30f-a9f57588278c@web.de> (raw)
In-Reply-To: <672befa1-cefb-480e-b474-ff40e4fe80ed@microchip.com>
>> Add a jump target so that a bit of exception handling can be better reused
>> at the end of this function implementation.
…
> Bad track record and no real benefit from the patch:
> NACK, sorry.
…
>> +++ b/drivers/clk/at91/pmc.c
>> @@ -162,20 +162,18 @@ static int __init pmc_register_ops(void)
>> if (!np)
>> return -ENODEV;
>>
>> - if (!of_device_is_available(np)) {
>> - of_node_put(np);
>> - return -ENODEV;
>> - }
>> + if (!of_device_is_available(np))
>> + goto put_node;
>> +
>> of_node_put(np);
>>
>> np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam");
>> if (!np)
>> return -ENODEV;
>>
>> - if (!of_device_is_available(np)) {
>> - of_node_put(np);
>> - return -ENODEV;
>> - }
>> + if (!of_device_is_available(np))
>> + goto put_node;
>> +
>> of_node_put(np);
>>
>> at91_pmc_backup_suspend = of_iomap(np, 0);
>> @@ -187,6 +185,10 @@ static int __init pmc_register_ops(void)
>> register_syscore_ops(&pmc_syscore_ops);
>>
>> return 0;
>> +
>> +put_node:
>> + of_node_put(np);
>> + return -ENODEV;
>> }
…
* Do you really disagree to advice from related information sources?
https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources?
* How do you think about to increase the application of scope-based resource management?
Regards,
Markus
prev parent reply other threads:[~2024-09-18 14:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 12:34 [PATCH] clk: at91: pmc: Use common error handling code in pmc_register_ops() Markus Elfring
2024-09-18 12:58 ` Nicolas Ferre
2024-09-18 14:32 ` Markus Elfring [this message]
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=ec3de20e-92cc-4e22-a30f-a9f57588278c@web.de \
--to=markus.elfring@web.de \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nicolas.ferre@microchip.com \
--cc=sboyd@kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox