mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-crypto@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Neil Horman <nhorman@tuxdriver.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/3] crypto-ansi_cprng: Delete two variable assignments in get_prng_bytes()
Date: Sat, 21 Oct 2017 19:15:54 +0200	[thread overview]
Message-ID: <7318b066-5233-426e-4b21-d4969b96bf67@users.sourceforge.net> (raw)
In-Reply-To: <d284473a-b968-2b3e-9147-1c8598a26f7c@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 21 Oct 2017 16:10:43 +0200

Adjust a jump target so that two error code assignments which are redundant
before condition checks can be removed because the same value will be set
as an exception handling at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 crypto/ansi_cprng.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index 111c8982a47f..3d805bf6d0c6 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -192,19 +192,16 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx,
 
 
 	spin_lock_bh(&ctx->prng_lock);
-
-	err = -EINVAL;
 	if (ctx->flags & PRNG_NEED_RESET)
-		goto unlock;
+		goto failure_indication;
 
 	/*
 	 * If the FIXED_SIZE flag is on, only return whole blocks of
 	 * pseudo random data
 	 */
-	err = -EINVAL;
 	if (ctx->flags & PRNG_FIXED_SIZE) {
 		if (nbytes < DEFAULT_BLK_SZ)
-			goto unlock;
+			goto failure_indication;
 		byte_count = DEFAULT_BLK_SZ;
 	}
 
@@ -267,6 +264,7 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx,
 
 reset_memory:
 	memset(buf, 0, nbytes);
+failure_indication:
 	err = -EINVAL;
 	goto unlock;
 }
-- 
2.14.2

  parent reply	other threads:[~2017-10-21 17:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-21 17:12 [PATCH 0/3] crypto-ansi_cprng: Fine-tuning for three function implementations SF Markus Elfring
2017-10-21 17:14 ` [PATCH 1/3] crypto-ansi_cprng: Use common error handling code in get_prng_bytes() SF Markus Elfring
2017-10-21 17:15 ` SF Markus Elfring [this message]
2017-10-21 17:17 ` [PATCH 3/3] crypto-ansi_cprng: Delete unnecessary blank lines SF Markus Elfring

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=7318b066-5233-426e-4b21-d4969b96bf67@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nhorman@tuxdriver.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome