diff mbox

[2/2] xen-tpmfront: Combine two condition checks into one statement in vtpm_send()

Message ID f1d76752-d5b4-649d-b11d-63348d439505@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring Oct. 22, 2017, 11:30 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Oct 2017 13:15:16 +0200

A return was performed with the same error code after two condition checks.
Thus use a single statement instead.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/tpm/xen-tpmfront.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Dan Carpenter Oct. 23, 2017, 7:31 a.m. UTC | #1
On Sun, Oct 22, 2017 at 01:30:46PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 22 Oct 2017 13:15:16 +0200
> 
> A return was performed with the same error code after two condition checks.
> Thus use a single statement instead.
> 

It's fine as-is, thanks.

regards,
dan carpenter
Jarkko Sakkinen Oct. 23, 2017, 1:44 p.m. UTC | #2
On Sun, Oct 22, 2017 at 01:30:46PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 22 Oct 2017 13:15:16 +0200
> 
> A return was performed with the same error code after two condition checks.
> Thus use a single statement instead.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/char/tpm/xen-tpmfront.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
> index 873a5631937a..0d02743e7a87 100644
> --- a/drivers/char/tpm/xen-tpmfront.c
> +++ b/drivers/char/tpm/xen-tpmfront.c
> @@ -82,10 +82,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
>  	u32 ordinal;
>  	unsigned long duration;
>  
> -	if (offset > PAGE_SIZE)
> -		return -EINVAL;
> -
> -	if (offset + count > PAGE_SIZE)
> +	if (offset > PAGE_SIZE || offset + count > PAGE_SIZE)
>  		return -EINVAL;
>  
>  	/* Wait for completion of any existing command or cancellation */
> -- 
> 2.14.2
> 

This is fine.

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko
Jarkko Sakkinen Oct. 24, 2017, 1:52 p.m. UTC | #3
On Mon, Oct 23, 2017 at 03:44:01PM +0200, Jarkko Sakkinen wrote:
> On Sun, Oct 22, 2017 at 01:30:46PM +0200, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 22 Oct 2017 13:15:16 +0200
> > 
> > A return was performed with the same error code after two condition checks.
> > Thus use a single statement instead.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >  drivers/char/tpm/xen-tpmfront.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> > 
> > diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
> > index 873a5631937a..0d02743e7a87 100644
> > --- a/drivers/char/tpm/xen-tpmfront.c
> > +++ b/drivers/char/tpm/xen-tpmfront.c
> > @@ -82,10 +82,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
> >  	u32 ordinal;
> >  	unsigned long duration;
> >  
> > -	if (offset > PAGE_SIZE)
> > -		return -EINVAL;
> > -
> > -	if (offset + count > PAGE_SIZE)
> > +	if (offset > PAGE_SIZE || offset + count > PAGE_SIZE)
> >  		return -EINVAL;
> >  
> >  	/* Wait for completion of any existing command or cancellation */
> > -- 
> > 2.14.2
> > 
> 
> This is fine.
> 
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> 
> /Jarkko

Anyway I NAK it because it is really a change of insignificant value.
Just adds cruft to the kernel release.

I would be fine if someone did this as part of something significant.

/Jarkko
diff mbox

Patch

diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index 873a5631937a..0d02743e7a87 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -82,10 +82,7 @@  static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
 	u32 ordinal;
 	unsigned long duration;
 
-	if (offset > PAGE_SIZE)
-		return -EINVAL;
-
-	if (offset + count > PAGE_SIZE)
+	if (offset > PAGE_SIZE || offset + count > PAGE_SIZE)
 		return -EINVAL;
 
 	/* Wait for completion of any existing command or cancellation */