Re: [PATCH 2/2] media: i2c: Add driver for Aptina MT9V111

From: kbuild test robot
Date: Mon Jun 11 2018 - 12:45:21 EST


Hi Jacopo,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.17 next-20180608]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Jacopo-Mondi/media-i2c-mt9v111-sensor-driver/20180611-233038
base: git://linuxtv.org/media_tree.git master
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=sh

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

drivers/media/i2c/mt9v111.c: In function 'mt9v111_set_format':
>> drivers/media/i2c/mt9v111.c:929:15: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
unsigned int idx;
^~~

vim +/idx +929 drivers/media/i2c/mt9v111.c

920
921 static int mt9v111_set_format(struct v4l2_subdev *subdev,
922 struct v4l2_subdev_pad_config *cfg,
923 struct v4l2_subdev_format *format)
924 {
925 struct mt9v111_dev *mt9v111 = sd_to_mt9v111(subdev);
926 struct v4l2_mbus_framefmt new_fmt;
927 struct v4l2_mbus_framefmt *__fmt;
928 unsigned int best_fit = ~0L;
> 929 unsigned int idx;
930 unsigned int i;
931
932 mutex_lock(&mt9v111->stream_mutex);
933 if (mt9v111->streaming) {
934 mutex_unlock(&mt9v111->stream_mutex);
935 return -EBUSY;
936 }
937 mutex_unlock(&mt9v111->stream_mutex);
938
939 if (format->pad)
940 return -EINVAL;
941
942 /* Update mbus format code and sizes. */
943 for (i = 0; i < ARRAY_SIZE(mt9v111_formats); i++) {
944 if (format->format.code == mt9v111_formats[i].code) {
945 new_fmt.code = mt9v111_formats[i].code;
946 break;
947 }
948 }
949 if (i == ARRAY_SIZE(mt9v111_formats))
950 new_fmt.code = mt9v111_formats[0].code;
951
952 for (i = 0; i < ARRAY_SIZE(mt9v111_frame_sizes); i++) {
953 unsigned int fit = abs(mt9v111_frame_sizes[i].width -
954 format->format.width) +
955 abs(mt9v111_frame_sizes[i].height -
956 format->format.height);
957 if (fit < best_fit) {
958 best_fit = fit;
959 idx = i;
960
961 if (fit == 0)
962 break;
963 }
964 }
965 new_fmt.width = mt9v111_frame_sizes[idx].width;
966 new_fmt.height = mt9v111_frame_sizes[idx].height;
967
968 /* Update the device (or pad) format if it has changed. */
969 __fmt = __mt9v111_get_pad_format(mt9v111, cfg, format->pad,
970 format->which);
971
972 /* Format hasn't changed, stop here. */
973 if (__fmt->code == new_fmt.code &&
974 __fmt->width == new_fmt.width &&
975 __fmt->height == new_fmt.height)
976 goto done;
977
978 /* Update the format and sizes, then mark changes as pending. */
979 __fmt->code = new_fmt.code;
980 __fmt->width = new_fmt.width;
981 __fmt->height = new_fmt.height;
982
983 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
984 mt9v111->pending = true;
985
986 dev_info(mt9v111->dev, "%s: mbus_code: %x - (%ux%u)\n",
987 __func__, __fmt->code, __fmt->width, __fmt->height);
988
989 done:
990 format->format = *__fmt;
991
992 return 0;
993 }
994

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip