From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julia Lawall Date: Wed, 06 Dec 2017 14:53:03 +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: <15713.1512571817@warthog.procyon.org.uk> To: linux-security-module@vger.kernel.org On Wed, 6 Dec 2017, David Howells wrote: > James Morris wrote: > > > I think a general cleanup in that function to make all of these follow the > > pattern: > > > > if (something) { > > key_ref = ERR_PTR(-error); > > goto error; > > } > > > > rather than unconditionally setting the error first, would be better, but > > this is a clear enough fix on its own. > > 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. julia > > David > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752532AbdLFOxO (ORCPT ); Wed, 6 Dec 2017 09:53:14 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:16028 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752062AbdLFOxK (ORCPT ); Wed, 6 Dec 2017 09:53:10 -0500 X-IronPort-AV: E=Sophos;i="5.45,368,1508796000"; d="scan'208";a="247413082" Date: Wed, 6 Dec 2017 15:53:03 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: David Howells cc: James Morris , 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: <15713.1512571817@warthog.procyon.org.uk> Message-ID: References: <20171204181424.15808-1-colin.king@canonical.com> <15713.1512571817@warthog.procyon.org.uk> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 6 Dec 2017, David Howells wrote: > James Morris wrote: > > > I think a general cleanup in that function to make all of these follow the > > pattern: > > > > if (something) { > > key_ref = ERR_PTR(-error); > > goto error; > > } > > > > rather than unconditionally setting the error first, would be better, but > > this is a clear enough fix on its own. > > 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. julia > > David > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > From mboxrd@z Thu Jan 1 00:00:00 1970 From: julia.lawall@lip6.fr (Julia Lawall) Date: Wed, 6 Dec 2017 15:53:03 +0100 (CET) Subject: [PATCH] security: keys: remove redundant assignment to key_ref In-Reply-To: <15713.1512571817@warthog.procyon.org.uk> 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, David Howells wrote: > James Morris wrote: > > > I think a general cleanup in that function to make all of these follow the > > pattern: > > > > if (something) { > > key_ref = ERR_PTR(-error); > > goto error; > > } > > > > rather than unconditionally setting the error first, would be better, but > > this is a clear enough fix on its own. > > 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. julia > > David > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- 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