* [PATCH] drivers: video: fbmem: add signed type cast for comparation.
@ 2013-07-22 8:07 Chen Gang
2013-07-22 11:16 ` Geert Uytterhoeven
2013-07-23 0:04 ` Chen Gang
0 siblings, 2 replies; 3+ messages in thread
From: Chen Gang @ 2013-07-22 8:07 UTC (permalink / raw)
To: linux-fbdev
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 <gang.chen@asianux.com>
---
drivers/video/fbmem.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 36e1fe2..8e8225c 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -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);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: video: fbmem: add signed type cast for comparation.
2013-07-22 8:07 [PATCH] drivers: video: fbmem: add signed type cast for comparation Chen Gang
@ 2013-07-22 11:16 ` Geert Uytterhoeven
2013-07-23 0:04 ` Chen Gang
1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2013-07-22 11:16 UTC (permalink / raw)
To: linux-fbdev
On Mon, Jul 22, 2013 at 10:07 AM, Chen Gang <gang.chen@asianux.com> wrote:
> 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 <gang.chen@asianux.com>
> ---
> drivers/video/fbmem.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 36e1fe2..8e8225c 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -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 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: video: fbmem: add signed type cast for comparation.
2013-07-22 8:07 [PATCH] drivers: video: fbmem: add signed type cast for comparation Chen Gang
2013-07-22 11:16 ` Geert Uytterhoeven
@ 2013-07-23 0:04 ` Chen Gang
1 sibling, 0 replies; 3+ messages in thread
From: Chen Gang @ 2013-07-23 0:04 UTC (permalink / raw)
To: linux-fbdev
On 07/22/2013 07:16 PM, Geert Uytterhoeven wrote:
> On Mon, Jul 22, 2013 at 10:07 AM, Chen Gang <gang.chen@asianux.com> wrote:
>> 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 <gang.chen@asianux.com>
>> ---
>> drivers/video/fbmem.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
>> index 36e1fe2..8e8225c 100644
>> --- a/drivers/video/fbmem.c
>> +++ b/drivers/video/fbmem.c
>> @@ -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.
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> 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
>
>
--
Chen Gang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-23 0:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-22 8:07 [PATCH] drivers: video: fbmem: add signed type cast for comparation Chen Gang
2013-07-22 11:16 ` Geert Uytterhoeven
2013-07-23 0:04 ` Chen Gang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).