All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Becker <Joel.Becker@oracle.com>
To: Dan Carpenter <error27@gmail.com>,
	Randy Dunlap <rdunlap@xenotime.net>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] configfs: documentation: remove unneeded check
Date: Wed, 27 Oct 2010 11:22:08 +0000	[thread overview]
Message-ID: <20101027112207.GA17439@mail.oracle.com> (raw)
In-Reply-To: <20101027100735.GE6062@bicker>

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

WARNING: multiple messages have this Message-ID (diff)
From: Joel Becker <Joel.Becker@oracle.com>
To: Dan Carpenter <error27@gmail.com>,
	Randy Dunlap <rdunlap@xenotime.net>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] configfs: documentation: remove unneeded check
Date: Wed, 27 Oct 2010 04:22:08 -0700	[thread overview]
Message-ID: <20101027112207.GA17439@mail.oracle.com> (raw)
In-Reply-To: <20101027100735.GE6062@bicker>

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

  reply	other threads:[~2010-10-27 11:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101027112207.GA17439@mail.oracle.com \
    --to=joel.becker@oracle.com \
    --cc=error27@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.