aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs
diff options
context:
space:
mode:
authorнаб <[email protected]>2022-04-07 14:00:38 +0200
committerBrian Behlendorf <[email protected]>2022-04-13 11:37:18 -0700
commit0dd34a1955b06cdea460f2f1711b72536a5a511b (patch)
treedffb4d4a04ca9cd6a57d732a94c207ec09b9cf8e /lib/libzfs
parent74e4bfbcff3636182b76a18d6d08efd3ad0ad165 (diff)
libzfs: import: zpool_clear_label: bool for boolean status
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #13304
Diffstat (limited to 'lib/libzfs')
-rw-r--r--lib/libzfs/libzfs_import.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c
index 806ab4e23..ed3cfea56 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);