Skip to contentSkip to conversation

Use parse_size_suffix in snapshot

PATCH David Goulet 1 participant 1 message Aug 23, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Merged with minor changes!

Thanks!
David

Quoted 49 lines · Simon Marchi
---
 src/bin/lttng/commands/snapshot.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
src/bin/lttng/commands/snapshot.c +2 -11
index 56acca8..5b62fed 100644
@@ -58,7 +58,7 @@ static struct poptOption snapshot_opts[] = {
 	{"ctrl-url",     'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0},
 	{"data-url",     'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0},
 	{"name",         'n', POPT_ARG_STRING, &opt_output_name, 0, 0, 0},
-	{"max-size",     'm', POPT_ARG_DOUBLE, 0, OPT_MAX_SIZE, 0, 0},
+	{"max-size",     'm', POPT_ARG_STRING, 0, OPT_MAX_SIZE, 0, 0},
 	{"list-options",   0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
 	{0, 0, 0, 0, 0, 0, 0}
 };
@@ -445,21 +445,12 @@ int cmd_snapshot(int argc, const char **argv)
 			char *endptr;
 			const char *opt = poptGetOptArg(pc);
 
-			/* Documented by the man page of strtoll(3). */
-			errno = 0;
-			val = strtoll(opt, &endptr, 10);
-			if ((errno == ERANGE && (val == LLONG_MAX || val == LONG_MIN))
-					|| (errno != 0 && val == 0)) {
+			if (utils_parse_size_suffix(opt, &val) < 0) {
 				ERR("Unable to handle max-size value %s", opt);
 				ret = CMD_ERROR;
 				goto end;
 			}
 
-			if (endptr == opt) {
-				ERR("No digits were found in %s", opt);
-				ret = CMD_ERROR;
-				goto end;
-			}
 			opt_max_size = val;
 
 			break;
Signature · 7 lines
1.7.1


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev