lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 13 Jun 2014 21:07:43 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Jiri Olsa <jolsa@...nel.org>
Cc:	linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...nel.org>,
	Jean Pihet <jean.pihet@...aro.org>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCH 13/17] perf tools: Add perf_config_u64 function

2014-06-13 (금), 00:08 +0200, Jiri Olsa:
> From: Jiri Olsa <jolsa@...hat.com>
> 
> Adding perf_config_u64 function to be able to parse
> 'llong' values out of config file.
> 
> Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
> Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
> Cc: David Ahern <dsahern@...il.com>
> Cc: Frederic Weisbecker <fweisbec@...il.com>
> Cc: Ingo Molnar <mingo@...nel.org>
> Cc: Jean Pihet <jean.pihet@...aro.org>
> Cc: Namhyung Kim <namhyung@...nel.org>
> Cc: Paul Mackerras <paulus@...ba.org>
> Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
>  tools/perf/util/cache.h  |  1 +
>  tools/perf/util/config.c | 22 ++++++++++++++++++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
> index 7b176dd..5cf9e1b 100644
> --- a/tools/perf/util/cache.h
> +++ b/tools/perf/util/cache.h
> @@ -22,6 +22,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *);
>  extern int perf_default_config(const char *, const char *, void *);
>  extern int perf_config(config_fn_t fn, void *);
>  extern int perf_config_int(const char *, const char *);
> +extern u64 perf_config_u64(const char *, const char *);
>  extern int perf_config_bool(const char *, const char *);
>  extern int config_error_nonbool(const char *);
>  extern const char *perf_config_dirname(const char *, const char *);
> diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
> index 24519e1..e68bbe3 100644
> --- a/tools/perf/util/config.c
> +++ b/tools/perf/util/config.c
> @@ -286,6 +286,20 @@ static int parse_unit_factor(const char *end, unsigned long *val)
>  	return 0;
>  }
>  
> +static int perf_parse_llong(const char *value, long long *ret)
> +{
> +	if (value && *value) {
> +		char *end;
> +		long val = strtoll(value, &end, 0);

Why not declare the val as long long?

> +		unsigned long factor = 1;

Also please add a blank line between declaration and actual body.

Thanks,
Namhyung


> +		if (!parse_unit_factor(end, &factor))
> +			return 0;
> +		*ret = val * factor;
> +		return 1;
> +	}
> +	return 0;
> +}
> +
>  static int perf_parse_long(const char *value, long *ret)
>  {
>  	if (value && *value) {
> @@ -307,6 +321,14 @@ static void die_bad_config(const char *name)
>  	die("bad config value for '%s'", name);
>  }
>  
> +u64 perf_config_u64(const char *name, const char *value)
> +{
> +	long long ret = 0;
> +	if (!perf_parse_llong(value, &ret))
> +		die_bad_config(name);
> +	return (u64) ret;
> +}
> +
>  int perf_config_int(const char *name, const char *value)
>  {
>  	long ret = 0;



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists