Re: [PATCH] scsi: use set_host_byte instead of open-coding it

From: Johannes Thumshirn
Date: Wed Oct 11 2017 - 09:25:59 EST


On Wed, Oct 11, 2017 at 03:05:40PM +0200, Steffen Maier wrote:
> Maybe I misunderstand, but doesn't set_host_byte only set the host byte but
> leave the other 3 parts untouched in c->result?
>
> static inline void set_host_byte(struct scsi_cmnd *cmd, char status)
> {
> cmd->result = (cmd->result & 0xff00ffff) | (status << 16);
> }
>
> In contrast, assigning something to c->result resets all parts.
> If so, the semantic patch would introduce a subtle semantic change.
> Unless it's guaranteed that in all the touched cases, c->result always has 0
> for status, message, and driver byte before calling set_host_byte().

Yes it does, another case I'll have to add to my coccinelle spatch, thanks for
reminding me (and I'm also doing it for set_msg_byte() and set_driver_byte(),
the status byte will be done manually probably).

>
> Bart's suggestion also sounds nice.

Yes I'm working on implementing it currently.

>
> FYI: Originally, I only thought about using set_host_byte in that one place
> fix of yours; I did not expect a full framework rework.

Oh well:
$ git diff --stat master..
[..]
80 files changed, 589 insertions(+), 540 deletions(-)

Byte,
Johannes

--
Johannes Thumshirn Storage
jthumshirn@xxxxxxx +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850