From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756993AbdJKNFs convert rfc822-to-8bit (ORCPT ); Wed, 11 Oct 2017 09:05:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56701 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752086AbdJKNFq (ORCPT ); Wed, 11 Oct 2017 09:05:46 -0400 Subject: Re: [PATCH] scsi: use set_host_byte instead of open-coding it To: Johannes Thumshirn , "Martin K . Petersen" Cc: Linux Kernel Mailinglist , Linux SCSI Mailinglist , Tejun Heo , Bart Van Assche , Oliver Neukum , Alan Stern References: <20171010152939.21353-1-jthumshirn@suse.de> From: Steffen Maier Date: Wed, 11 Oct 2017 15:05:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171010152939.21353-1-jthumshirn@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 17101113-0008-0000-0000-0000049EC328 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101113-0009-0000-0000-00001E30D01E Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-11_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710110179 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/10/2017 05:29 PM, Johannes Thumshirn wrote: > Call set_host_byte() instead of open-coding it. > > Converted using this simple Coccinelle spatch > > > @@ > local idexpression struct scsi_cmnd *c; > expression E1; > @@ > > - c->result = E1 << 16; > + set_host_byte(c, E1); 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(). Bart's suggestion also sounds nice. 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. -- Mit freundlichen Grüßen / Kind regards Steffen Maier Linux on z Systems Development IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294