json_stats.c: Move variable declarations out of a switch statement
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; ^~~~~~~~ ```
This commit is contained in:
parent
747c7bbcf6
commit
bcde0da8e4
|
@ -79,6 +79,8 @@ static void nvlist_to_json(nvlist_t *nvl, jprint_t *jp) {
|
||||||
const char *name = (const char *)NVP_NAME(nvp);
|
const char *name = (const char *)NVP_NAME(nvp);
|
||||||
data_type_t type = NVP_TYPE(nvp);
|
data_type_t type = NVP_TYPE(nvp);
|
||||||
void *p = NVP_VALUE(nvp);
|
void *p = NVP_VALUE(nvp);
|
||||||
|
uint64_t *u;
|
||||||
|
nvlist_t **a;
|
||||||
|
|
||||||
if (jp_error(jp) != JPRINT_OK)
|
if (jp_error(jp) != JPRINT_OK)
|
||||||
return;
|
return;
|
||||||
|
@ -89,7 +91,7 @@ static void nvlist_to_json(nvlist_t *nvl, jprint_t *jp) {
|
||||||
* Array types
|
* Array types
|
||||||
*/
|
*/
|
||||||
case DATA_TYPE_UINT64_ARRAY:
|
case DATA_TYPE_UINT64_ARRAY:
|
||||||
uint64_t *u = (uint64_t *)p;
|
u = (uint64_t *)p;
|
||||||
jp_printf(jp, "%k: [", name);
|
jp_printf(jp, "%k: [", name);
|
||||||
for (int i = 0; i < NVP_NELEM(nvp); ++i) {
|
for (int i = 0; i < NVP_NELEM(nvp); ++i) {
|
||||||
if (jp_error(jp) != JPRINT_OK)
|
if (jp_error(jp) != JPRINT_OK)
|
||||||
|
@ -99,7 +101,7 @@ static void nvlist_to_json(nvlist_t *nvl, jprint_t *jp) {
|
||||||
jp_printf(jp, "]");
|
jp_printf(jp, "]");
|
||||||
break;
|
break;
|
||||||
case DATA_TYPE_NVLIST_ARRAY:
|
case DATA_TYPE_NVLIST_ARRAY:
|
||||||
nvlist_t **a = (nvlist_t **)p;
|
a = (nvlist_t **)p;
|
||||||
jp_printf(jp, "%k: [", name);
|
jp_printf(jp, "%k: [", name);
|
||||||
for (int i = 0; i < NVP_NELEM(nvp); ++i) {
|
for (int i = 0; i < NVP_NELEM(nvp); ++i) {
|
||||||
if (jp_error(jp) != JPRINT_OK)
|
if (jp_error(jp) != JPRINT_OK)
|
||||||
|
|
Loading…
Reference in New Issue