From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Morris Date: Thu, 07 Dec 2017 00:49:42 +0000 Subject: Re: [PATCH] security: keys: remove redundant assignment to key_ref Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: References: <20171204181424.15808-1-colin.king@canonical.com> <15713.1512571817@warthog.procyon.org.uk> In-Reply-To: To: linux-security-module@vger.kernel.org On Wed, 6 Dec 2017, Julia Lawall wrote: > > There's a preference in Linux to use: > > > > key_ref = ERR_PTR(-error); > > if (something) > > goto error; > > > > instead because it uses less vertical space. It might originally have been > > promulgated by Linus, but I don't remember. Though you do have a point - your > > way makes error handling less subject breakage from code rearrangement. > > I have the impression that there are many examples of both approaches. I thought this was mainly to set a default error condition once and then some call during the function sets it to zero on success. -- James Morris From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752500AbdLGAuC (ORCPT ); Wed, 6 Dec 2017 19:50:02 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57102 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752059AbdLGAuA (ORCPT ); Wed, 6 Dec 2017 19:50:00 -0500 Date: Thu, 7 Dec 2017 11:49:42 +1100 (AEDT) From: James Morris X-X-Sender: james.l.morris@localhost To: Julia Lawall cc: David Howells , Colin King , "Serge E . Hallyn" , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] security: keys: remove redundant assignment to key_ref In-Reply-To: Message-ID: References: <20171204181424.15808-1-colin.king@canonical.com> <15713.1512571817@warthog.procyon.org.uk> User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8737 signatures=668643 X-Proofpoint-Spam-Details: rule=notspam policy=default 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-1709140000 definitions=main-1712070010 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 6 Dec 2017, Julia Lawall wrote: > > There's a preference in Linux to use: > > > > key_ref = ERR_PTR(-error); > > if (something) > > goto error; > > > > instead because it uses less vertical space. It might originally have been > > promulgated by Linus, but I don't remember. Though you do have a point - your > > way makes error handling less subject breakage from code rearrangement. > > I have the impression that there are many examples of both approaches. I thought this was mainly to set a default error condition once and then some call during the function sets it to zero on success. -- James Morris From mboxrd@z Thu Jan 1 00:00:00 1970 From: james.l.morris@oracle.com (James Morris) Date: Thu, 7 Dec 2017 11:49:42 +1100 (AEDT) Subject: [PATCH] security: keys: remove redundant assignment to key_ref In-Reply-To: References: <20171204181424.15808-1-colin.king@canonical.com> <15713.1512571817@warthog.procyon.org.uk> Message-ID: To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On Wed, 6 Dec 2017, Julia Lawall wrote: > > There's a preference in Linux to use: > > > > key_ref = ERR_PTR(-error); > > if (something) > > goto error; > > > > instead because it uses less vertical space. It might originally have been > > promulgated by Linus, but I don't remember. Though you do have a point - your > > way makes error handling less subject breakage from code rearrangement. > > I have the impression that there are many examples of both approaches. I thought this was mainly to set a default error condition once and then some call during the function sets it to zero on success. -- James Morris -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html