All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: dhowells@redhat.com, torvalds@linux-foundation.org,
	Wei Yongjun <weiyongjun1@huawei.com>,
	keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] keys: asymmetric: fix error return code in software_key_query()
Date: Thu, 23 Jul 2020 07:31:23 +0000	[thread overview]
Message-ID: <1267853.1595489483@warthog.procyon.org.uk> (raw)
In-Reply-To: <20200723013223.GA45081@linux.intel.com>

Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote:

> >  	if (IS_ERR(tfm))
> >  		return PTR_ERR(tfm);
> >  
> > +	ret = -ENOMEM;
> 
> This is extremely confusing to read way to handle 'ret'.
> 
> Would be way more cleaner to be just simple and stupid:
> 
> 	if (!key) {
> 		ret = -ENOMEM;
> 		goto error_free_tfm;
> 	}

I agree, but we have some people who will (or who used to) moan at you for
doing in four lines what you could've done in three.  I don't know if this is
still the standard.

David

WARNING: multiple messages have this Message-ID (diff)
From: David Howells <dhowells@redhat.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: dhowells@redhat.com, torvalds@linux-foundation.org,
	Wei Yongjun <weiyongjun1@huawei.com>,
	keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] keys: asymmetric: fix error return code in software_key_query()
Date: Thu, 23 Jul 2020 08:31:23 +0100	[thread overview]
Message-ID: <1267853.1595489483@warthog.procyon.org.uk> (raw)
In-Reply-To: <20200723013223.GA45081@linux.intel.com>

Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote:

> >  	if (IS_ERR(tfm))
> >  		return PTR_ERR(tfm);
> >  
> > +	ret = -ENOMEM;
> 
> This is extremely confusing to read way to handle 'ret'.
> 
> Would be way more cleaner to be just simple and stupid:
> 
> 	if (!key) {
> 		ret = -ENOMEM;
> 		goto error_free_tfm;
> 	}

I agree, but we have some people who will (or who used to) moan at you for
doing in four lines what you could've done in three.  I don't know if this is
still the standard.

David


  parent reply	other threads:[~2020-07-23  7:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 11:21 [PATCH] KEYS: asymmetric: fix error return code in software_key_query() Wei Yongjun
2020-06-22 11:21 ` Wei Yongjun
2020-07-15 22:28 ` [PATCH] keys: " David Howells
2020-07-15 22:28   ` David Howells
2020-07-23  1:32   ` Jarkko Sakkinen
2020-07-23  1:32     ` Jarkko Sakkinen
2020-07-23  1:36     ` Jarkko Sakkinen
2020-07-23  1:36       ` Jarkko Sakkinen
2020-07-23  7:31   ` David Howells [this message]
2020-07-23  7:31     ` David Howells
2020-07-23  7:42   ` David Howells
2020-07-23  7:42     ` David Howells
2020-07-24  7:16     ` Jarkko Sakkinen
2020-07-24  7:16       ` Jarkko Sakkinen

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=1267853.1595489483@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=weiyongjun1@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.