Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wunused-but-set-variable post-increments found by new Clang trunk (number 3 will shock you!) #13304

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions lib/libzfs/libzfs_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ zpool_clear_label(int fd)
struct stat64 statbuf;
int l;
vdev_label_t *label;
l2arc_dev_hdr_phys_t *l2dhdr;
uint64_t size;
int labels_cleared = 0, header_cleared = 0;
boolean_t clear_l2arc_header = 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);
Expand All @@ -150,11 +149,6 @@ zpool_clear_label(int fd)
if ((label = calloc(1, sizeof (vdev_label_t))) == NULL)
return (-1);

if ((l2dhdr = calloc(1, sizeof (l2arc_dev_hdr_phys_t))) == NULL) {
free(label);
return (-1);
}

for (l = 0; l < VDEV_LABELS; l++) {
uint64_t state, guid, l2cache;
nvlist_t *config;
Expand Down Expand Up @@ -204,24 +198,22 @@ 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;
}

/* 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++;
}
_Static_assert(sizeof (*label) >= sizeof (l2arc_dev_hdr_phys_t),
"label < l2arc_dev_hdr_phys_t");
memset(label, 0, sizeof (l2arc_dev_hdr_phys_t));
if (pwrite64(fd, label, sizeof (l2arc_dev_hdr_phys_t),
VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t))
header_cleared = B_TRUE;
}
behlendorf marked this conversation as resolved.
Show resolved Hide resolved

free(label);
free(l2dhdr);

if (labels_cleared == 0)
if (!labels_cleared || (clear_l2arc_header && !header_cleared))
return (-1);

return (0);
Expand Down
3 changes: 0 additions & 3 deletions module/zfs/vdev_removal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2251,7 +2251,6 @@ spa_vdev_remove_top_check(vdev_t *vd)
* and not be raidz or draid.
*/
vdev_t *rvd = spa->spa_root_vdev;
int num_indirect = 0;
for (uint64_t id = 0; id < rvd->vdev_children; id++) {
vdev_t *cvd = rvd->vdev_child[id];

Expand All @@ -2267,8 +2266,6 @@ spa_vdev_remove_top_check(vdev_t *vd)
if (cvd->vdev_ashift != 0 &&
cvd->vdev_alloc_bias == VDEV_BIAS_NONE)
ASSERT3U(cvd->vdev_ashift, ==, spa->spa_max_ashift);
if (cvd->vdev_ops == &vdev_indirect_ops)
num_indirect++;
if (!vdev_is_concrete(cvd))
continue;
if (vdev_get_nparity(cvd) != 0)
Expand Down
7 changes: 2 additions & 5 deletions tests/zfs-tests/cmd/draid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,14 +1312,11 @@ static int
draid_merge(int argc, char *argv[])
{
char filename[MAXPATHLEN] = {0};
int c, error, total_merged = 0, verbose = 0;
int c, error, total_merged = 0;
nvlist_t *allcfgs;

while ((c = getopt(argc, argv, ":v")) != -1) {
while ((c = getopt(argc, argv, ":")) != -1) {
switch (c) {
case 'v':
verbose++;
break;
case ':':
(void) fprintf(stderr,
"missing argument for '%c' option\n", optopt);
Expand Down