drivers: video: fbmem: add signed type cast for comparation.
PATCH 1/1 drivers: video: fbmem: add signed type cast for comparation.
For 'con2fb.framebuffer', it can be '-1' as an invalid value, so it need related type cast for its comparing.
The related warning:
drivers/video/fbmem.c:1169:3: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
--- drivers/video/fbmem.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/fbmem.c +1 -1
@@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,return -EFAULT ;if (con2fb.console <1 || con2fb.console >MAX_NR_CONSOLES )return -EINVAL ; -if (con2fb.framebuffer <0 || con2fb.framebuffer >=FB_MAX ) +if ((int )con2fb.framebuffer <0 || con2fb.framebuffer >=FB_MAX )return -EINVAL ;if (!registered_fb[con2fb.framebuffer])request_module ("fb%d" , con2fb.framebuffer);
Signature · 1 line
1.7.7.6
Quoted 18 lines · Chen Gang
For 'con2fb.framebuffer', it can be '-1' as an invalid value, so it need related type cast for its comparing.
The related warning:
drivers/video/fbmem.c:1169:3: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]Signed-off-by Chen Gang <[email protected]>--- drivers/video/fbmem.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/video/fbmem.c +0
-0
drivers/video/fbmem.c static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, · line 1170
Quoted 6 lines
drivers/video/fbmem.c +1
-1@@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,return -EFAULT ;if (con2fb.console <1 || con2fb.console >MAX_NR_CONSOLES )return -EINVAL ; -if (con2fb.framebuffer <0 || con2fb.framebuffer >=FB_MAX ) +if ((int )con2fb.framebuffer <0 || con2fb.framebuffer >=FB_MAX )return -EINVAL ;
Instead of adding the cast, you can also just remove the check, as it's useless. If it's `-1' for invalid, after conversion to unsigned, it will trigger the check
">= FB_MAX".
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 14 lines · Geert Uytterhoeven
Quoted 13 lines · Chen Gang
For 'con2fb.framebuffer', it can be '-1' as an invalid value, so it need related type cast for its comparing.
The related warning:
drivers/video/fbmem.c:1169:3: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]Signed-off-by Chen Gang <[email protected]>--- drivers/video/fbmem.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 17 lines
drivers/video/fbmem.c static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, · line 1170
Quoted 11 lines
drivers/video/fbmem.c +1
-1@@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,return -EFAULT ;if (con2fb.console <1 || con2fb.console >MAX_NR_CONSOLES )return -EINVAL ; -if (con2fb.framebuffer <0 || con2fb.framebuffer >=FB_MAX ) +if ((int )con2fb.framebuffer <0 || con2fb.framebuffer >=FB_MAX )return -EINVAL ;Instead of adding the cast, you can also just remove the check, as it's useless. If it's `-1' for invalid, after conversion to unsigned, it will trigger the check
">=FB_MAX".
OH, yes, thanks.
Original implementation is no issue (the compiler will skip the first checking automatically).
If suitable, I should send patch v2.
Thanks.
Quoted 12 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Signature · 1 line
Chen Gang