[hverkuil-media-tree:for-v5.20g 3/6] drivers/staging/media/wave5/wave5-vpu-dec.c:1338:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true

From: kernel test robot
Date: Thu Jun 30 2022 - 18:17:24 EST


tree: git://linuxtv.org/hverkuil/media_tree.git for-v5.20g
head: 4a01406b7d1d14a1789d2fde39e8803622a76a5f
commit: 06872f144660558e5bf17a3c8979d0fe39f8414a [3/6] staging: media: wave5: Add the v4l2 layer
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20220701/202207010647.LBFPssdW-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a774ba7f60d1fef403b5507b1b1a7475d3684d71)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git remote add hverkuil-media-tree git://linuxtv.org/hverkuil/media_tree.git
git fetch --no-tags hverkuil-media-tree for-v5.20g
git checkout 06872f144660558e5bf17a3c8979d0fe39f8414a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/staging/

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

All warnings (new ones prefixed by >>):

drivers/staging/media/wave5/wave5-vpu-dec.c:1143:7: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
int ret;
^
>> drivers/staging/media/wave5/wave5-vpu-dec.c:1338:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (kfifo_alloc(&inst->irq_status, 16 * sizeof(int), GFP_KERNEL)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kfifo.h:350:43: note: expanded from macro 'kfifo_alloc'
#define kfifo_alloc(fifo, size, gfp_mask) \
^
drivers/staging/media/wave5/wave5-vpu-dec.c:1358:9: note: uninitialized use occurs here
return ret;
^~~
drivers/staging/media/wave5/wave5-vpu-dec.c:1338:2: note: remove the 'if' if its condition is always false
if (kfifo_alloc(&inst->irq_status, 16 * sizeof(int), GFP_KERNEL)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/media/wave5/wave5-vpu-dec.c:1286:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
2 warnings generated.
--
>> drivers/staging/media/wave5/wave5-vpu.c:233:3: warning: format specifies type 'unsigned long long' but the argument has type 'dma_addr_t' (aka 'unsigned int') [-Wformat]
dev->sram_buf.daddr, dev->sram_buf.size);
^~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
_p_func(dev, fmt, ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
>> drivers/staging/media/wave5/wave5-vpu.c:233:24: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
dev->sram_buf.daddr, dev->sram_buf.size);
^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
_p_func(dev, fmt, ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
2 warnings generated.
--
drivers/staging/media/wave5/wave5-vpu-enc.c:1247:7: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
int ret;
^
>> drivers/staging/media/wave5/wave5-vpu-enc.c:1459:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (kfifo_alloc(&inst->irq_status, 16 * sizeof(int), GFP_KERNEL)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kfifo.h:350:43: note: expanded from macro 'kfifo_alloc'
#define kfifo_alloc(fifo, size, gfp_mask) \
^
drivers/staging/media/wave5/wave5-vpu-enc.c:1479:9: note: uninitialized use occurs here
return ret;
^~~
drivers/staging/media/wave5/wave5-vpu-enc.c:1459:2: note: remove the 'if' if its condition is always false
if (kfifo_alloc(&inst->irq_status, 16 * sizeof(int), GFP_KERNEL)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/media/wave5/wave5-vpu-enc.c:1379:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
2 warnings generated.


vim +1338 drivers/staging/media/wave5/wave5-vpu-dec.c

1280
1281 static int wave5_vpu_open_dec(struct file *filp)
1282 {
1283 struct video_device *vdev = video_devdata(filp);
1284 struct vpu_device *dev = video_drvdata(filp);
1285 struct vpu_instance *inst = NULL;
1286 int ret;
1287
1288 inst = kzalloc(sizeof(*inst), GFP_KERNEL);
1289 if (!inst)
1290 return -ENOMEM;
1291
1292 inst->dev = dev;
1293 inst->type = VPU_INST_TYPE_DEC;
1294 inst->ops = &wave5_vpu_dec_inst_ops;
1295
1296 v4l2_fh_init(&inst->v4l2_fh, vdev);
1297 filp->private_data = &inst->v4l2_fh;
1298 v4l2_fh_add(&inst->v4l2_fh);
1299
1300 INIT_LIST_HEAD(&inst->list);
1301 list_add_tail(&inst->list, &dev->instances);
1302
1303 inst->v4l2_m2m_dev = v4l2_m2m_init(&wave5_vpu_dec_m2m_ops);
1304 if (IS_ERR(inst->v4l2_m2m_dev)) {
1305 ret = PTR_ERR(inst->v4l2_m2m_dev);
1306 dev_err(inst->dev->dev, "v4l2_m2m_init fail: %d\n", ret);
1307 goto free_inst;
1308 }
1309
1310 inst->v4l2_fh.m2m_ctx =
1311 v4l2_m2m_ctx_init(inst->v4l2_m2m_dev, inst, wave5_vpu_dec_queue_init);
1312 if (IS_ERR(inst->v4l2_fh.m2m_ctx)) {
1313 ret = PTR_ERR(inst->v4l2_fh.m2m_ctx);
1314 goto err_m2m_release;
1315 }
1316
1317 v4l2_ctrl_handler_init(&inst->v4l2_ctrl_hdl, 10);
1318 v4l2_ctrl_new_custom(&inst->v4l2_ctrl_hdl, &wave5_vpu_thumbnail_mode, NULL);
1319 v4l2_ctrl_new_std(&inst->v4l2_ctrl_hdl, &wave5_vpu_dec_ctrl_ops,
1320 V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 32, 1, 1);
1321
1322 if (inst->v4l2_ctrl_hdl.error) {
1323 ret = -ENODEV;
1324 goto err_m2m_release;
1325 }
1326
1327 inst->v4l2_fh.ctrl_handler = &inst->v4l2_ctrl_hdl;
1328 v4l2_ctrl_handler_setup(&inst->v4l2_ctrl_hdl);
1329
1330 wave5_set_default_format(&inst->src_fmt, &inst->dst_fmt);
1331 inst->colorspace = V4L2_COLORSPACE_REC709;
1332 inst->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
1333 inst->hsv_enc = 0;
1334 inst->quantization = V4L2_QUANTIZATION_DEFAULT;
1335 inst->xfer_func = V4L2_XFER_FUNC_DEFAULT;
1336
1337 init_completion(&inst->irq_done);
> 1338 if (kfifo_alloc(&inst->irq_status, 16 * sizeof(int), GFP_KERNEL)) {
1339 dev_err(inst->dev->dev, "failed to allocate fifo\n");
1340 goto err_m2m_release;
1341 }
1342
1343 inst->id = ida_alloc(&inst->dev->inst_ida, GFP_KERNEL);
1344 if (inst->id < 0) {
1345 dev_warn(inst->dev->dev, "unable to allocate instance ID: %d\n", inst->id);
1346 ret = inst->id;
1347 goto err_kfifo_free;
1348 }
1349
1350 return 0;
1351
1352 err_kfifo_free:
1353 kfifo_free(&inst->irq_status);
1354 err_m2m_release:
1355 v4l2_m2m_release(inst->v4l2_m2m_dev);
1356 free_inst:
1357 kfree(inst);
1358 return ret;
1359 }
1360

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