[rtems commit] Get rid of unused variables.

Sebastian Huber sebh at rtems.org
Fri Sep 9 04:43:21 UTC 2022


Module:    rtems
Branch:    master
Commit:    1acb1925e95e5adfaaca05c8edaacfd277e88b7d
Changeset: http://git.rtems.org/rtems/commit/?id=1acb1925e95e5adfaaca05c8edaacfd277e88b7d

Author:    Xin LI <delphij at FreeBSD.org>
Date:      Fri Jul 20 07:07:27 2018 +0000

Get rid of unused variables.

copied_key and copied_salt are assigned with NULL and never used
otherwise. Remove the two variables and related code.

Reviewed by:	pfg
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16314

---

 cpukit/libcrypt/crypt-sha256.c | 9 +--------
 cpukit/libcrypt/crypt-sha512.c | 9 +--------
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/cpukit/libcrypt/crypt-sha256.c b/cpukit/libcrypt/crypt-sha256.c
index a70b92cc85..f6d510219e 100644
--- a/cpukit/libcrypt/crypt-sha256.c
+++ b/cpukit/libcrypt/crypt-sha256.c
@@ -69,15 +69,12 @@ crypt_sha256_r(const char *key, const char *salt, struct crypt_data *data)
 	uint8_t alt_result[32], temp_result[32];
 	SHA256_CTX ctx, alt_ctx;
 	size_t salt_len, key_len, cnt, rounds;
-	char *cp, *copied_key, *copied_salt, *p_bytes, *s_bytes, *endp;
+	char *cp, *p_bytes, *s_bytes, *endp;
 	const char *num;
 	bool rounds_custom;
 	char *buffer = &data->buffer[0];
 	int buflen = (int)sizeof(data->buffer);
 
-	copied_key = NULL;
-	copied_salt = NULL;
-
 	/* Default number of rounds. */
 	rounds = ROUNDS_DEFAULT;
 	rounds_custom = false;
@@ -262,10 +259,6 @@ crypt_sha256_r(const char *key, const char *salt, struct crypt_data *data)
 	memset(s_bytes, '\0', salt_len);
 	memset(&ctx, '\0', sizeof(ctx));
 	memset(&alt_ctx, '\0', sizeof(alt_ctx));
-	if (copied_key != NULL)
-		memset(copied_key, '\0', key_len);
-	if (copied_salt != NULL)
-		memset(copied_salt, '\0', salt_len);
 
 	return buffer;
 }
diff --git a/cpukit/libcrypt/crypt-sha512.c b/cpukit/libcrypt/crypt-sha512.c
index 901b352ec5..6d680348a6 100644
--- a/cpukit/libcrypt/crypt-sha512.c
+++ b/cpukit/libcrypt/crypt-sha512.c
@@ -69,15 +69,12 @@ crypt_sha512_r(const char *key, const char *salt, struct crypt_data *data)
 	uint8_t alt_result[64], temp_result[64];
 	SHA512_CTX ctx, alt_ctx;
 	size_t salt_len, key_len, cnt, rounds;
-	char *cp, *copied_key, *copied_salt, *p_bytes, *s_bytes, *endp;
+	char *cp, *p_bytes, *s_bytes, *endp;
 	const char *num;
 	bool rounds_custom;
 	char *buffer = &data->buffer[0];
 	int buflen = (int)sizeof(data->buffer);
 
-	copied_key = NULL;
-	copied_salt = NULL;
-
 	/* Default number of rounds. */
 	rounds = ROUNDS_DEFAULT;
 	rounds_custom = false;
@@ -274,10 +271,6 @@ crypt_sha512_r(const char *key, const char *salt, struct crypt_data *data)
 	memset(s_bytes, '\0', salt_len);
 	memset(&ctx, '\0', sizeof(ctx));
 	memset(&alt_ctx, '\0', sizeof(alt_ctx));
-	if (copied_key != NULL)
-		memset(copied_key, '\0', key_len);
-	if (copied_salt != NULL)
-		memset(copied_salt, '\0', salt_len);
 
 	return buffer;
 }



More information about the vc mailing list