]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
utils: make hexstring_a2n provide the number of hex digits parsed
authorSabrina Dubroca <sd@queasysnail.net>
Fri, 3 Jun 2016 14:45:45 +0000 (16:45 +0200)
committerStephen Hemminger <shemming@brocade.com>
Wed, 8 Jun 2016 16:30:31 +0000 (09:30 -0700)
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Phil Sutter <phil@nwl.cc>
include/utils.h
lib/utils.c

index ef81d00f3d70d835b81dfc6c059e4679aa5944a1..aef28ce732ab4966cbf64f33a53ed2656324ac5c 100644 (file)
@@ -114,8 +114,8 @@ int get_u8(__u8 *val, const char *arg, int base);
 int get_s8(__s8 *val, const char *arg, int base);
 int get_addr64(__u64 *ap, const char *cp);
 
-charhexstring_n2a(const __u8 *str, int len, char *buf, int blen);
-__u8* hexstring_a2n(const char *str, __u8 *buf, int blen);
+char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen);
+__u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len);
 #define ADDR64_BUF_SIZE sizeof("xxxx:xxxx:xxxx:xxxx")
 int addr64_n2a(__u64 addr, char *buff, size_t len);
 
index b93b1dc843150154bb234790b154863ed12e41ac..bd10c0d717182fe3fa37a2bfe48f7876d5511ff3 100644 (file)
@@ -866,9 +866,9 @@ char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen)
        return buf;
 }
 
-__u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
+__u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len)
 {
-       int cnt = 0;
+       unsigned int cnt = 0;
        char *endptr;
 
        if (strlen(str) % 2)
@@ -885,6 +885,10 @@ __u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
                buf[cnt++] = tmp;
                str += 2;
        }
+
+       if (len)
+               *len = cnt;
+
        return buf;
 }