All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dimitri Sivanich <sivanich@sgi.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Robin Holt <holt@sgi.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] gru: fix a sanity test in gru_set_context_option()
Date: Mon, 20 May 2013 13:46:21 +0000	[thread overview]
Message-ID: <20130520134621.GA25574@sgi.com> (raw)
In-Reply-To: <20130519183041.GB30128@mwanda>

On Sun, May 19, 2013 at 09:30:41PM +0300, Dan Carpenter wrote:
> On Sun, May 19, 2013 at 09:44:42AM -0500, Dimitri Sivanich wrote:
> > 
> > Since we're here, maybe we should neaten this up a little?
> > 
> > Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
> > ---
> >  drivers/misc/sgi-gru/grufault.c |    5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > Index: linux/drivers/misc/sgi-gru/grufault.c
> > =================================> > --- linux.orig/drivers/misc/sgi-gru/grufault.c
> > +++ linux/drivers/misc/sgi-gru/grufault.c
> > @@ -876,8 +876,9 @@ int gru_set_context_option(unsigned long
> >  	switch (req.op) {
> >  	case sco_blade_chiplet:
> >  		/* Select blade/chiplet for GRU context */
> > -		if (req.val1 < -1 || req.val1 >= GRU_MAX_BLADES || !gru_base[req.val1] ||
> > -		    req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB) {
> > +		if (req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB ||
> > +			req.val1 < -1 || req.val1 >= GRU_MAX_BLADES ||
> > +			(req.val1 >= 0 && !gru_base[req.val1])) {
> >  			ret = -EINVAL;
> 
> I generally prefer how in the original code all the sub conditions
> were aligned nicely but I will Ack your version as well.  Thanks.
> 

I guess I'd have to agree.  How about this?

Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
---
 drivers/misc/sgi-gru/grufault.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: linux/drivers/misc/sgi-gru/grufault.c
=================================--- linux.orig/drivers/misc/sgi-gru/grufault.c
+++ linux/drivers/misc/sgi-gru/grufault.c
@@ -876,8 +876,9 @@ int gru_set_context_option(unsigned long
 	switch (req.op) {
 	case sco_blade_chiplet:
 		/* Select blade/chiplet for GRU context */
-		if (req.val1 < -1 || req.val1 >= GRU_MAX_BLADES || !gru_base[req.val1] ||
-		    req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB) {
+		if (req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB ||
+		    req.val1 < -1 || req.val1 >= GRU_MAX_BLADES ||
+		    (req.val1 >= 0 && !gru_base[req.val1])) {
 			ret = -EINVAL;
 		} else {
 			gts->ts_user_blade_id = req.val1;

WARNING: multiple messages have this Message-ID (diff)
From: Dimitri Sivanich <sivanich@sgi.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Robin Holt <holt@sgi.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] gru: fix a sanity test in gru_set_context_option()
Date: Mon, 20 May 2013 08:46:21 -0500	[thread overview]
Message-ID: <20130520134621.GA25574@sgi.com> (raw)
In-Reply-To: <20130519183041.GB30128@mwanda>

On Sun, May 19, 2013 at 09:30:41PM +0300, Dan Carpenter wrote:
> On Sun, May 19, 2013 at 09:44:42AM -0500, Dimitri Sivanich wrote:
> > 
> > Since we're here, maybe we should neaten this up a little?
> > 
> > Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
> > ---
> >  drivers/misc/sgi-gru/grufault.c |    5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > Index: linux/drivers/misc/sgi-gru/grufault.c
> > ===================================================================
> > --- linux.orig/drivers/misc/sgi-gru/grufault.c
> > +++ linux/drivers/misc/sgi-gru/grufault.c
> > @@ -876,8 +876,9 @@ int gru_set_context_option(unsigned long
> >  	switch (req.op) {
> >  	case sco_blade_chiplet:
> >  		/* Select blade/chiplet for GRU context */
> > -		if (req.val1 < -1 || req.val1 >= GRU_MAX_BLADES || !gru_base[req.val1] ||
> > -		    req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB) {
> > +		if (req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB ||
> > +			req.val1 < -1 || req.val1 >= GRU_MAX_BLADES ||
> > +			(req.val1 >= 0 && !gru_base[req.val1])) {
> >  			ret = -EINVAL;
> 
> I generally prefer how in the original code all the sub conditions
> were aligned nicely but I will Ack your version as well.  Thanks.
> 

I guess I'd have to agree.  How about this?

Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
---
 drivers/misc/sgi-gru/grufault.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: linux/drivers/misc/sgi-gru/grufault.c
===================================================================
--- linux.orig/drivers/misc/sgi-gru/grufault.c
+++ linux/drivers/misc/sgi-gru/grufault.c
@@ -876,8 +876,9 @@ int gru_set_context_option(unsigned long
 	switch (req.op) {
 	case sco_blade_chiplet:
 		/* Select blade/chiplet for GRU context */
-		if (req.val1 < -1 || req.val1 >= GRU_MAX_BLADES || !gru_base[req.val1] ||
-		    req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB) {
+		if (req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB ||
+		    req.val1 < -1 || req.val1 >= GRU_MAX_BLADES ||
+		    (req.val1 >= 0 && !gru_base[req.val1])) {
 			ret = -EINVAL;
 		} else {
 			gts->ts_user_blade_id = req.val1;

  reply	other threads:[~2013-05-20 13:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-19 12:59 [patch] gru: fix a sanity test in gru_set_context_option() Dan Carpenter
2013-05-19 12:59 ` Dan Carpenter
2013-05-19 14:44 ` Dimitri Sivanich
2013-05-19 14:44   ` Dimitri Sivanich
2013-05-19 18:30   ` Dan Carpenter
2013-05-19 18:30     ` Dan Carpenter
2013-05-20 13:46     ` Dimitri Sivanich [this message]
2013-05-20 13:46       ` Dimitri Sivanich
2013-05-20 18:06       ` Dan Carpenter
2013-05-20 18:06         ` Dan Carpenter

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=20130520134621.GA25574@sgi.com \
    --to=sivanich@sgi.com \
    --cc=dan.carpenter@oracle.com \
    --cc=holt@sgi.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.