From f7331c71946fb9985aa14bda85b353efe3623d70 Mon Sep 17 00:00:00 2001 From: Jonas Jonsson Date: Mon, 5 Oct 2015 13:59:09 +0200 Subject: [PATCH] Use sizeof(seq) instead of magic number 13 Be more future proof by keeping the number of magic constants low. --- src/dump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dump.c b/src/dump.c index 1a4e176..5444340 100644 --- a/src/dump.c +++ b/src/dump.c @@ -134,7 +134,7 @@ static int dump_string(const char *str, size_t len, json_dump_callback_t dump, v /* codepoint is in BMP */ if(codepoint < 0x10000) { - snprintf(seq, 13, "\\u%04X", codepoint); + snprintf(seq, sizeof(seq), "\\u%04X", codepoint); length = 6; } @@ -147,7 +147,7 @@ static int dump_string(const char *str, size_t len, json_dump_callback_t dump, v first = 0xD800 | ((codepoint & 0xffc00) >> 10); last = 0xDC00 | (codepoint & 0x003ff); - snprintf(seq, 13, "\\u%04X\\u%04X", first, last); + snprintf(seq, sizeof(seq), "\\u%04X\\u%04X", first, last); length = 12; }