Re: [PATCH 1/4] Remove redundant return value check

Dan Carpenter
2023-11-02T14:31:19Z

On Thu, Nov 02, 2023 at 05:11:32PM +0300, 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
>

It can return an error because of this check:

drivers/media/mc/mc-entity.c
215 if (hweight32(iter->flags & (MEDIA_PAD_FL_SINK |
216 MEDIA_PAD_FL_SOURCE)) != 1) {
217 ret = -EINVAL;
218 break;
219 }

Plus I don't like removing error checking for this reason.

Earlier this month I fixed a case where someone removed an IS_ERR()
check but then we modified the function to return error pointers.
https://lore.kernel.org/all/356fb42c-9cf1-45cd-9233-ac845c507fb7@moroto.mountain/

regards,
dan carpenter