Print this page
6447 handful of nvpair cleanups

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libnvpair/libnvpair.c
          +++ new/usr/src/lib/libnvpair/libnvpair.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2012 by Delphix. All rights reserved.
  24   24   */
  25   25  
  26   26  #include <unistd.h>
  27      -#include <strings.h>
       27 +#include <string.h>
  28   28  #include <libintl.h>
  29   29  #include <sys/types.h>
  30   30  #include <sys/inttypes.h>
  31   31  #include <stdarg.h>
  32   32  #include <note.h>
  33   33  #include "libnvpair.h"
  34   34  
  35   35  /*
  36   36   * libnvpair - A tools library for manipulating <name, value> pairs.
  37   37   *
↓ open down ↓ 166 lines elided ↑ open up ↑
 204  204  NVLIST_PRTFUNC(boolean_value, boolean_t, int, "%d")
 205  205  NVLIST_PRTFUNC(byte, uchar_t, uchar_t, "0x%2.2x")
 206  206  NVLIST_PRTFUNC(int8, int8_t, int, "%d")
 207  207  NVLIST_PRTFUNC(uint8, uint8_t, uint8_t, "0x%x")
 208  208  NVLIST_PRTFUNC(int16, int16_t, int16_t, "%d")
 209  209  NVLIST_PRTFUNC(uint16, uint16_t, uint16_t, "0x%x")
 210  210  NVLIST_PRTFUNC(int32, int32_t, int32_t, "%d")
 211  211  NVLIST_PRTFUNC(uint32, uint32_t, uint32_t, "0x%x")
 212  212  NVLIST_PRTFUNC(int64, int64_t, longlong_t, "%lld")
 213  213  NVLIST_PRTFUNC(uint64, uint64_t, u_longlong_t, "0x%llx")
 214      -NVLIST_PRTFUNC(double, double, double, "0x%llf")
      214 +NVLIST_PRTFUNC(double, double, double, "0x%f")
 215  215  NVLIST_PRTFUNC(string, char *, char *, "%s")
 216  216  NVLIST_PRTFUNC(hrtime, hrtime_t, hrtime_t, "0x%llx")
 217  217  
 218  218  /*
 219  219   * Generate functions to print array-valued nvlist members.
 220  220   */
 221  221  
 222  222  #define NVLIST_ARRPRTFUNC(type_and_variant, vtype, ptype, vfmt) \
 223  223  static int \
 224  224  nvaprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
↓ open down ↓ 997 lines elided ↑ open up ↑
1222 1222                  /* check indexed value of array for match */
1223 1223                  sr = sscanf(value, "%"SCNi64, (int64_t *)&val_arg);
1224 1224                  if ((sr == 1) &&
1225 1225                      (nvpair_value_uint64_array(nvp, &val_array, &a_len) == 0) &&
1226 1226                      (ai < a_len) &&
1227 1227                      (val_array[ai] == val_arg))
1228 1228                          return (1);
1229 1229                  break;
1230 1230          }
1231 1231          case DATA_TYPE_BOOLEAN_VALUE: {
1232      -                boolean_t val, val_arg;
     1232 +                int32_t val_arg;
     1233 +                boolean_t val;
1233 1234  
1234 1235                  /* scanf boolean_t from value and check for match */
1235 1236                  sr = sscanf(value, "%"SCNi32, &val_arg);
1236 1237                  if ((sr == 1) &&
1237 1238                      (nvpair_value_boolean_value(nvp, &val) == 0) &&
1238 1239                      (val == val_arg))
1239 1240                          return (1);
1240 1241                  break;
1241 1242          }
1242 1243          case DATA_TYPE_BOOLEAN_ARRAY: {
1243      -                boolean_t *val_array, val_arg;
     1244 +                boolean_t *val_array;
     1245 +                int32_t val_arg;
1244 1246  
1245 1247                  /* check indexed value of array for match */
1246 1248                  sr = sscanf(value, "%"SCNi32, &val_arg);
1247 1249                  if ((sr == 1) &&
1248 1250                      (nvpair_value_boolean_array(nvp,
1249 1251                      &val_array, &a_len) == 0) &&
1250 1252                      (ai < a_len) &&
1251 1253                      (val_array[ai] == val_arg))
1252 1254                          return (1);
1253 1255                  break;
↓ open down ↓ 32 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX