Skip to content

Commit 3fb0cf4

Browse files
sudarsan-22fabiobaltieri
authored andcommitted
drivers: video: fix uninitialized struct
Zero-initialize fmt to fix Coverity. CID:525180 CID 524760 CID 524753 CID 524781 CID 524755 Signed-off-by: sudarsan N <sudarsansamy2002@gmail.com>
1 parent ab99a53 commit 3fb0cf4

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

drivers/video/mt9m114.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,11 @@ static int mt9m114_init_controls(const struct device *dev)
528528
static int mt9m114_init(const struct device *dev)
529529
{
530530
const struct mt9m114_config *cfg = dev->config;
531-
struct video_format fmt;
531+
struct video_format fmt = {
532+
.pixelformat = VIDEO_PIX_FMT_RGB565,
533+
.width = 480,
534+
.height = 272,
535+
};
532536
uint16_t val;
533537
int ret;
534538

@@ -561,11 +565,6 @@ static int mt9m114_init(const struct device *dev)
561565
return ret;
562566
}
563567

564-
/* Set default format to 480x272 RGB565 */
565-
fmt.pixelformat = VIDEO_PIX_FMT_RGB565;
566-
fmt.width = 480;
567-
fmt.height = 272;
568-
569568
ret = mt9m114_set_fmt(dev, &fmt);
570569
if (ret) {
571570
LOG_ERR("Unable to configure default format");

drivers/video/ov5640.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ static int ov5640_init_controls(const struct device *dev)
13241324
static int ov5640_init(const struct device *dev)
13251325
{
13261326
const struct ov5640_config *cfg = dev->config;
1327-
struct video_format fmt;
1327+
struct video_format fmt = {0};
13281328
uint16_t chip_id;
13291329
int ret;
13301330

drivers/video/ov7670.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,11 @@ static int ov7670_init(const struct device *dev)
489489
const struct ov7670_config *config = dev->config;
490490
int ret, i;
491491
uint8_t pid;
492-
struct video_format fmt;
492+
struct video_format fmt = {
493+
.pixelformat = VIDEO_PIX_FMT_RGB565,
494+
.width = 320,
495+
.height = 240,
496+
};
493497
const struct ov7670_reg *reg;
494498

495499
if (!i2c_is_ready_dt(&config->bus)) {
@@ -563,10 +567,6 @@ static int ov7670_init(const struct device *dev)
563567
/* Delay after reset */
564568
k_msleep(5);
565569

566-
/* Set default camera format (QVGA, YUYV) */
567-
fmt.pixelformat = VIDEO_PIX_FMT_RGB565;
568-
fmt.width = 320;
569-
fmt.height = 240;
570570
ret = ov7670_set_fmt(dev, &fmt);
571571
if (ret < 0) {
572572
return ret;

drivers/video/ov9655.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,12 @@ static int ov9655_get_fmt(const struct device *dev, struct video_format *fmt)
326326
static int ov9655_init(const struct device *dev)
327327
{
328328
const struct ov9655_config *config = dev->config;
329-
struct video_format fmt;
329+
/* Set default camera format (QQVGA, YUYV) */
330+
struct video_format fmt = {
331+
.pixelformat = VIDEO_PIX_FMT_YUYV,
332+
.width = 160,
333+
.height = 120,
334+
};
330335
uint32_t pid;
331336
int ret;
332337

@@ -380,11 +385,6 @@ static int ov9655_init(const struct device *dev)
380385
return -ENODEV;
381386
}
382387

383-
/* Set default camera format (QQVGA, YUYV) */
384-
fmt.pixelformat = VIDEO_PIX_FMT_YUYV;
385-
fmt.width = 160;
386-
fmt.height = 120;
387-
388388
return ov9655_set_fmt(dev, &fmt);
389389
}
390390

drivers/video/video_emul_imager.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@ static int emul_imager_init_controls(const struct device *dev)
344344

345345
int emul_imager_init(const struct device *dev)
346346
{
347-
struct video_format fmt;
347+
struct video_format fmt = {
348+
.pixelformat = fmts[0].pixelformat,
349+
.width = fmts[0].width_min,
350+
.height = fmts[0].height_min,
351+
};
348352
uint8_t sensor_id;
349353
int ret;
350354

@@ -365,10 +369,6 @@ int emul_imager_init(const struct device *dev)
365369
return ret;
366370
}
367371

368-
fmt.pixelformat = fmts[0].pixelformat;
369-
fmt.width = fmts[0].width_min;
370-
fmt.height = fmts[0].height_min;
371-
372372
ret = emul_imager_set_fmt(dev, &fmt);
373373
if (ret < 0) {
374374
LOG_ERR("Failed to set to default format %x %ux%u",

0 commit comments

Comments
 (0)