aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-05-22 16:23:59 +0200
committerBrian Behlendorf <[email protected]>2021-06-11 09:10:00 -0700
commit3aa81a6635bf025298a40bf7b62ab57c556cfbbe (patch)
treeabdff392ed10a421c98206ef7ee40bfa811d42d9 /lib
parent1a345d645a5389ac4f9922bc7ecf5cc519e15d32 (diff)
linux/libzutil: use ARRAY_SIZE instead of constant for search paths
Reviewed-by: John Kennedy <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12105
Diffstat (limited to 'lib')
-rw-r--r--lib/libzutil/os/freebsd/zutil_import_os.c2
-rw-r--r--lib/libzutil/os/linux/zutil_import_os.c11
2 files changed, 6 insertions, 7 deletions
diff --git a/lib/libzutil/os/freebsd/zutil_import_os.c b/lib/libzutil/os/freebsd/zutil_import_os.c
index 36c4d90aa..2d8900ce2 100644
--- a/lib/libzutil/os/freebsd/zutil_import_os.c
+++ b/lib/libzutil/os/freebsd/zutil_import_os.c
@@ -168,7 +168,7 @@ out:
(void) close(fd);
}
-static const char *
+static const char * const
zpool_default_import_path[] = {
"/dev"
};
diff --git a/lib/libzutil/os/linux/zutil_import_os.c b/lib/libzutil/os/linux/zutil_import_os.c
index 84c3cb44f..0a647375b 100644
--- a/lib/libzutil/os/linux/zutil_import_os.c
+++ b/lib/libzutil/os/linux/zutil_import_os.c
@@ -74,7 +74,6 @@
#endif
#include <blkid/blkid.h>
-#define DEFAULT_IMPORT_PATH_SIZE 9
#define DEV_BYID_PATH "/dev/disk/by-id/"
static boolean_t
@@ -255,8 +254,8 @@ zpool_open_func(void *arg)
}
}
-static char *
-zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE] = {
+static const char * const
+zpool_default_import_path[] = {
"/dev/disk/by-vdev", /* Custom rules, use first if they exist */
"/dev/mapper", /* Use multipath devices before components */
"/dev/disk/by-partlabel", /* Single unique entry set by user */
@@ -271,8 +270,8 @@ zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE] = {
const char * const *
zpool_default_search_paths(size_t *count)
{
- *count = DEFAULT_IMPORT_PATH_SIZE;
- return ((const char * const *)zpool_default_import_path);
+ *count = ARRAY_SIZE(zpool_default_import_path);
+ return (zpool_default_import_path);
}
/*
@@ -300,7 +299,7 @@ zfs_path_order(char *name, int *order)
}
free(envdup);
} else {
- for (i = 0; i < DEFAULT_IMPORT_PATH_SIZE; i++) {
+ for (i = 0; i < ARRAY_SIZE(zpool_default_import_path); i++) {
if (strncmp(name, zpool_default_import_path[i],
strlen(zpool_default_import_path[i])) == 0) {
*order = i;