]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix double const qualifier declarations
authorTino Reichardt <milky-zfs@mcmilk.de>
Fri, 30 Sep 2022 22:34:39 +0000 (00:34 +0200)
committerGitHub <noreply@github.com>
Fri, 30 Sep 2022 22:34:39 +0000 (15:34 -0700)
Some header files define structures like this one:

typedef const struct zio_checksum_info {
/* ... */
const char *ci_name;
} zio_abd_checksum_func_t;

So we can use `zio_abd_checksum_func_t` for const declarations now.
It's not needed that we use the `const` qualifier again like this:
`const zio_abd_checksum_func_t *varname;`

This patch solves the double const qualifiers, which were found by
smatch.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Closes #13961

13 files changed:
include/libzutil.h
include/sys/dmu.h
include/sys/zio_checksum.h
include/sys/zio_compress.h
lib/libzpool/util.c
lib/libzutil/zutil_import.c
lib/libzutil/zutil_import.h
module/os/linux/zfs/zpl_ctldir.c
module/zfs/dmu.c
module/zfs/sa.c
module/zfs/vdev.c
module/zfs/zio_checksum.c
module/zfs/zio_compress.c

index 9b86c351bd2d3b7f1cbeae8a9e016dc157127d0e..0b4075c160164ee213e1757a199c38965d0fda5f 100644 (file)
@@ -56,8 +56,8 @@ typedef const struct pool_config_ops {
 /*
  * An instance of pool_config_ops_t is expected in the caller's binary.
  */
-_LIBZUTIL_H const pool_config_ops_t libzfs_config_ops;
-_LIBZUTIL_H const pool_config_ops_t libzpool_config_ops;
+_LIBZUTIL_H pool_config_ops_t libzfs_config_ops;
+_LIBZUTIL_H pool_config_ops_t libzpool_config_ops;
 
 typedef struct importargs {
        char **path;            /* a list of paths to search            */
@@ -71,9 +71,9 @@ typedef struct importargs {
 } importargs_t;
 
 _LIBZUTIL_H nvlist_t *zpool_search_import(void *, importargs_t *,
-    const pool_config_ops_t *);
+    pool_config_ops_t *);
 _LIBZUTIL_H int zpool_find_config(void *, const char *, nvlist_t **,
-    importargs_t *, const pool_config_ops_t *);
+    importargs_t *, pool_config_ops_t *);
 
 _LIBZUTIL_H const char * const * zpool_default_search_paths(size_t *count);
 _LIBZUTIL_H int zpool_read_label(int, nvlist_t **, int *);
index e20b00d867403f8c1f1d632094121935dfe04542..d68700d371db6bc8725a205b6e9f9e3188e54fc9 100644 (file)
@@ -907,7 +907,7 @@ typedef const struct dmu_object_byteswap_info {
 } dmu_object_byteswap_info_t;
 
 extern const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES];
-extern const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS];
+extern dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS];
 
 /*
  * Get information on a DMU object.
index 84e371d6c3eff9d5538288cde0c7f0e67eebe4b9..5903678dfb417c90323cd91c06ab18107113d9e5 100644 (file)
@@ -102,7 +102,7 @@ typedef struct zio_bad_cksum {
        uint8_t                 zbc_has_cksum;  /* expected/actual valid */
 } zio_bad_cksum_t;
 
