Print this page
5005 libnvpair JSON output broken by lint fixes
5006 libnvpair JSON cannot print int16 arrays
Reviewed by: Robert Mustacchi <rm@joyent.com>

@@ -7,11 +7,11 @@
  * A full copy of the text of the CDDL should have accompanied this
  * source.  A copy of the CDDL is also available via the Internet at
  * http://www.illumos.org/license/CDDL.
  */
 /*
- * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <strings.h>

@@ -19,12 +19,14 @@
 #include <sys/debug.h>
 
 #include "libnvpair.h"
 
 #define FPRINTF(fp, ...)                        \
+        do {                                            \
         if (fprintf(fp, __VA_ARGS__) < 0)       \
-                return (-1)                     \
+                        return (-1);                    \
+        } while (0)
 
 /*
  * When formatting a string for JSON output we must escape certain characters,
  * as described in RFC4627.  This applies to both member names and
  * DATA_TYPE_STRING values.

@@ -326,11 +328,11 @@
                         VERIFY0(nvpair_value_int16_array(curr, &val, &valsz));
                         FPRINTF(fp, "[");
                         for (i = 0; i < valsz; i++) {
                                 if (i > 0)
                                         FPRINTF(fp, ",");
-                                FPRINTF(fp, "%hhd", val[i]);
+                                FPRINTF(fp, "%hd", val[i]);
                         }
                         FPRINTF(fp, "]");
                         break;
                 }