summaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_variable.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2019-01-18 12:31:54 +0100
committerAlexander Graf <agraf@suse.de>2019-02-13 09:40:06 +0100
commit6e37fa2293a344ab20f79498ac097fb8f12a1183 (patch)
tree3eb732d3372253c652569e3700d40953268d934f /lib/efi_loader/efi_variable.c
parentbc867951a25737b9599591bd1dd09352ef7791df (diff)
efi_loader: eliminate duplicate function hex2mem()
Use existing inline function hex2bin() instead of defining a new one. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_loader/efi_variable.c')
-rw-r--r--lib/efi_loader/efi_variable.c44
1 files changed, 3 insertions, 41 deletions
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index c302dbd2fe..eea7f68b85 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -8,6 +8,7 @@
#include <malloc.h>
#include <charset.h>
#include <efi_loader.h>
+#include <hexdump.h>
#define READ_ONLY BIT(31)
@@ -46,45 +47,6 @@
#define PREFIX_LEN (strlen("efi_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_"))
-static int hex(int ch)
-{
- if (ch >= 'a' && ch <= 'f')
- return ch-'a'+10;
- if (ch >= '0' && ch <= '9')
- return ch-'0';
- if (ch >= 'A' && ch <= 'F')
- return ch-'A'+10;
- return -1;
-}
-
-static int hex2mem(u8 *mem, const char *hexstr, int size)
-{
- int nibble;
- int i;
-
- for (i = 0; i < size; i++) {
- if (*hexstr == '\0')
- break;
-
- nibble = hex(*hexstr);
- if (nibble < 0)
- return -1;
-
- *mem = nibble;
- hexstr++;
-
- nibble = hex(*hexstr);
- if (nibble < 0)
- return -1;
-
- *mem = (*mem << 4) | nibble;
- hexstr++;
- mem++;
- }
-
- return i;
-}
-
static char *mem2hex(char *hexstr, const u8 *mem, int count)
{
static const char hexchars[] = "0123456789abcdef";
@@ -195,7 +157,7 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
in_size = *data_size;
if ((s = prefix(val, "(blob)"))) {
- unsigned len = strlen(s);
+ size_t len = strlen(s);
/* number of hexadecimal digits must be even */
if (len & 1)
@@ -211,7 +173,7 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
if (!data)
return EFI_EXIT(EFI_INVALID_PARAMETER);
- if (hex2mem(data, s, len) != len)
+ if (hex2bin(data, s, len))
return EFI_EXIT(EFI_DEVICE_ERROR);
debug("%s: got value: \"%s\"\n", __func__, s);