[lvc-project] [PATCH 1/4] Remove redundant return value check

Dan Carpenter dan.carpenter at linaro.org
Thu Nov 2 17:31:12 MSK 2023


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




More information about the lvc-project mailing list