From 40f70de06e85d81aafaa5a13a883cfb590076431 Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Wed, 5 Dec 2018 12:55:07 +0100 Subject: [PATCH] json_util: add debug logs to spdk_json_decode_object function It is helpful to see what went wrong during decoding. Change-Id: Ia26d3ea6e97823966840e688eaf9264dfef120a8 Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/c/436194 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Maciej Szwed Reviewed-by: Shuhei Matsumoto Reviewed-by: Darek Stojaczyk --- lib/json/json_util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/json/json_util.c b/lib/json/json_util.c index 1146e6fad..1f3d0846e 100644 --- a/lib/json/json_util.c +++ b/lib/json/json_util.c @@ -331,10 +331,12 @@ spdk_json_decode_object(const struct spdk_json_val *values, if (seen[decidx]) { /* duplicate field name */ invalid = true; + SPDK_JSON_DEBUG("Duplicate key '%s'\n", dec->name); } else { seen[decidx] = true; if (dec->decode_func(v, field)) { invalid = true; + SPDK_JSON_DEBUG("Decoder failed to decode key '%s'\n", dec->name); /* keep going to fill out any other valid keys */ } } @@ -344,6 +346,7 @@ spdk_json_decode_object(const struct spdk_json_val *values, if (!found) { invalid = true; + SPDK_JSON_DEBUG("Decoder not found for key '%.*s'\n", name->len, (char *)name->start); } i += 1 + spdk_json_val_len(v);