Re: [PATCH 2/2] staging: gdm724x: Remove variable

From: Sven Van Asbroeck
Date: Sat May 25 2019 - 09:32:10 EST

On Fri, May 24, 2019 at 2:04 AM Nishka Dasgupta
<nishkadg.linux@xxxxxxxxx> wrote:
> The return variable is used only twice (in two different branches), and
> both times it is assigned the same constant value. These can therefore
> be merged into the same assignment, placed at the point that both
> these branches (and no other) go to. The return variable itself can be
> removed.

> fail:
> release_usb(udev);
> - return ret;
> + return -ENOMEM;
> }

At the risk of sticking my nose where it doesn't belong...

AFAIK it's a well-established pattern to have a success path returning 0,
and an error path returning ret, where ret gets assigned the err value.

This patch removes the pattern, making it slightly harder for developers
to read. And if the function needs to return different err values in the
future, that future patch will need to add the ret variable back in.

Modern compilers optimize ret away, so the patch won't result in
smaller or more efficient code.

This particular patch sounds like negative work to me.