-_SYS_ZIO_CHECKSUM_H const zio_checksum_info_t
+_SYS_ZIO_CHECKSUM_H zio_checksum_info_t
     zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS];
 
 /*
index a736d8091986e425e98da71acec25f91f3bcfdd7..19fc44952db6019845982630af991c0a8e232967 100644 (file)
@@ -152,7 +152,7 @@ typedef const struct zio_compress_info {
        zio_decompresslevel_func_t      *ci_decompress_level;
 } zio_compress_info_t;
 
-extern const zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS];
+extern zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS];
 
 /*
  * lz4 compression init & free
index 6ff0d2853729178982a789a4cd6538fde74ebb38..0ce7822a3563574665c044cc6f26d7c8b8401b93 100644 (file)
@@ -350,7 +350,7 @@ pool_active(void *unused, const char *name, uint64_t guid,
 }
 #endif
 
-const pool_config_ops_t libzpool_config_ops = {
+pool_config_ops_t libzpool_config_ops = {
        .pco_refresh_config = refresh_config,
        .pco_pool_active = pool_active,
 };
index 252b0bac685c6309e535ca476fc53446b6d9a8c4..e3f1c8942564d2a25026e95d6b907868f39334aa 100644 (file)
@@ -1777,8 +1777,7 @@ zpool_find_import(libpc_handle_t *hdl, importargs_t *iarg)
 
 
 nvlist_t *
-zpool_search_import(void *hdl, importargs_t *import,
-    const pool_config_ops_t *pco)
+zpool_search_import(void *hdl, importargs_t *import, pool_config_ops_t *pco)
 {
        libpc_handle_t handle = { 0 };
        nvlist_t *pools = NULL;
@@ -1821,7 +1820,7 @@ pool_match(nvlist_t *cfg, char *tgt)
 
 int
 zpool_find_config(void *hdl, const char *target, nvlist_t **configp,
-    importargs_t *args, const pool_config_ops_t *pco)
+    importargs_t *args, pool_config_ops_t *pco)
 {
        nvlist_t *pools;
        nvlist_t *match = NULL;
index b68a7fcfcb78dca080b7e89db641c6f5da8fd34f..482315e44130e1ce004b17a2603e6a93a962e8a9 100644 (file)
@@ -43,7 +43,7 @@ typedef struct libpc_handle {
        boolean_t lpc_open_access_error;
        boolean_t lpc_desc_active;
        char lpc_desc[1024];
-       const pool_config_ops_t *lpc_ops;
+       pool_config_ops_t *lpc_ops;
        void *lpc_lib_handle;
 } libpc_handle_t;
 
index 1a688687ac4bbd15e83607a6cf58d76f2db437ca..837629e4a5e025c473e8ad1a4e70aeb98f8f7ea8 100644 (file)
@@ -208,7 +208,7 @@ zpl_snapdir_revalidate(struct dentry *dentry, unsigned int flags)
        return (!!dentry->d_inode);
 }
 
-static const dentry_operations_t zpl_dops_snapdirs = {
+static dentry_operations_t zpl_dops_snapdirs = {
 /*
  * Auto mounting of snapshots is only supported for 2.6.37 and
  * newer kernels.  Prior to this kernel the ops->follow_link()
index 3bf08fbdc118da3ef45642b77d7bd8c992a1ded4..9e67eb51f415ae539720b99f157fbcb15ad7035b 100644 (file)
@@ -145,7 +145,7 @@ const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = {
        {DMU_BSWAP_UINT64, TRUE,  FALSE, FALSE, "bpobj subobj"          }
 };
 
-const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS] = {
+dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS] = {
        {       byteswap_uint8_array,   "uint8"         },
        {       byteswap_uint16_array,  "uint16"        },
        {       byteswap_uint32_array,  "uint32"        },
index c094a8f0730a8d2f7f0169936e9e11f3172b4678..5568a24b84fe8a6b00aed3bca8ec0549fe4ed454 100644 (file)
@@ -141,7 +141,7 @@ static int sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
     sa_data_op_t action, sa_data_locator_t *locator, void *datastart,
     uint16_t buflen, dmu_tx_t *tx);
 
-static const arc_byteswap_func_t sa_bswap_table[] = {
+static arc_byteswap_func_t sa_bswap_table[] = {
        byteswap_uint64_array,
        byteswap_uint32_array,
        byteswap_uint16_array,
index b097e09210afa754d55f91cff8811ce6b8eee4a9..66cec052b669231c95fadbb2a69818d0339f9912 100644 (file)
@@ -224,7 +224,7 @@ vdev_dbgmsg_print_tree(vdev_t *vd, int indent)
  * Virtual device management.
  */
 
-static const vdev_ops_t *const vdev_ops_table[] = {
+static vdev_ops_t *const vdev_ops_table[] = {
        &vdev_root_ops,
        &vdev_raidz_ops,
        &vdev_draid_ops,
@@ -246,7 +246,7 @@ static const vdev_ops_t *const vdev_ops_table[] = {
 static vdev_ops_t *
 vdev_getops(const char *type)
 {
-       const vdev_ops_t *ops, *const *opspp;
+       vdev_ops_t *ops, *const *opspp;
 
        for (opspp = vdev_ops_table; (ops = *opspp) != NULL; opspp++)
                if (strcmp(ops->vdev_op_type, type) == 0)
index b3c5fbbd8bba7a4b7ccddd27e950805e3349e5dd..37cd35bc847f14863210595bfd64c771056cf3ca 100644 (file)
@@ -160,7 +160,7 @@ abd_fletcher_4_byteswap(abd_t *abd, uint64_t size,
        abd_fletcher_4_impl(abd, size, &acd);
 }
 
-const zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = {
+zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = {
        {{NULL, NULL}, NULL, NULL, 0, "inherit"},
        {{NULL, NULL}, NULL, NULL, 0, "on"},
        {{abd_checksum_off,             abd_checksum_off},
index 6527e33ca37d87c11e2ba1e150b4fe316977c6f0..4c9cbc96209328acc7754abeca9b93c0c36e4d16 100644 (file)
@@ -49,7 +49,7 @@ unsigned long zio_decompress_fail_fraction = 0;
 /*
  * Compression vectors.
  */
-const zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS] = {
+zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS] = {
        {"inherit",     0,      NULL,           NULL, NULL},
        {"on",          0,      NULL,           NULL, NULL},
        {"uncompressed", 0,     NULL,           NULL, NULL},