Commit 8d7cd91d authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

staging: atomisp: avoid false-positive maybe-uninitialized warning

In combination with CONFIG_PROFILE_ANNOTATED_BRANCHES=y, the unlikely()
inside of the WARN() macro becomes too complex for gcc to see that
we don't use the output arguments of mt9m114_to_res() are used
correctly:

drivers/staging/media/atomisp/i2c/mt9m114.c: In function 'mt9m114_get_fmt':
drivers/staging/media/atomisp/i2c/mt9m114.c:817:13: error: 'height' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  int width, height;
             ^~~~~~
drivers/staging/media/atomisp/i2c/mt9m114.c: In function 'mt9m114_s_exposure_selection':
drivers/staging/media/atomisp/i2c/mt9m114.c:1179:13: error: 'height' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Without WARN_ON(), there is no problem, so by simply replacing it with
v4l2_err(), the warnings go away. The WARN() output is also not needed
here, as we'd probably catch the problem before even getting here,
and other checks for the same condition already use v4l2_err.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7afe8f84
......@@ -689,12 +689,13 @@ static struct mt9m114_res_struct *mt9m114_to_res(u32 w, u32 h)
return &mt9m114_res[index];
}
static int mt9m114_res2size(unsigned int res, int *h_size, int *v_size)
static int mt9m114_res2size(struct v4l2_subdev *sd, int *h_size, int *v_size)
{
struct mt9m114_device *dev = to_mt9m114_sensor(sd);
unsigned short hsize;
unsigned short vsize;
switch (res) {
switch (dev->res) {
case MT9M114_RES_736P:
hsize = MT9M114_RES_736P_SIZE_H;
vsize = MT9M114_RES_736P_SIZE_V;
......@@ -708,7 +709,8 @@ static int mt9m114_res2size(unsigned int res, int *h_size, int *v_size)
vsize = MT9M114_RES_960P_SIZE_V;
break;
default:
WARN(1, "%s: Resolution 0x%08x unknown\n", __func__, res);
v4l2_err(sd, "%s: Resolution 0x%08x unknown\n", __func__,
dev->res);
return -EINVAL;
}
......@@ -813,14 +815,13 @@ static int mt9m114_get_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_format *format)
{
struct v4l2_mbus_framefmt *fmt = &format->format;
struct mt9m114_device *dev = to_mt9m114_sensor(sd);
int width, height;
int ret;
if (format->pad)
return -EINVAL;
fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
ret = mt9m114_res2size(dev->res, &width, &height);
ret = mt9m114_res2size(sd, &width, &height);
if (ret)
return ret;
fmt->width = width;
......@@ -1174,7 +1175,6 @@ static int mt9m114_s_exposure_selection(struct v4l2_subdev *sd,
struct v4l2_subdev_selection *sel)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct mt9m114_device *dev = to_mt9m114_sensor(sd);
struct misensor_reg exp_reg;
int width, height;
int grid_width, grid_height;
......@@ -1192,7 +1192,7 @@ static int mt9m114_s_exposure_selection(struct v4l2_subdev *sd,
grid_right = sel->r.left + sel->r.width - 1;
grid_bottom = sel->r.top + sel->r.height - 1;
ret = mt9m114_res2size(dev->res, &width, &height);
ret = mt9m114_res2size(sd, &width, &height);
if (ret)
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment