lkml.org 
[lkml]   [2009]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] drivers/thermal/thermal_sys.c: fix strncmp tests
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"))

?


\
 
 \ /
  Last update: 2009-11-13 23:25    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog