aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2010-05-28 19:04:59 +0100
committerMichael Brown <mcb30@ipxe.org>2010-05-28 19:04:59 +0100
commitd6f79d6b6e7a4b7209cb5d7a7193bb2259306cd7 (patch)
treec9015407256e1c128f0f6c81d4558b830f51f83e /src
parent7b267ee6dba47f97edc9460d94a7aa77e5302318 (diff)
downloadipxe-d6f79d6b6e7a4b7209cb5d7a7193bb2259306cd7.zip
ipxe-d6f79d6b6e7a4b7209cb5d7a7193bb2259306cd7.tar.gz
ipxe-d6f79d6b6e7a4b7209cb5d7a7193bb2259306cd7.tar.bz2
[infiniband] Use generic base16 functions for SRP
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/net/infiniband/ib_srp.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/net/infiniband/ib_srp.c b/src/net/infiniband/ib_srp.c
index 24eb1f9..f4ec544 100644
--- a/src/net/infiniband/ib_srp.c
+++ b/src/net/infiniband/ib_srp.c
@@ -32,6 +32,7 @@ FILE_LICENCE ( BSD2 );
#include <stdlib.h>
#include <errno.h>
+#include <ipxe/base16.h>
#include <ipxe/srp.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_cmrc.h>
@@ -78,8 +79,7 @@ static int ib_srp_parse_byte_string ( const char *rp_comp, uint8_t *bytes,
unsigned int size_flags ) {
size_t size = ( size_flags & ~IB_SRP_PARSE_FLAG_MASK );
size_t rp_comp_len = strlen ( rp_comp );
- char buf[3];
- char *buf_end;
+ int decoded_size;
/* Allow optional components to be empty */
if ( ( rp_comp_len == 0 ) &&
@@ -91,13 +91,11 @@ static int ib_srp_parse_byte_string ( const char *rp_comp, uint8_t *bytes,
return -EINVAL_BYTE_STRING_LEN;
/* Parse byte string */
- for ( ; size ; size--, rp_comp += 2, bytes++ ) {
- memcpy ( buf, rp_comp, 2 );
- buf[2] = '\0';
- *bytes = strtoul ( buf, &buf_end, 16 );
- if ( buf_end != &buf[2] )
- return -EINVAL_BYTE_STRING;
- }
+ decoded_size = base16_decode ( rp_comp, bytes );
+ if ( decoded_size < 0 )
+ return decoded_size;
+ assert ( decoded_size == size );
+
return 0;
}