Skip to content
Permalink
Browse files

7990 libzfs: snapspec_cb() does not need to call zfs_strdup()

Reviewed by: Yuri Pankov <yuri.pankov@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
  • Loading branch information...
mtelka authored and ahrens committed Mar 21, 2017
1 parent 2ed5314 commit d8584ba6fb7a5e46da1725845b99ae5fab5a4baf
Showing with 4 additions and 7 deletions.
  1. +4 −7 usr/src/lib/libzfs/common/libzfs_iter.c
@@ -317,27 +317,24 @@ static int
snapspec_cb(zfs_handle_t *zhp, void *arg)
{
snapspec_arg_t *ssa = arg;
char *shortsnapname;
const char *shortsnapname;
int err = 0;

if (ssa->ssa_seenlast)
return (0);
shortsnapname = zfs_strdup(zhp->zfs_hdl,
strchr(zfs_get_name(zhp), '@') + 1);

shortsnapname = strchr(zfs_get_name(zhp), '@') + 1;
if (!ssa->ssa_seenfirst && strcmp(shortsnapname, ssa->ssa_first) == 0)
ssa->ssa_seenfirst = B_TRUE;
if (strcmp(shortsnapname, ssa->ssa_last) == 0)
ssa->ssa_seenlast = B_TRUE;

if (ssa->ssa_seenfirst) {
err = ssa->ssa_func(zhp, ssa->ssa_arg);
} else {
zfs_close(zhp);
}

if (strcmp(shortsnapname, ssa->ssa_last) == 0)
ssa->ssa_seenlast = B_TRUE;
free(shortsnapname);

return (err);
}

0 comments on commit d8584ba

Please sign in to comment.
You can’t perform that action at this time.