diff options
author | Giuseppe Di Natale <[email protected]> | 2017-03-28 17:22:46 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-03-28 17:22:46 -0700 |
commit | 2035575fd67fd7dd14f072e1cb6f4bae8ca62c7d (patch) | |
tree | 139c450e011a15e860a3c535c379d0e942a12f2c /lib | |
parent | ff61d1a4959065aa99d52489438f6737765987c6 (diff) |
OpenZFS 7990 - libzfs: snapspec_cb() does not need to call zfs_strdup()
Authored by: Marcel Telka <[email protected]>
Reviewed by: Yuri Pankov <[email protected]>
Reviewed by: Toomas Soome <[email protected]>
Approved by: Matthew Ahrens <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Ported-by: Giuseppe Di Natale <[email protected]>
OpenZFS-issue: https://www.illumos.org/issues/7990
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/d8584ba
Closes #5939
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs_iter.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/libzfs/libzfs_iter.c b/lib/libzfs/libzfs_iter.c index e22a2c85b..d78c757a5 100644 --- a/lib/libzfs/libzfs_iter.c +++ b/lib/libzfs/libzfs_iter.c @@ -312,16 +312,17 @@ 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); @@ -329,10 +330,6 @@ snapspec_cb(zfs_handle_t *zhp, void *arg) zfs_close(zhp); } - if (strcmp(shortsnapname, ssa->ssa_last) == 0) - ssa->ssa_seenlast = B_TRUE; - free(shortsnapname); - return (err); } |