aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/module/nvpair/nvpair.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/module/nvpair/nvpair.c')
-rw-r--r--sys/contrib/openzfs/module/nvpair/nvpair.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/sys/contrib/openzfs/module/nvpair/nvpair.c b/sys/contrib/openzfs/module/nvpair/nvpair.c
index a442990dade0..887f7d32df4a 100644
--- a/sys/contrib/openzfs/module/nvpair/nvpair.c
+++ b/sys/contrib/openzfs/module/nvpair/nvpair.c
@@ -6,7 +6,7 @@
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
+ * or https://opensource.org/licenses/CDDL-1.0.
* See the License for the specific language governing permissions
* and limitations under the License.
*
@@ -41,6 +41,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/string.h>
+#include <rpc/types.h>
#include <rpc/xdr.h>
#include <sys/mod.h>
@@ -473,7 +474,7 @@ nvt_remove_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
}
i_nvp_t **tab = priv->nvp_hashtable;
- char *name = NVP_NAME(nvp);
+ const char *name = NVP_NAME(nvp);
uint64_t hash = nvt_hash(name);
uint64_t index = hash & (priv->nvp_nbuckets - 1);
@@ -528,7 +529,7 @@ nvt_add_nvpair(nvlist_t *nvl, nvpair_t *nvp)
}
i_nvp_t **tab = priv->nvp_hashtable;
- char *name = NVP_NAME(nvp);
+ const char *name = NVP_NAME(nvp);
uint64_t hash = nvt_hash(name);
uint64_t index = hash & (priv->nvp_nbuckets - 1);
@@ -1517,7 +1518,7 @@ nvlist_empty(const nvlist_t *nvl)
return (priv->nvp_list == NULL);
}
-char *
+const char *
nvpair_name(const nvpair_t *nvp)
{
return (NVP_NAME(nvp));
@@ -1731,7 +1732,7 @@ nvlist_lookup_double(const nvlist_t *nvl, const char *name, double *val)
#endif
int
-nvlist_lookup_string(nvlist_t *nvl, const char *name, char **val)
+nvlist_lookup_string(const nvlist_t *nvl, const char *name, const char **val)
{
return (nvlist_lookup_common(nvl, name, DATA_TYPE_STRING, NULL, val));
}
@@ -1917,7 +1918,7 @@ nvlist_lookup_pairs(nvlist_t *nvl, int flag, ...)
*/
static int
nvlist_lookup_nvpair_ei_sep(nvlist_t *nvl, const char *name, const char sep,
- nvpair_t **ret, int *ip, char **ep)
+ nvpair_t **ret, int *ip, const char **ep)
{
nvpair_t *nvp;
const char *np;
@@ -2057,8 +2058,11 @@ nvlist_lookup_nvpair_ei_sep(nvlist_t *nvl, const char *name, const char sep,
nvl = EMBEDDED_NVL(nvp);
break;
} else if (nvpair_type(nvp) == DATA_TYPE_NVLIST_ARRAY) {
- (void) nvpair_value_nvlist_array(nvp,
- &nva, (uint_t *)&n);
+ if (nvpair_value_nvlist_array(nvp,
+ &nva, (uint_t *)&n) != 0)
+ goto fail;
+ if (nva == NULL)
+ goto fail;
if ((n < 0) || (idx >= n))
goto fail;
nvl = nva[idx];
@@ -2094,7 +2098,7 @@ nvlist_lookup_nvpair(nvlist_t *nvl, const char *name, nvpair_t **ret)
* description.
*/
int nvlist_lookup_nvpair_embedded_index(nvlist_t *nvl,
- const char *name, nvpair_t **ret, int *ip, char **ep)
+ const char *name, nvpair_t **ret, int *ip, const char **ep)
{
return (nvlist_lookup_nvpair_ei_sep(nvl, name, '.', ret, ip, ep));
}
@@ -2189,7 +2193,7 @@ nvpair_value_double(const nvpair_t *nvp, double *val)
#endif
int
-nvpair_value_string(nvpair_t *nvp, char **val)
+nvpair_value_string(const nvpair_t *nvp, const char **val)
{
return (nvpair_value_common(nvp, DATA_TYPE_STRING, NULL, val));
}
@@ -2261,7 +2265,7 @@ nvpair_value_uint64_array(nvpair_t *nvp, uint64_t **val, uint_t *nelem)
}
int
-nvpair_value_string_array(nvpair_t *nvp, char ***val, uint_t *nelem)
+nvpair_value_string_array(nvpair_t *nvp, const char ***val, uint_t *nelem)
{
return (nvpair_value_common(nvp, DATA_TYPE_STRING_ARRAY, nelem, val));
}
@@ -2808,7 +2812,7 @@ nvs_native_create(nvstream_t *nvs, nvs_native_t *native, char *buf,
static void
nvs_native_destroy(nvstream_t *nvs)
{
- (void) nvs;
+ nvs->nvs_private = NULL;
}
static int
@@ -3189,7 +3193,7 @@ nvs_xdr_destroy(nvstream_t *nvs)
switch (nvs->nvs_op) {
case NVS_OP_ENCODE:
case NVS_OP_DECODE:
- xdr_destroy((XDR *)nvs->nvs_private);
+ nvs->nvs_private = NULL;
break;
default:
break;