diff options
author | Karel Zak | 2017-11-01 15:33:04 +0100 |
---|---|---|
committer | Karel Zak | 2017-11-01 15:33:04 +0100 |
commit | 61b9233995102d89e0f9d0beed6277071bb419ea (patch) | |
tree | 9533c1d3253e1b38f38ccb1cae291503eea30475 /lib/mangle.c | |
parent | dmesg: add note about -F format to the man page (diff) | |
download | kernel-qcow2-util-linux-61b9233995102d89e0f9d0beed6277071bb419ea.tar.gz kernel-qcow2-util-linux-61b9233995102d89e0f9d0beed6277071bb419ea.tar.xz kernel-qcow2-util-linux-61b9233995102d89e0f9d0beed6277071bb419ea.zip |
lib/mangle: return size of the decoded buffer
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/mangle.c')
-rw-r--r-- | lib/mangle.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/mangle.c b/lib/mangle.c index 354d3359f..494360d7c 100644 --- a/lib/mangle.c +++ b/lib/mangle.c @@ -70,12 +70,13 @@ void unmangle_to_buffer(const char *s, char *buf, size_t len) *buf = '\0'; } -void unhexmangle_to_buffer(const char *s, char *buf, size_t len) +size_t unhexmangle_to_buffer(const char *s, char *buf, size_t len) { size_t sz = 0; + const char *buf0 = buf; if (!s) - return; + return 0; while(*s && sz < len - 1) { if (*s == '\\' && sz + 3 < len - 1 && s[1] == 'x' && @@ -90,6 +91,7 @@ void unhexmangle_to_buffer(const char *s, char *buf, size_t len) } } *buf = '\0'; + return buf - buf0 + 1; } static inline char *skip_nonspaces(const char *s) |