Skip to contentSkip to conversation

video: mmpfb: cleanup some static checker warnings in probe()

PATCH In review Dan Carpenter 3 participants 3 messages Apr 14, 2014 – Apr 30, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: mmpfb: cleanup some static checker warnings in probe()

Sparse complains about using zero instead of NULL for pointers. Probably, if we enabled the warning, then GCC would complain about the unused initializers. I've just removed them.

Smatch complains that we first check if "fbi" is NULL and then dereference it in the error handling. It turns out that "fbi" can't be NULL so I've removed the check.

drivers/video/fbdev/mmp/fb/mmpfb.c +2 -7
index 7ab31eb..910fcc6 100644
@@ -554,8 +554,8 @@ static void fb_info_clear(struct fb_info *info)
 static int mmpfb_probe(struct platform_device *pdev)
 {
 	struct mmp_buffer_driver_mach_info *mi;
-	struct fb_info *info = 0;
-	struct mmpfb_info *fbi = 0;
+	struct fb_info *info;
+	struct mmpfb_info *fbi;
 	int ret, modes_num;
 
 	mi = pdev->dev.platform_data;
@@ -569,10 +569,6 @@ static int mmpfb_probe(struct platform_device *pdev)
 	if (info = NULL)
 		return -ENOMEM;
 	fbi = info->par;
-	if (!fbi) {
-		ret = -EINVAL;
-		goto failed;
-	}
 
 	/* init fb */
 	fbi->fb_info = info;
@@ -667,7 +663,6 @@ failed_free_buff:
 		fbi->fb_start_dma);
 failed_destroy_mutex:
 	mutex_destroy(&fbi->access_ok);
-failed:
 	dev_err(fbi->dev, "mmp-fb: frame buffer device init failed\n");
 
 	framebuffer_release(info);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Dan Carpenter

Sparse complains about using zero instead of NULL for pointers. Probably, if we enabled the warning, then GCC would complain about the unused initializers. I've just removed them.

Smatch complains that we first check if "fbi" is NULL and then dereference it in the error handling. It turns out that "fbi" can't be NULL so I've removed the check.

Yes, right.
'fbi' cannot be NULL, because 'info->par' is set as below.

./drivers/video/fbsysfs.c
struct fb_info *framebuffer_alloc(size_t size, struct device *dev) {
.....

        info = (struct fb_info *) p;

        if (size)
                info->par = p + fb_info_size;
Quoted 2 lines

Best regards,
Jingoo Han

Quoted 35 lines
drivers/video/fbdev/mmp/fb/mmpfb.c +2 -7
index 7ab31eb..910fcc6 100644
@@ -554,8 +554,8 @@ static void fb_info_clear(struct fb_info *info)
 static int mmpfb_probe(struct platform_device *pdev)
 {
 	struct mmp_buffer_driver_mach_info *mi;
-	struct fb_info *info = 0;
-	struct mmpfb_info *fbi = 0;
+	struct fb_info *info;
+	struct mmpfb_info *fbi;
 	int ret, modes_num;
 
 	mi = pdev->dev.platform_data;
@@ -569,10 +569,6 @@ static int mmpfb_probe(struct platform_device *pdev)
 	if (info = NULL)
 		return -ENOMEM;
 	fbi = info->par;
-	if (!fbi) {
-		ret = -EINVAL;
-		goto failed;
-	}
 
 	/* init fb */
 	fbi->fb_info = info;
@@ -667,7 +663,6 @@ failed_free_buff:
 		fbi->fb_start_dma);
 failed_destroy_mutex:
 	mutex_destroy(&fbi->access_ok);
-failed:
 	dev_err(fbi->dev, "mmp-fb: frame buffer device init failed\n");
 
 	framebuffer_release(info);
#2 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter

Sparse complains about using zero instead of NULL for pointers. Probably, if we enabled the warning, then GCC would complain about the unused initializers. I've just removed them.

Smatch complains that we first check if "fbi" is NULL and then dereference it in the error handling. It turns out that "fbi" can't be NULL so I've removed the check.

Thanks, queued for 3.16.

Tomi