[mmc-utils,3/5] Fix parsing of character in to_binstr()
diff mbox series

Message ID 20181218143601.24413-4-michael.heimpold@i2se.com
State New
Headers show
Series
  • Various fixes for mmc-utils
Related show

Commit Message

Michael Heimpold Dec. 18, 2018, 2:35 p.m. UTC
When a hex-digit > 'a' or 'A' is read, we have to add an offset of 10
to access the valid symbol in our mapping table.

Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
---
 lsmmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/lsmmc.c b/lsmmc.c
index a53bc57..e64117c 100644
--- a/lsmmc.c
+++ b/lsmmc.c
@@ -386,9 +386,9 @@  char *to_binstr(char *hexstr)
 		if (isdigit(*hexstr))
 			strcat(binstr, bindigits[*hexstr - '0']);
 		else if (islower(*hexstr))
-			strcat(binstr, bindigits[*hexstr - 'a']);
+			strcat(binstr, bindigits[*hexstr - 'a' + 10]);
 		else
-			strcat(binstr, bindigits[*hexstr - 'A']);
+			strcat(binstr, bindigits[*hexstr - 'A' + 10]);
 
 		hexstr++;
 	}