Skip to content

Instantly share code, notes, and snippets.

@kaspar030
Created January 10, 2018 13:54
Show Gist options
  • Select an option

  • Save kaspar030/06d9b04ed210aed79d42bd4bba885298 to your computer and use it in GitHub Desktop.

Select an option

Save kaspar030/06d9b04ed210aed79d42bd4bba885298 to your computer and use it in GitHub Desktop.
commit 25b453fd4d354cd16de7ff233da626758c6ab1be
Author: Kaspar Schleiser <kaspar@schleiser.de>
Date: Wed Jan 10 14:53:55 2018 +0100
fixup! sys/fmt: add new byte to hex converters:
diff --git a/sys/fmt/fmt.c b/sys/fmt/fmt.c
index 3d333195e..36540a545 100644
--- a/sys/fmt/fmt.c
+++ b/sys/fmt/fmt.c
@@ -64,11 +64,11 @@ size_t fmt_byte_hex(char *out, uint8_t byte)
size_t fmt_bytes_hex(char *out, const uint8_t *ptr, size_t n)
{
- size_t len = 0;
+ size_t len = n * 2;
+
if (out) {
while (n--) {
out += fmt_byte_hex(out, *ptr++);
- len += 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment