From bcde0da8e46978467788ab13972076b5a4f8b5e5 Mon Sep 17 00:00:00 2001 From: Mateusz Piotrowski Date: Wed, 10 May 2023 13:15:00 +0200 Subject: [PATCH] json_stats.c: Move variable declarations out of a switch statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes the following compilation error: ``` ../../module/zfs/json_stats.c: In function ‘nvlist_to_json’: ../../module/zfs/json_stats.c:92:4: error: a label can only be part of a statement and a declaration is not a statement uint64_t *u = (uint64_t *)p; ^~~~~~~~ ../../module/zfs/json_stats.c:102:4: error: a label can only be part of a statement and a declaration is not a statement nvlist_t **a = (nvlist_t **)p; ^~~~~~~~ ``` --- module/zfs/json_stats.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module/zfs/json_stats.c b/module/zfs/json_stats.c index bb0229fa23..a80bd6e522 100644 --- a/module/zfs/json_stats.c +++ b/module/zfs/json_stats.c @@ -79,6 +79,8 @@ static void nvlist_to_json(nvlist_t *nvl, jprint_t *jp) { const char *name = (const char *)NVP_NAME(nvp); data_type_t type = NVP_TYPE(nvp); void *p = NVP_VALUE(nvp); + uint64_t *u; + nvlist_t **a; if (jp_error(jp) != JPRINT_OK) return; @@ -89,7 +91,7 @@ static void nvlist_to_json(nvlist_t *nvl, jprint_t *jp) { * Array types */ case DATA_TYPE_UINT64_ARRAY: - uint64_t *u = (uint64_t *)p; + u = (uint64_t *)p; jp_printf(jp, "%k: [", name); for (int i = 0; i < NVP_NELEM(nvp); ++i) { if (jp_error(jp) != JPRINT_OK) @@ -99,7 +101,7 @@ static void nvlist_to_json(nvlist_t *nvl, jprint_t *jp) { jp_printf(jp, "]"); break; case DATA_TYPE_NVLIST_ARRAY: - nvlist_t **a = (nvlist_t **)p; + a = (nvlist_t **)p; jp_printf(jp, "%k: [", name); for (int i = 0; i < NVP_NELEM(nvp); ++i) { if (jp_error(jp) != JPRINT_OK)