6447 handful of nvpair cleanups
illumos/illumos-gate@759e89be35
759e89be35
https://www.illumos.org/issues/6447
I got a patch from someone who uses nvpair code outside of illumos. It fixes a
couple of gcc warnings/bugs for him.
1. silence uninitialized use warnings
2. add parentheses around assignment used as truth value
3. fix printf format specifier (ll is for integers only)
4. strstr, strspn, strcspn, and strcmp are declared in string.h, not
strings.h.
5. avoid scanning integer into boolean variable
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Steve Dougherty <sdougherty@barracuda.com>
This commit is contained in:
parent
0957649a03
commit
298580cb35
@ -1624,6 +1624,8 @@ nvlist_lookup_nvpair_ei_sep(nvlist_t *nvl, const char *name, const char sep,
|
||||
if ((nvl == NULL) || (name == NULL))
|
||||
return (EINVAL);
|
||||
|
||||
sepp = NULL;
|
||||
idx = 0;
|
||||
/* step through components of name */
|
||||
for (np = name; np && *np; np = sepp) {
|
||||
/* ensure unique names */
|
||||
@ -2381,7 +2383,7 @@ nvlist_xpack(nvlist_t *nvl, char **bufp, size_t *buflen, int encoding,
|
||||
*/
|
||||
nv_priv_init(&nvpriv, nva, 0);
|
||||
|
||||
if (err = nvlist_size(nvl, &alloc_size, encoding))
|
||||
if ((err = nvlist_size(nvl, &alloc_size, encoding)))
|
||||
return (err);
|
||||
|
||||
if ((buf = nv_mem_zalloc(&nvpriv, alloc_size)) == NULL)
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/inttypes.h>
|
||||
@ -211,7 +211,7 @@ NVLIST_PRTFUNC(int32, int32_t, int32_t, "%d")
|
||||
NVLIST_PRTFUNC(uint32, uint32_t, uint32_t, "0x%x")
|
||||
NVLIST_PRTFUNC(int64, int64_t, longlong_t, "%lld")
|
||||
NVLIST_PRTFUNC(uint64, uint64_t, u_longlong_t, "0x%llx")
|
||||
NVLIST_PRTFUNC(double, double, double, "0x%llf")
|
||||
NVLIST_PRTFUNC(double, double, double, "0x%f")
|
||||
NVLIST_PRTFUNC(string, char *, char *, "%s")
|
||||
NVLIST_PRTFUNC(hrtime, hrtime_t, hrtime_t, "0x%llx")
|
||||
|
||||
@ -1218,7 +1218,8 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai,
|
||||
break;
|
||||
}
|
||||
case DATA_TYPE_BOOLEAN_VALUE: {
|
||||
boolean_t val, val_arg;
|
||||
int32_t val_arg;
|
||||
boolean_t val;
|
||||
|
||||
/* scanf boolean_t from value and check for match */
|
||||
sr = sscanf(value, "%"SCNi32, &val_arg);
|
||||
@ -1229,7 +1230,8 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai,
|
||||
break;
|
||||
}
|
||||
case DATA_TYPE_BOOLEAN_ARRAY: {
|
||||
boolean_t *val_array, val_arg;
|
||||
boolean_t *val_array;
|
||||
int32_t val_arg;
|
||||
|
||||
/* check indexed value of array for match */
|
||||
sr = sscanf(value, "%"SCNi32, &val_arg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user