Skip to contentSkip to conversation

Zero dev in main()

PATCH In review Sakari Ailus 2 participants 2 messages Nov 23, 2018 – Nov 30, 2018 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Zero dev in main()

From: Sakari Ailus <[email protected]>

This is necessary since video_open() may not be always called soon

---
 yavta.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
yavta.c +1 -2
index c7986bd..de5376d 100644
@@ -342,7 +342,6 @@ static bool video_has_valid_buf_type(struct device *dev)
 
 static void video_init(struct device *dev)
 {
-	memset(dev, 0, sizeof *dev);
 	dev->fd = -1;
 	dev->memtype = V4L2_MEMORY_MMAP;
 	dev->buffers = NULL;
@@ -1903,7 +1902,7 @@ static struct option opts[] = {
 int main(int argc, char *argv[])
 {
 	struct sched_param sched;
-	struct device dev;
+	struct device dev = { 0 };
 	int ret;
 
 	/* Options parsings */
Signature · 1 line
2.11.0
#1 lore raw

Hi Sakari,

Thank you for the patch.

Quoted 3 lines · On Thursday, 22 November 2018 17:29:56 EET Sakari Ailus wrote:

From: Sakari Ailus <[email protected]>

This is necessary since video_open() may not be always called soon

Do you mean video_init() ? Isn't it called at the very first line of main() ?

Quoted 26 lines
---
 yavta.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
yavta.c +1 -2
index c7986bd..de5376d 100644
@@ -342,7 +342,6 @@ static bool video_has_valid_buf_type(struct device *dev)
 
 static void video_init(struct device *dev)
 {
-	memset(dev, 0, sizeof *dev);
 	dev->fd = -1;
 	dev->memtype = V4L2_MEMORY_MMAP;
 	dev->buffers = NULL;
@@ -1903,7 +1902,7 @@ static struct option opts[] = {
 int main(int argc, char *argv[])
 {
 	struct sched_param sched;
-	struct device dev;
+	struct device dev = { 0 };
 	int ret;
 
 	/* Options parsings */
Signature · 3 lines
Regards,

Laurent Pinchart