diff mbox series

[1/3] ascii_to_bin: rename arguments to clarify function

Message ID 20200529065831.9062-1-sde@unmatched.eu
State Accepted
Headers show
Series [1/3] ascii_to_bin: rename arguments to clarify function | expand

Commit Message

Stijn Devriendt May 29, 2020, 6:58 a.m. UTC
Signed-off-by: Stijn Devriendt <sde@unmatched.eu>
---
 core/util.c    | 14 +++++++-------
 include/util.h |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/core/util.c b/core/util.c
index 8c2a80b..bd7ef6e 100644
--- a/core/util.c
+++ b/core/util.c
@@ -54,21 +54,21 @@  static char* TMPDIRSCRIPT = NULL;
  * Convert a hash as hexa string into a sequence of bytes
  * hash must be an array of 32 bytes as specified by SHA256
  */
-int ascii_to_bin(unsigned char *hash, const char *s, size_t len)
+int ascii_to_bin(unsigned char *dest, const char *src, size_t srclen)
 {
 	unsigned int i;
 	unsigned int val;
 
-	if (s == NULL) {
+	if (src == NULL) {
 		return 0;
 	}
 
-	if (len % 2)
+	if (srclen % 2)
 		return -EINVAL;
-	if (strlen(s) == len) {
-		for (i = 0; i < len; i+= 2) {
-			val = from_ascii(&s[i], 2, LG_16);
-			hash[i / 2] = val;
+	if (strlen(src) == srclen) {
+		for (i = 0; i < srclen; i+= 2) {
+			val = from_ascii(&src[i], 2, LG_16);
+			dest[i / 2] = val;
 		}
 	} else
 		return -1;
diff --git a/include/util.h b/include/util.h
index 8d1757f..68df96a 100644
--- a/include/util.h
+++ b/include/util.h
@@ -140,7 +140,7 @@  typedef void (*notifier) (RECOVERY_STATUS status, int error, int level, const ch
 uintmax_t
 from_ascii (char const *where, size_t digs, unsigned logbase);
 int ascii_to_hash(unsigned char *hash, const char *s);
-int ascii_to_bin(unsigned char *hash, const char *s, size_t len);
+int ascii_to_bin(unsigned char *dest, const char *src, size_t srclen);
 void hash_to_ascii(const unsigned char *hash, char *s);
 int IsValidHash(const unsigned char *hash);