Skip to contentSkip to conversation

drivers: video: fbcmap: add signed type cast for comparation

PATCH In review Chen Gang 2 participants 3 messages Jul 22, 2013 – Aug 20, 2013 Framebuffer layer

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 drivers: video: fbcmap: add signed type cast for comparation

According to fb_set_cmap() in this file, knows about it is necessary to check 'start' whether less than zero or not, so need add related type cast for its comparing.

The related warning:

drivers/video/fbcmap.c:288:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

---
 drivers/video/fbcmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/fbcmap.c +1 -1
index 5c3960d..44c88e3 100644
@@ -285,7 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
 		rc = -ENODEV;
 		goto out;
 	}
-	if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
+	if ((int)cmap->start < 0 || (!info->fbops->fb_setcolreg &&
 				!info->fbops->fb_setcmap)) {
 		rc = -EINVAL;
 		goto out1;
Signature · 1 line
1.7.7.6
#1 lore raw

Hi

Quoted 19 lines · Chen Gang

According to fb_set_cmap() in this file, knows about it is necessary to check 'start' whether less than zero or not, so need add related type cast for its comparing.

The related warning:

drivers/video/fbcmap.c:288:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

---
 drivers/video/fbcmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/fbcmap.c +0 -0
index 5c3960d..44c88e3 100644

drivers/video/fbcmap.c int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info) · line 289

Quoted 6 lines
drivers/video/fbcmap.c +1 -1
@@ -285,7 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
                rc = -ENODEV;
                goto out;
        }
-       if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
+       if ((int)cmap->start < 0 || (!info->fbops->fb_setcolreg &&
                                !info->fbops->fb_setcmap)) {

What's the reason to do this, anyway? fb_set_cmap() does the same but actually casts to a signed integer. So I think we can remove this check here.

Regards
David

Quoted 8 lines
drivers/video/fbcmap.c +0 -1
                rc = -EINVAL;
                goto out1;
--

1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw
In reply to Chen Gang
Quoted 17 lines · David Herrmann

Hi

Quoted 14 lines · Chen Gang

According to fb_set_cmap() in this file, knows about it is necessary to check 'start' whether less than zero or not, so need add related type cast for its comparing.

The related warning:

drivers/video/fbcmap.c:288:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

---
 drivers/video/fbcmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 16 lines

drivers/video/fbcmap.c int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info) · line 289

Quoted 11 lines
drivers/video/fbcmap.c +1 -1
index 5c3960d..44c88e3 100644
@@ -285,7 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
                rc = -ENODEV;
                goto out;
        }
-       if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
+       if ((int)cmap->start < 0 || (!info->fbops->fb_setcolreg &&
                                !info->fbops->fb_setcmap)) {

What's the reason to do this, anyway? fb_set_cmap() does the same but actually casts to a signed integer. So I think we can remove this check here.

OK, that sounds reasonable to me, and now my mail client is OK, I will send patch v2 for it.

:-)

Quoted 13 lines

Regards
David

Quoted 8 lines
drivers/video/fbcmap.c +0 -1
                rc = -EINVAL;
                goto out1;
--

1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Chen Gang