[lttng-dev] [PATCH lttng-tools] Use parse_size_suffix in snapshot

David Goulet dgoulet at ev0ke.net
Fri Aug 23 15:49:46 EDT 2013


Merged with minor changes!

Thanks!
David

On 13 Aug (14:22:31), Simon Marchi wrote:
> Signed-off-by: Simon Marchi <simon.marchi at polymtl.ca>
> ---
>  src/bin/lttng/commands/snapshot.c |   13 ++-----------
>  1 files changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/src/bin/lttng/commands/snapshot.c b/src/bin/lttng/commands/snapshot.c
> index 56acca8..5b62fed 100644
> --- a/src/bin/lttng/commands/snapshot.c
> +++ b/src/bin/lttng/commands/snapshot.c
> @@ -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;
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev



More information about the lttng-dev mailing list