Re: [PATCH 00/36] treewide: remove conditional returns with no effect

Jani Nikula <jani.nikula-VuQAYsv1563Yd54FQh9/[email protected]> Mon, 27 Jul 2026 14:36:57 +0300
Newsgroups gmane.comp.freedesktop.xorg.nouveau,gmane.comp.freedesktop.amd-gfx,gmane.comp.video.dri.devel,gmane.comp.freedesktop.xorg.drivers.intel,gmane.linux.kernel.cifs,gmane.linux.kernel.clk,gmane.linux.kernel.cryptoapi,gmane.linux.kernel.gpio,gmane.linux.kernel.iio,gmane.linux.kernel.input,gmane.linux.kernel,gmane.linux.drivers.video-input-infrastructure,gmane.linux.kernel.mm,gmane.linux.power-management.general,gmane.linux.drivers.rdma,gmane.linux.scsi,gmane.linux.sound,gmane.linux.usb.general,gmane.linux.kernel.wireless.general,gmane.comp.linux.lvs.devel,gmane.linux.network,gmane.comp.security.firewalls.netfilter.devel,gmane.linux.drivers.platform.x86.devel
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs Bertel Jungin Aukio 5, 02600 Espoo, Finland
Message-ID <a4703624643e1d2fd1a9dedc1d36ce5d34d3133f__12287.5161397801$1785215664$gmane$org@intel.com>
On Mon, 27 Jul 2026, Sang-Heon Jeon <[email protected]> wrote:
> Hello,
>
> On Mon, Jul 27, 2026 at 5:30 PM Jani Nikula <[email protected]> wrote:
>>
>> On Fri, 24 Jul 2026, Jakub Kicinski <[email protected]> wrote:
>> > On Fri, 24 Jul 2026 03:45:02 +0900 Sang-Heon Jeon wrote:
>> >> Patch 1 adds a Coccinelle script that matches the pattern, including
>> >> negation and constant-comparison variants. Where a local variable is
>> >> assigned right before the check, the assignment and the two returns
>> >> turn into a single return of the assigned expression.
>> >
>> > Huh, I thought we already had such script. Various script children have
>> > been sending such "cleanups" in the past.
>>
>> We did, and it was removed, I believe in 1a617a8475e8 ("coccinelle:
>> misc: remove "complex return code" warnings"), because people just don't
>> want this constant churn.
>>
>> It's perfectly fine to have the error case and happy day scenario
>> separated.
>
> Thanks for sharing the history.
>
> I checked the mailing list. The removed script looks similar to the
> new one, but it is different. The removed script reported a
> conditional return followed by an explicit return 0, where the error
> case and happy day scenario are separated as you mentioned, and Johan
> also complained about this 10 years ago.
>
> But the new script only reports when both branches return the same
> variable, not the explicit 0. So, I think the new script is close to
> the restricted version that Julia mentioned 10 years ago, and it
> should be acceptable.

ret === 0 after an if (ret) return.

BR,
Jani.


>
>>
>> BR,
>> Jani.
>>
>>
>> --
>> Jani Nikula, Intel
>
> Best Regards,
> Sang-Heon Jeon

-- 
Jani Nikula, Intel