[lvc-project] [PATCH 1/4] Remove redundant return value check
Sakari Ailus
sakari.ailus at linux.intel.com
Thu Nov 2 18:09:57 MSK 2023
Hi Hans, Alexandra,
On Thu, Nov 02, 2023 at 03:21:04PM +0100, Hans de Goede wrote:
> Hi Alexandra,
>
> On 11/2/23 15:11, Alexandra Diupina wrote:
> > media_entity_pads_init() will not return 0 only if the
> > 2nd parameter >= MEDIA_ENTITY_MAX_PADS (512), but 1 is
> > passed, so checking the return value is redundant
>
> Generally speaking functions which can fail should always be
> error-checked even if their invocation today happen to be
> such that they will not fail.
>
> Either the invocation or the function itself my change
> causing it to fail in the future. Which is why we want
> to keep the error checks.
>
> But maybe media_entity_pads_init() is special and
> does not need to be error checked.
>
> Sakari, Laurent do you have any opinion on this ?
>
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> This feels like a false positive of the tool to me,
> but lets wait and see what Sakari or Laurent have
> to say.
I agree with Hans: this function today may not fail with the parameters
passed to it but it may happen in the future. In general it's good to check
a return value of a function that returns one: if that function is changed,
no-one will go through the callers as long as the arguments and the return
value remain the same.
--
Regards,
Sakari Ailus
More information about the lvc-project
mailing list