Skip to content

Commit

Permalink
libzfs: import: zpool_clear_label: actually fail if clearing l2arc he…
Browse files Browse the repository at this point in the history
…ader fails

Found with -Wunused-but-set-variable on Clang trunk

Signed-off-by: Ahelenia Ziemiańska <[email protected]>
  • Loading branch information
nabijaczleweli committed Apr 7, 2022
1 parent 718c0db commit 6b9898e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/libzfs/libzfs_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ zpool_clear_label(int fd)
struct stat64 statbuf;
int l;
vdev_label_t *label;
l2arc_dev_hdr_phys_t *l2dhdr;
l2arc_dev_hdr_phys_t *l2dhdr = NULL;
uint64_t size;
int labels_cleared = 0, header_cleared = 0;
boolean_t clear_l2arc_header = B_FALSE;
int labels_cleared = 0;
boolean_t clear_l2arc_header = B_FALSE, header_cleared = B_FALSE;

if (fstat64_blk(fd, &statbuf) == -1)
return (0);
Expand Down Expand Up @@ -210,20 +210,20 @@ zpool_clear_label(int fd)
}

/* Clear the L2ARC header. */
if (clear_l2arc_header) {
memset(l2dhdr, 0, sizeof (l2arc_dev_hdr_phys_t));
if (pwrite64(fd, l2dhdr, sizeof (l2arc_dev_hdr_phys_t),
VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t)) {
header_cleared++;
}
}
if (clear_l2arc_header &&
pwrite64(fd, l2dhdr, sizeof (l2arc_dev_hdr_phys_t),
VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t))
header_cleared = B_TRUE;

free(label);
free(l2dhdr);

if (labels_cleared == 0)
return (-1);

if (clear_l2arc_header && !header_cleared)
return (-1);

return (0);
}

Expand Down

0 comments on commit 6b9898e

Please sign in to comment.