From 0dd34a1955b06cdea460f2f1711b72536a5a511b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 7 Apr 2022 14:00:38 +0200 Subject: [PATCH] libzfs: import: zpool_clear_label: bool for boolean status 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 #13304 --- lib/libzfs/libzfs_import.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 806ab4e23b..ed3cfea56f 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -138,8 +138,8 @@ zpool_clear_label(int fd) int l; vdev_label_t *label; uint64_t size; - int labels_cleared = 0; - boolean_t clear_l2arc_header = B_FALSE, header_cleared = B_FALSE; + boolean_t labels_cleared = B_FALSE, clear_l2arc_header = B_FALSE, + header_cleared = B_FALSE; if (fstat64_blk(fd, &statbuf) == -1) return (0); @@ -198,9 +198,8 @@ zpool_clear_label(int fd) size_t label_size = sizeof (vdev_label_t) - (2 * VDEV_PAD_SIZE); if (pwrite64(fd, label, label_size, label_offset(size, l) + - (2 * VDEV_PAD_SIZE)) == label_size) { - labels_cleared++; - } + (2 * VDEV_PAD_SIZE)) == label_size) + labels_cleared = B_TRUE; } if (clear_l2arc_header) { @@ -214,10 +213,7 @@ zpool_clear_label(int fd) free(label); - if (labels_cleared == 0) - return (-1); - - if (clear_l2arc_header && !header_cleared) + if (!labels_cleared || (clear_l2arc_header && !header_cleared)) return (-1); return (0);