From 0f7a0cc7c2e27f0e13f3efd02b8888187c7f4596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 12 Jan 2022 17:28:41 +0100 Subject: [PATCH] libzfs: const correctness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #12968 --- include/libzfs.h | 4 ++-- lib/libzfs/libzfs_crypto.c | 9 +++++---- lib/libzfs/libzfs_pool.c | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/libzfs.h b/include/libzfs.h index fe70a5b3a6..c0e53b88a6 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -553,8 +553,8 @@ _LIBZFS_H int zfs_crypto_create(libzfs_handle_t *, char *, nvlist_t *, nvlist_t *, boolean_t stdin_available, uint8_t **, uint_t *); _LIBZFS_H int zfs_crypto_clone_check(libzfs_handle_t *, zfs_handle_t *, char *, nvlist_t *); -_LIBZFS_H int zfs_crypto_attempt_load_keys(libzfs_handle_t *, char *); -_LIBZFS_H int zfs_crypto_load_key(zfs_handle_t *, boolean_t, char *); +_LIBZFS_H int zfs_crypto_attempt_load_keys(libzfs_handle_t *, const char *); +_LIBZFS_H int zfs_crypto_load_key(zfs_handle_t *, boolean_t, const char *); _LIBZFS_H int zfs_crypto_unload_key(zfs_handle_t *); _LIBZFS_H int zfs_crypto_rewrap(zfs_handle_t *, nvlist_t *, boolean_t); diff --git a/lib/libzfs/libzfs_crypto.c b/lib/libzfs/libzfs_crypto.c index e3486cf9a3..e7d3b09c67 100644 --- a/lib/libzfs/libzfs_crypto.c +++ b/lib/libzfs/libzfs_crypto.c @@ -685,7 +685,7 @@ end: */ static int get_key_material(libzfs_handle_t *hdl, boolean_t do_verify, boolean_t newkey, - zfs_keyformat_t keyformat, char *keylocation, const char *fsname, + zfs_keyformat_t keyformat, const char *keylocation, const char *fsname, uint8_t **km_out, size_t *kmlen_out, boolean_t *can_retry_out) { int ret; @@ -1240,7 +1240,7 @@ out: * filesystem and all of its children. */ int -zfs_crypto_attempt_load_keys(libzfs_handle_t *hdl, char *fsname) +zfs_crypto_attempt_load_keys(libzfs_handle_t *hdl, const char *fsname) { int ret; zfs_handle_t *zhp = NULL; @@ -1275,7 +1275,8 @@ error: } int -zfs_crypto_load_key(zfs_handle_t *zhp, boolean_t noop, char *alt_keylocation) +zfs_crypto_load_key(zfs_handle_t *zhp, boolean_t noop, + const char *alt_keylocation) { int ret, attempts = 0; char errbuf[1024]; @@ -1283,7 +1284,7 @@ zfs_crypto_load_key(zfs_handle_t *zhp, boolean_t noop, char *alt_keylocation) uint64_t keyformat = ZFS_KEYFORMAT_NONE; char prop_keylocation[MAXNAMELEN]; char prop_encroot[MAXNAMELEN]; - char *keylocation = NULL; + const char *keylocation = NULL; uint8_t *key_material = NULL, *key_data = NULL; size_t key_material_len; boolean_t is_encroot, can_retry = B_FALSE, correctible = B_FALSE; diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 2179c03d76..88c7ee74b7 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -2030,7 +2030,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, nvlist_t *nv = NULL; nvlist_t *nvinfo = NULL; nvlist_t *missing = NULL; - char *thename; + const char *thename; char *origname; int ret; int error = 0; @@ -2047,7 +2047,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, return (zfs_error_fmt(hdl, EZFS_INVALIDNAME, dgettext(TEXT_DOMAIN, "cannot import '%s'"), newname)); - thename = (char *)newname; + thename = newname; } else { thename = origname; }