All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] configfs: documentation: remove unneeded check
@ 2010-10-27 10:07 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2010-10-27 10:07 UTC (permalink / raw)
  To: Randy Dunlap, joel.becker; +Cc: linux-kernel, linux-doc, kernel-janitors

If "p" is NULL then it will cause an oops when we pass it to
simple_strtoul().  In this case "p" can not be NULL so I removed the
check and cleaned up the rest of the if condition as well.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
index d428cc9..63ff248 100644
--- a/Documentation/filesystems/configfs/configfs_example_explicit.c
+++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
@@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
 	char *p = (char *) page;
 
 	tmp = simple_strtoul(p, &p, 10);
-	if (!p || (*p && (*p != '\n')))
+	if (*p != '\0' && *p != '\n')
 		return -EINVAL;
 
 	if (tmp > INT_MAX)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [patch] configfs: documentation: remove unneeded check
@ 2010-10-27 10:07 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2010-10-27 10:07 UTC (permalink / raw)
  To: Randy Dunlap, joel.becker; +Cc: linux-kernel, linux-doc, kernel-janitors

If "p" is NULL then it will cause an oops when we pass it to
simple_strtoul().  In this case "p" can not be NULL so I removed the
check and cleaned up the rest of the if condition as well.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
index d428cc9..63ff248 100644
--- a/Documentation/filesystems/configfs/configfs_example_explicit.c
+++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
@@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
 	char *p = (char *) page;
 
 	tmp = simple_strtoul(p, &p, 10);
-	if (!p || (*p && (*p != '\n')))
+	if (*p != '\0' && *p != '\n')
 		return -EINVAL;
 
 	if (tmp > INT_MAX)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [patch] configfs: documentation: remove unneeded check
  2010-10-27 10:07 ` Dan Carpenter
@ 2010-10-27 11:22   ` Joel Becker
  -1 siblings, 0 replies; 8+ messages in thread
From: Joel Becker @ 2010-10-27 11:22 UTC (permalink / raw)
  To: Dan Carpenter, Randy Dunlap, linux-kernel, linux-doc, kernel-janitors

On Wed, Oct 27, 2010 at 12:07:35PM +0200, Dan Carpenter wrote:
> If "p" is NULL then it will cause an oops when we pass it to
> simple_strtoul().  In this case "p" can not be NULL so I removed the
> check and cleaned up the rest of the if condition as well.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
> index d428cc9..63ff248 100644
> --- a/Documentation/filesystems/configfs/configfs_example_explicit.c
> +++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
> @@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
>  	char *p = (char *) page;
>  
>  	tmp = simple_strtoul(p, &p, 10);
> -	if (!p || (*p && (*p != '\n')))
> +	if (*p != '\0' && *p != '\n')
>  		return -EINVAL;

	If you're going to prefer "*p != '\0'" to "*p" as a test, I'd
like you to include parens: "if ((*p != '\0') && (*p != '\n'))"  While
the order of precedence is correct in your change, it makes folks have
to stop and think about order of precedence in the first place.

Joel

-- 

Life's Little Instruction Book #444

	"Never underestimate the power of a kind word or deed."

Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] configfs: documentation: remove unneeded check
@ 2010-10-27 11:22   ` Joel Becker
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Becker @ 2010-10-27 11:22 UTC (permalink / raw)
  To: Dan Carpenter, Randy Dunlap, linux-kernel, linux-doc, kernel-janitors

On Wed, Oct 27, 2010 at 12:07:35PM +0200, Dan Carpenter wrote:
> If "p" is NULL then it will cause an oops when we pass it to
> simple_strtoul().  In this case "p" can not be NULL so I removed the
> check and cleaned up the rest of the if condition as well.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
> index d428cc9..63ff248 100644
> --- a/Documentation/filesystems/configfs/configfs_example_explicit.c
> +++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
> @@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
>  	char *p = (char *) page;
>  
>  	tmp = simple_strtoul(p, &p, 10);
> -	if (!p || (*p && (*p != '\n')))
> +	if (*p != '\0' && *p != '\n')
>  		return -EINVAL;

	If you're going to prefer "*p != '\0'" to "*p" as a test, I'd
like you to include parens: "if ((*p != '\0') && (*p != '\n'))"  While
the order of precedence is correct in your change, it makes folks have
to stop and think about order of precedence in the first place.

Joel

-- 

Life's Little Instruction Book #444

	"Never underestimate the power of a kind word or deed."

Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch v2] configfs: documentation: remove unneeded check
  2010-10-27 11:22   ` Joel Becker
