zfs: holds: general cleanup

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13373
This commit is contained in:
наб 2022-04-23 19:19:41 +02:00 committed by Brian Behlendorf
parent 849c14e048
commit 55d36e47c8
1 changed files with 7 additions and 11 deletions

View File

@ -6495,13 +6495,10 @@ holds_callback(zfs_handle_t *zhp, void *data)
static int static int
zfs_do_holds(int argc, char **argv) zfs_do_holds(int argc, char **argv)
{ {
int errors = 0;
int c; int c;
int i; boolean_t errors = B_FALSE;
boolean_t scripted = B_FALSE; boolean_t scripted = B_FALSE;
boolean_t recursive = B_FALSE; boolean_t recursive = B_FALSE;
const char *opts = "rH";
nvlist_t *nvl;
int types = ZFS_TYPE_SNAPSHOT; int types = ZFS_TYPE_SNAPSHOT;
holds_cbdata_t cb = { 0 }; holds_cbdata_t cb = { 0 };
@ -6511,7 +6508,7 @@ zfs_do_holds(int argc, char **argv)
int flags = 0; int flags = 0;
/* check options */ /* check options */
while ((c = getopt(argc, argv, opts)) != -1) { while ((c = getopt(argc, argv, "rH")) != -1) {
switch (c) { switch (c) {
case 'r': case 'r':
recursive = B_TRUE; recursive = B_TRUE;
@ -6538,10 +6535,9 @@ zfs_do_holds(int argc, char **argv)
if (argc < 1) if (argc < 1)
usage(B_FALSE); usage(B_FALSE);
if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) nvlist_t *nvl = fnvlist_alloc();
nomem();
for (i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {
char *snapshot = argv[i]; char *snapshot = argv[i];
const char *delim; const char *delim;
const char *snapname; const char *snapname;
@ -6550,7 +6546,7 @@ zfs_do_holds(int argc, char **argv)
if (delim == NULL) { if (delim == NULL) {
(void) fprintf(stderr, (void) fprintf(stderr,
gettext("'%s' is not a snapshot\n"), snapshot); gettext("'%s' is not a snapshot\n"), snapshot);
++errors; errors = B_TRUE;
continue; continue;
} }
snapname = delim + 1; snapname = delim + 1;
@ -6567,7 +6563,7 @@ zfs_do_holds(int argc, char **argv)
ret = zfs_for_each(argc, argv, flags, types, NULL, NULL, limit, ret = zfs_for_each(argc, argv, flags, types, NULL, NULL, limit,
holds_callback, &cb); holds_callback, &cb);
if (ret != 0) if (ret != 0)
++errors; errors = B_TRUE;
} }
/* /*
@ -6580,7 +6576,7 @@ zfs_do_holds(int argc, char **argv)
nvlist_free(nvl); nvlist_free(nvl);
return (0 != errors); return (errors);
} }
#define CHECK_SPINNER 30 #define CHECK_SPINNER 30