* [PATCH] acpi: clean up video.c boundary checks and types
@ 2009-10-01 22:51 Arjan van de Ven
2009-10-28 15:56 ` Len Brown
0 siblings, 1 reply; 2+ messages in thread
From: Arjan van de Ven @ 2009-10-01 22:51 UTC (permalink / raw)
To: len.brown; +Cc: linux-acpi, akpm
>From 1e96af755961a028c888ba9e49c1d4c17c8a4442 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
Date: Thu, 1 Oct 2009 15:48:40 -0700
Subject: [PATCH] acpi: clean up video.c boundary checks and types
proc.c and video.c are a bit sloppy around types and style,
confusing gcc for a new feature that'll be in 2.6.33 and will
cause a warning on the current code.
This patch changes
if (foo + 1 > sizeof bar)
into
if (foo >= sizeof(bar))
which is more kernel-style.
it also changes a variable in proc.c to unsigned; it gets assigned
a value from an unsigned type, and is then only compared for > not
for negative, so using unsigned is just outright the right type
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
drivers/acpi/proc.c | 2 +-
drivers/acpi/video.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index d0d550d..ceff3ad 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -393,7 +393,7 @@ acpi_system_write_wakeup_device(struct file *file,
struct list_head *node, *next;
char strbuf[5];
char str[5] = "";
- int len = count;
+ unsigned int len = count;
struct acpi_device *found_dev = NULL;
if (len > 4)
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index a4fddb2..2868303 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1218,7 +1218,7 @@ acpi_video_device_write_state(struct file *file,
u32 state = 0;
- if (!dev || count + 1 > sizeof str)
+ if (!dev || count >= sizeof(str))
return -EINVAL;
if (copy_from_user(str, buffer, count))
@@ -1275,7 +1275,7 @@ acpi_video_device_write_brightness(struct file *file,
int i;
- if (!dev || !dev->brightness || count + 1 > sizeof str)
+ if (!dev || !dev->brightness || count >= sizeof(str))
return -EINVAL;
if (copy_from_user(str, buffer, count))
@@ -1557,7 +1557,7 @@ acpi_video_bus_write_POST(struct file *file,
unsigned long long opt, options;
- if (!video || count + 1 > sizeof str)
+ if (!video || count >= sizeof(str))
return -EINVAL;
status = acpi_video_bus_POST_options(video, &options);
@@ -1597,7 +1597,7 @@ acpi_video_bus_write_DOS(struct file *file,
unsigned long opt;
- if (!video || count + 1 > sizeof str)
+ if (!video || count >= sizeof(str))
return -EINVAL;
if (copy_from_user(str, buffer, count))
--
1.6.2.5
--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] acpi: clean up video.c boundary checks and types
2009-10-01 22:51 [PATCH] acpi: clean up video.c boundary checks and types Arjan van de Ven
@ 2009-10-28 15:56 ` Len Brown
0 siblings, 0 replies; 2+ messages in thread
From: Len Brown @ 2009-10-28 15:56 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: linux-acpi, Andrew Morton
applied
thanks,
Len Brown, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-10-28 16:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-01 22:51 [PATCH] acpi: clean up video.c boundary checks and types Arjan van de Ven
2009-10-28 15:56 ` Len Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox