mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>,
	linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] USB: misplaced parenthesis
Date: Tue, 16 Feb 2010 12:16:22 +0100	[thread overview]
Message-ID: <4B7A7E86.4090806@gmail.com> (raw)
In-Reply-To: <1266273848.29987.21.camel@Joe-Laptop.home>

> I think it'd be better if you hoisted the set'n'test out of the if()

ok, I agree.

> Isn't this the current logic?
> 
> 	result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12,
> 				   srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0);
> 	result = result != USB_STOR_TRANSPORT_GOOD;
> 	if (result)
> 		return result;

Thanks for your comments, Yes that was the current logic, which I thought
was wrong, but now I think it could also be obscurely written but right:

in drivers/usb/storage/transport.h line 100 note the definitions:

#define USB_STOR_TRANSPORT_GOOD    0   /* Transport good, command good     */
#define USB_STOR_TRANSPORT_FAILED  1   /* Transport good, command failed   */
#define USB_STOR_TRANSPORT_NO_SENSE 2  /* Command failed, no auto-sense    */
#define USB_STOR_TRANSPORT_ERROR   3   /* Transport bad (i.e. device dead) */

With the current logic usbat_hp8200e_transport() returns TRANSPORT_FAILED,
even if usbat_write_block() returned TRANSPORT_NO_SENSE or TRANSPORT_ERROR.

This could be intended, but then the author chose a very obscure way to write:

	if (usbat_write_block(us, USBAT_ATA, srb->cmnd, 12,
			      srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0) !=
			      USB_STOR_TRANSPORT_GOOD) 
		return USB_STOR_TRANSPORT_FAILED;

Or was the parenthesis misplaced and should it really be:

	result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12,
				   srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0);

	if (result != USB_STOR_TRANSPORT_GOOD)
 		return result;
 
Maybe someone with the specs/more knowledge of this driver could look into
this?

Thanks, Roel

  reply	other threads:[~2010-02-16 11:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-15 22:40 Roel Kluin
2010-02-15 22:44 ` Joe Perches
2010-02-16 11:16   ` Roel Kluin [this message]
2010-02-16 15:52     ` Alan Stern
2010-02-17 10:50       ` Roel Kluin

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=4B7A7E86.4090806@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mdharm-usb@one-eyed-alien.net \
    --cc=usb-storage@lists.one-eyed-alien.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome