configfs: documentation: remove unneeded check
Subsystems (2)
PATCH 1/1 configfs: documentation: remove unneeded check
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.
Documentation/filesystems/configfs/configfs_example_explicit.c +1 -1
@@ -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 )
Quoted 11 lines · Dan Carpenter
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 <[email protected]>Documentation/filesystems/configfs/configfs_example_explicit.c +0
-0
Documentation/filesystems/configfs/configfs_example_explicit.c static ssize_t childless_storeme_write(struct childless *childless, · line 93
Quoted 6 lines
Documentation/filesystems/configfs/configfs_example_explicit.c +1
-1@@ -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
Signature · 9 lines
Life's Little Instruction Book #444 "Never underestimate the power of a kind word or deed." Joel Becker Senior Development Manager Oracle E-mail: [email protected] Phone: (650) 506-8127
PATCH v2 1/1 configfs: documentation: remove unneeded check
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.
---
V2: Added some parenthesis to make the precedence more clear.
Documentation/filesystems/configfs/configfs_example_explicit.c +1 -1
@@ -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 )
Quoted 6 lines · Dan Carpenter
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 <[email protected]>
Quoted 17 lines
---
V2: Added some parenthesis to make the precedence more clear.Documentation/filesystems/configfs/configfs_example_explicit.c +1
-1@@ -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 )
Signature · 10 lines
"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: [email protected]
Phone: (650) 506-8127