@ 2010-10-27 14:50     ` Dan Carpenter
  -1 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2010-10-27 14:50 UTC (permalink / raw)
  To: Joel Becker; +Cc: Randy Dunlap, linux-kernel, linux-doc, kernel-janitors

If "p" is NULL then it will cause an oops when we pass it to
simple_strtoul().  In this case "p" can not be NULL so I removed the
check.  I also changed the check a little to make it more explicit that
we are testing whether p points to the NUL char.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
V2: Added some parenthesis to make the precedence more clear.

diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
index d428cc9..63ff248 100644
--- a/Documentation/filesystems/configfs/configfs_example_explicit.c
+++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
@@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
 	char *p = (char *) page;
 
 	tmp = simple_strtoul(p, &p, 10);
-	if (!p || (*p && (*p != '\n')))
+	if ((*p != '\0') && (*p != '\n'))
 		return -EINVAL;
 
 	if (tmp > INT_MAX)


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [patch v2] configfs: documentation: remove unneeded check
@ 2010-10-27 14:50     ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2010-10-27 14:50 UTC (permalink / raw)
  To: Joel Becker; +Cc: Randy Dunlap, linux-kernel, linux-doc, kernel-janitors

If "p" is NULL then it will cause an oops when we pass it to
simple_strtoul().  In this case "p" can not be NULL so I removed the
check.  I also changed the check a little to make it more explicit that
we are testing whether p points to the NUL char.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
V2: Added some parenthesis to make the precedence more clear.

diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
index d428cc9..63ff248 100644
--- a/Documentation/filesystems/configfs/configfs_example_explicit.c
+++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
@@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
 	char *p = (char *) page;
 
 	tmp = simple_strtoul(p, &p, 10);
-	if (!p || (*p && (*p != '\n')))
+	if ((*p != '\0') && (*p != '\n'))
 		return -EINVAL;
 
 	if (tmp > INT_MAX)


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [patch v2] configfs: documentation: remove unneeded check
  2010-10-27 14:50     ` Dan Carpenter
@ 2010-10-28 11:55       ` Joel Becker
  -1 siblings, 0 replies; 8+ messages in thread
From: Joel Becker @ 2010-10-28 11:55 UTC (permalink / raw)
  To: Dan Carpenter, Randy Dunlap, linux-kernel, linux-doc, kernel-janitors

On Wed, Oct 27, 2010 at 04:50:31PM +0200, Dan Carpenter wrote:
> If "p" is NULL then it will cause an oops when we pass it to
> simple_strtoul().  In this case "p" can not be NULL so I removed the
> check.  I also changed the check a little to make it more explicit that
> we are testing whether p points to the NUL char.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Acked-by: Joel Becker <joel.becker@oracle.com>

> ---
> V2: Added some parenthesis to make the precedence more clear.
> 
> diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
> index d428cc9..63ff248 100644
> --- a/Documentation/filesystems/configfs/configfs_example_explicit.c
> +++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
> @@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
>  	char *p = (char *) page;
>  
>  	tmp = simple_strtoul(p, &p, 10);
> -	if (!p || (*p && (*p != '\n')))
> +	if ((*p != '\0') && (*p != '\n'))
>  		return -EINVAL;
>  
>  	if (tmp > INT_MAX)
> 

-- 

"Sometimes I think the surest sign intelligent
 life exists elsewhere in the universe is that
 none of it has tried to contact us."
                                -Calvin & Hobbes

Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch v2] configfs: documentation: remove unneeded check
@ 2010-10-28 11:55       ` Joel Becker
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Becker @ 2010-10-28 11:55 UTC (permalink / raw)
  To: Dan Carpenter, Randy Dunlap, linux-kernel, linux-doc, kernel-janitors

On Wed, Oct 27, 2010 at 04:50:31PM +0200, Dan Carpenter wrote:
> If "p" is NULL then it will cause an oops when we pass it to
> simple_strtoul().  In this case "p" can not be NULL so I removed the
> check.  I also changed the check a little to make it more explicit that
> we are testing whether p points to the NUL char.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Acked-by: Joel Becker <joel.becker@oracle.com>

> ---
> V2: Added some parenthesis to make the precedence more clear.
> 
> diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
> index d428cc9..63ff248 100644
> --- a/Documentation/filesystems/configfs/configfs_example_explicit.c
> +++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
> @@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
>  	char *p = (char *) page;
>  
>  	tmp = simple_strtoul(p, &p, 10);
> -	if (!p || (*p && (*p != '\n')))
> +	if ((*p != '\0') && (*p != '\n'))
>  		return -EINVAL;
>  
>  	if (tmp > INT_MAX)
> 

-- 

"Sometimes I think the surest sign intelligent
 life exists elsewhere in the universe is that
 none of it has tried to contact us."
                                -Calvin & Hobbes

Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-10-28 11:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-27 10:07 [patch] configfs: documentation: remove unneeded check Dan Carpenter
2010-10-27 10:07 ` Dan Carpenter
2010-10-27 11:22 ` Joel Becker
2010-10-27 11:22   ` Joel Becker
2010-10-27 14:50   ` [patch v2] " Dan Carpenter
2010-10-27 14:50     ` Dan Carpenter
2010-10-28 11:55     ` Joel Becker
2010-10-28 11:55       ` Joel Becker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.