drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c:467 h264_encode_frame() warn: missing error code? 'ret'

From: Dan Carpenter
Date: Tue Jan 03 2023 - 03:10:24 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 69b41ac87e4a664de78a395ff97166f0b2943210
commit: 2023a99811110aebba9eee4aa09ef7bd21a8a249 media: platform: rename mediatek/mtk-jpeg/ to mediatek/jpeg/
config: ia64-randconfig-m041-20230101
compiler: ia64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>

smatch warnings:
drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c:467 h264_encode_frame() warn: missing error code? 'ret'

vim +/ret +467 drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c

2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 435 static int h264_encode_frame(struct venc_h264_inst *inst,
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 436 struct venc_frm_buf *frm_buf,
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 437 struct mtk_vcodec_mem *bs_buf,
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 438 unsigned int *bs_size)
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 439 {
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 440 int ret = 0;
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 441 unsigned int irq_status;
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 442 struct venc_frame_info frame_info;
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 443
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 444 mtk_vcodec_debug_enter(inst);
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 445 mtk_vcodec_debug(inst, "frm_cnt = %d\n ", inst->frm_cnt);
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 446 frame_info.frm_count = inst->frm_cnt;
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 447 frame_info.skip_frm_count = inst->skip_frm_cnt;
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 448 frame_info.frm_type = h264_frame_type(inst);
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 449 mtk_vcodec_debug(inst, "frm_count = %d,skip_frm_count =%d,frm_type=%d.\n",
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 450 frame_info.frm_count, frame_info.skip_frm_count,
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 451 frame_info.frm_type);
10d0f56800b313 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Dafna Hirschfeld 2021-10-22 452 ret = vpu_enc_encode(&inst->vpu_inst, H264_BS_MODE_FRAME, frm_buf, bs_buf, &frame_info);
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 453 if (ret)
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 454 return ret;
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 455
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 456 /*
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 457 * skip frame case: The skip frame buffer is composed by vpu side only,
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 458 * it does not trigger the hw, so skip the wait interrupt operation.
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 459 */
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 460 if (inst->vpu_inst.state == VEN_IPI_MSG_ENC_STATE_SKIP) {
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 461 *bs_size = inst->vpu_inst.bs_size;
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 462 memcpy(bs_buf->va,
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 463 inst->work_bufs[VENC_H264_VPU_WORK_BUF_SKIP_FRAME].va,
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 464 *bs_size);
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 465 ++inst->frm_cnt;
0dc4b328612579 drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Yunfei Dong 2020-08-21 466 ++inst->skip_frm_cnt;
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 @467 return ret;

This seems intentional. Just do "return 0;" here to make the code more
readable.

2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 468 }
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 469
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 470 irq_status = h264_enc_wait_venc_done(inst);
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 471 if (irq_status != MTK_VENC_IRQ_STATUS_FRM) {
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 472 mtk_vcodec_err(inst, "irq_status=%d failed", irq_status);
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 473 return -EIO;
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 474 }
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 475
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 476 *bs_size = h264_read_reg(inst, VENC_PIC_BITSTREAM_BYTE_CNT);
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 477
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 478 ++inst->frm_cnt;
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 479 mtk_vcodec_debug(inst, "frm %d bs_size %d key_frm %d <-",
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 480 inst->frm_cnt, *bs_size, inst->vpu_inst.is_key_frm);
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 481
2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 482 return ret;

Here too.

2cc93862d4840f drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c Tiffany Lin 2016-05-03 483 }

--
0-DAY CI Kernel Test Service
https://01.org/lkp