Skip to content

Commit

Permalink
5190 nvlist_lookup_nvpair should return ENOENT if there is no target …
Browse files Browse the repository at this point in the history
…NVP, but it returns EINVAL

Reviewed by: Bill Sommerfeld <sommerfeld@hamachi.org>
Reviewed by: Andy Fiddaman <illumos@fiddaman.net>
Approved by: Robert Mustacchi <rm@fingolfin.org>
  • Loading branch information
tsoome committed Apr 6, 2024
1 parent 8efd981 commit eca3956
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
14 changes: 7 additions & 7 deletions usr/src/common/nvpair/nvpair.c
Expand Up @@ -982,7 +982,7 @@ nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp)
* This function calculates the size of an nvpair value.
*
* The data argument controls the behavior in case of the data types
* DATA_TYPE_STRING and
* DATA_TYPE_STRING and
* DATA_TYPE_STRING_ARRAY
* Is data == NULL then the size of the string(s) is excluded.
*/
Expand Down Expand Up @@ -2038,7 +2038,7 @@ nvlist_lookup_nvpair_ei_sep(nvlist_t *nvl, const char *name, const char sep,

fail: if (ep && sepp)
*ep = sepp;
return (EINVAL);
return (ENOENT);
}

/*
Expand Down Expand Up @@ -2831,10 +2831,10 @@ nvs_native_nvlist(nvstream_t *nvs, nvlist_t *nvl, size_t *size)
case NVS_OP_GETSIZE:
/*
* if calculate for packed embedded list
* 4 for end of the embedded list
* 4 for end of the embedded list
* else
* 2 * sizeof (int32_t) for nvl_version and nvl_nvflag
* and 4 for end of the entire list
* 2 * sizeof (int32_t) for nvl_version and nvl_nvflag
* and 4 for end of the entire list
*/
if (native->n_flag) {
*size += 4;
Expand Down Expand Up @@ -3167,7 +3167,7 @@ nvs_xdr_nvlist(nvstream_t *nvs, nvlist_t *nvl, size_t *size)
switch (nvs->nvs_op) {
case NVS_OP_ENCODE:
case NVS_OP_DECODE: {
XDR *xdr = nvs->nvs_private;
XDR *xdr = nvs->nvs_private;

if (!xdr_int(xdr, &nvl->nvl_version) ||
!xdr_u_int(xdr, &nvl->nvl_nvflag))
Expand Down Expand Up @@ -3520,7 +3520,7 @@ nvs_xdr_nvp_size(nvstream_t *nvs, nvpair_t *nvp, size_t *size)
static int
nvs_xdr_nvpair(nvstream_t *nvs, nvpair_t *nvp, size_t *size)
{
XDR *xdr = nvs->nvs_private;
XDR *xdr = nvs->nvs_private;
int32_t encode_len, decode_len;

switch (nvs->nvs_op) {
Expand Down
3 changes: 0 additions & 3 deletions usr/src/lib/libnwam/common/libnwam_values.c
Expand Up @@ -525,9 +525,6 @@ nwam_get_prop_value(void *list, const char *name, nwam_value_t *valuep)
*valuep = NULL;

if ((nverr = nvlist_lookup_nvpair(list, name, &prop)) != 0) {
/* convert EINVAL to NOT_FOUND */
if (nverr == EINVAL)
return (NWAM_ENTITY_NOT_FOUND);
return (nwam_errno_to_nwam_error(nverr));
}

Expand Down

0 comments on commit eca3956

Please sign in to comment.