From 2924858552cf0e633115c04ea1b31b525d561cc6 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 16 Mar 2009 10:02:06 -0700 Subject: [PATCH 1/2] Remove two self referential functions. Newer versions of gcc (4.3.0) detected the following unused code segments. --- .topdeps | 1 + .topmsg | 8 +++++++ cmd/zpool/zpool_main.c | 27 ----------------------- lib/libzfs/libzfs_dataset.c | 43 ------------------------------------- 4 files changed, 9 insertions(+), 70 deletions(-) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000..1f7391f92b --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000..b7a46338e7 --- /dev/null +++ b/.topmsg @@ -0,0 +1,8 @@ +From: Brian Behlendorf +Subject: [PATCH] fix deadcode + +Remove deadcode. It's possible the code should be in use +somewhere, but as the source code is laid out it currently +is not. + +Signed-off-by: Brian Behlendorf diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 42c6aabb63..13c8a59ab5 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -2214,33 +2214,6 @@ zpool_do_list(int argc, char **argv) return (ret); } -static nvlist_t * -zpool_get_vdev_by_name(nvlist_t *nv, char *name) -{ - nvlist_t **child; - uint_t c, children; - nvlist_t *match; - char *path; - - if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, - &child, &children) != 0) { - verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0); - if (strncmp(name, "/dev/dsk/", 9) == 0) - name += 9; - if (strncmp(path, "/dev/dsk/", 9) == 0) - path += 9; - if (strcmp(name, path) == 0) - return (nv); - return (NULL); - } - - for (c = 0; c < children; c++) - if ((match = zpool_get_vdev_by_name(child[c], name)) != NULL) - return (match); - - return (NULL); -} - static int zpool_do_attach_or_replace(int argc, char **argv, int replacing) { diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index a381a0e63a..405a21cd84 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -76,49 +76,6 @@ zfs_type_to_name(zfs_type_t type) return (NULL); } -/* - * Given a path and mask of ZFS types, return a string describing this dataset. - * This is used when we fail to open a dataset and we cannot get an exact type. - * We guess what the type would have been based on the path and the mask of - * acceptable types. - */ -static const char * -path_to_str(const char *path, int types) -{ - /* - * When given a single type, always report the exact type. - */ - if (types == ZFS_TYPE_SNAPSHOT) - return (dgettext(TEXT_DOMAIN, "snapshot")); - if (types == ZFS_TYPE_FILESYSTEM) - return (dgettext(TEXT_DOMAIN, "filesystem")); - if (types == ZFS_TYPE_VOLUME) - return (dgettext(TEXT_DOMAIN, "volume")); - - /* - * The user is requesting more than one type of dataset. If this is the - * case, consult the path itself. If we're looking for a snapshot, and - * a '@' is found, then report it as "snapshot". Otherwise, remove the - * snapshot attribute and try again. - */ - if (types & ZFS_TYPE_SNAPSHOT) { - if (strchr(path, '@') != NULL) - return (dgettext(TEXT_DOMAIN, "snapshot")); - return (path_to_str(path, types & ~ZFS_TYPE_SNAPSHOT)); - } - - /* - * The user has requested either filesystems or volumes. - * We have no way of knowing a priori what type this would be, so always - * report it as "filesystem" or "volume", our two primitive types. - */ - if (types & ZFS_TYPE_FILESYSTEM) - return (dgettext(TEXT_DOMAIN, "filesystem")); - - assert(types & ZFS_TYPE_VOLUME); - return (dgettext(TEXT_DOMAIN, "volume")); -} - /* * Validate a ZFS path. This is used even before trying to open the dataset, to * provide a more meaningful error message. We place a more useful message in From bb29348bc22604f79925cfd235e2aa736934d7e5 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 16 Mar 2009 10:11:57 -0700 Subject: [PATCH 2/2] New TopGit dependency: fix-deadcode --- .topdeps | 1 + 1 file changed, 1 insertion(+) diff --git a/.topdeps b/.topdeps index 04ac73ff29..154ef94beb 100644 --- a/.topdeps +++ b/.topdeps @@ -12,3 +12,4 @@ fix-stack fix-taskq fix-list fix-strncat +fix-deadcode