* [PATCH] drivers/thermal/thermal_sys.c: fix strncmp tests
@ 2009-11-09 22:12 Joe Perches
2009-11-13 22:22 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2009-11-09 22:12 UTC (permalink / raw)
To: Zhang Rui, Sujith Thomas; +Cc: LKML
Use strncmp(var, "foo", sizeof("foo") - 1)
not strncmp(var, "foo", sizeof("foo"))
Signed-off-by: Joe Perches <joe@perches.com>
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 4e83c29..c35d538 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -147,9 +147,9 @@ mode_store(struct device *dev, struct device_attribute *attr,
if (!tz->ops->set_mode)
return -EPERM;
- if (!strncmp(buf, "enabled", sizeof("enabled")))
+ if (!strncmp(buf, "enabled", sizeof("enabled") - 1))
result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED);
- else if (!strncmp(buf, "disabled", sizeof("disabled")))
+ else if (!strncmp(buf, "disabled", sizeof("disabled") - 1))
result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED);
else
result = -EINVAL;
@@ -228,8 +228,8 @@ passive_store(struct device *dev, struct device_attribute *attr,
if (state && !tz->forced_passive) {
mutex_lock(&thermal_list_lock);
list_for_each_entry(cdev, &thermal_cdev_list, node) {
- if (!strncmp("Processor", cdev->type,
- sizeof("Processor")))
+ if (!strncmp(cdev->type, "Processor",
+ sizeof("Processor") - 1))
thermal_zone_bind_cooling_device(tz,
THERMAL_TRIPS_NONE,
cdev);
@@ -238,8 +238,8 @@ passive_store(struct device *dev, struct device_attribute *attr,
} else if (!state && tz->forced_passive) {
mutex_lock(&thermal_list_lock);
list_for_each_entry(cdev, &thermal_cdev_list, node) {
- if (!strncmp("Processor", cdev->type,
- sizeof("Processor")))
+ if (!strncmp(cdev->type, "Processor",
+ sizeof("Processor") - 1))
thermal_zone_unbind_cooling_device(tz,
THERMAL_TRIPS_NONE,
cdev);
@@ -796,7 +796,7 @@ static void thermal_release(struct device *dev)
struct thermal_zone_device *tz;
struct thermal_cooling_device *cdev;
- if (!strncmp(dev_name(dev), "thermal_zone", sizeof "thermal_zone" - 1)) {
+ if (!strncmp(dev_name(dev), "thermal_zone", sizeof("thermal_zone") - 1)) {
tz = to_thermal_zone(dev);
kfree(tz);
} else {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers/thermal/thermal_sys.c: fix strncmp tests
2009-11-09 22:12 [PATCH] drivers/thermal/thermal_sys.c: fix strncmp tests Joe Perches
@ 2009-11-13 22:22 ` Andrew Morton
2009-11-13 23:37 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2009-11-13 22:22 UTC (permalink / raw)
To: Joe Perches; +Cc: Zhang Rui, Sujith Thomas, LKML
On Mon, 09 Nov 2009 14:12:49 -0800
Joe Perches <joe@perches.com> wrote:
> Use strncmp(var, "foo", sizeof("foo") - 1)
> not strncmp(var, "foo", sizeof("foo"))
>
> Signed-off-by: Joe Perches <joe@perches.com>
>
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 4e83c29..c35d538 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -147,9 +147,9 @@ mode_store(struct device *dev, struct device_attribute *attr,
> if (!tz->ops->set_mode)
> return -EPERM;
>
> - if (!strncmp(buf, "enabled", sizeof("enabled")))
> + if (!strncmp(buf, "enabled", sizeof("enabled") - 1))
How about
if (!strcmp(buf, "enabled"))
?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers/thermal/thermal_sys.c: fix strncmp tests
2009-11-13 22:22 ` Andrew Morton
@ 2009-11-13 23:37 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2009-11-13 23:37 UTC (permalink / raw)
To: Andrew Morton; +Cc: Zhang Rui, Sujith Thomas, LKML
On Fri, 2009-11-13 at 14:22 -0800, Andrew Morton wrote:
> On Mon, 09 Nov 2009 14:12:49 -0800
> Joe Perches <joe@perches.com> wrote:
>
> > Use strncmp(var, "foo", sizeof("foo") - 1)
> > not strncmp(var, "foo", sizeof("foo"))
> >
> > Signed-off-by: Joe Perches <joe@perches.com>
> >
> > diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> > index 4e83c29..c35d538 100644
> > --- a/drivers/thermal/thermal_sys.c
> > +++ b/drivers/thermal/thermal_sys.c
> > @@ -147,9 +147,9 @@ mode_store(struct device *dev, struct device_attribute *attr,
> > if (!tz->ops->set_mode)
> > return -EPERM;
> >
> > - if (!strncmp(buf, "enabled", sizeof("enabled")))
> > + if (!strncmp(buf, "enabled", sizeof("enabled") - 1))
>
> How about
>
> if (!strcmp(buf, "enabled"))
Fine with me.
I think strncmp(foo, "bar", sizeof("bar"))
where foo has a trailing 0 should be
converted to strcmp(foo, "bar");
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-13 23:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-09 22:12 [PATCH] drivers/thermal/thermal_sys.c: fix strncmp tests Joe Perches
2009-11-13 22:22 ` Andrew Morton
2009-11-13 23:37 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®