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] [day] [month] [year] [list]
Message-ID: <561F5446.2090403@nokia.com>
Date:	Thu, 15 Oct 2015 12:52:46 +0530
From:	Sriram Raghunathan <sriram.r@...ia.com>
To:	Sriram Raghunathan <sriram.r@...ia.com>, a.p.zijlstra@...llo.nl,
	paulus@...ba.org, acme@...nel.org, yunlong.song@...wei.com
CC:	mingo@...hat.com, artagnon@...il.com, hemant@...ux.vnet.ibm.com,
	jolsa@...nel.org, dsahern@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] perf :redirection of usage strings to stdout

Sorry, I made a mistake please ignore this patch.

Sriram
On Wednesday 14 October 2015 10:40 PM, Sriram Raghunathan wrote:
> This patch is to redirect the usage/builtin help strings
> to stdout rather than stderr. This is follows the patter
> similar to that of some of the coreutils (ls, rm).
>
> This patch originated from the discussion on a mail loop
> about the inconsistency  usage of stdout/stderr usage.
>
> Tested the piece of code below with
>
> # perf stat -h > /tmp/foo 2>> /tmp/bar
> # perf --help > /tmp/foo 2>&1 /tmp/bar
>
> Signed-off-by: Sriram Raghunathan <sriram.r@...ia.com>
> ---
>   tools/perf/util/parse-options.c | 54 ++++++++++++++++++++---------------------
>   1 file changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
> index 01626be..c81b2e3 100644
> --- a/tools/perf/util/parse-options.c
> +++ b/tools/perf/util/parse-options.c
> @@ -563,9 +563,9 @@ static void print_option_help(const struct option *opts, int full)
>   	int pad;
>   
>   	if (opts->type == OPTION_GROUP) {
> -		fputc('\n', stderr);
> +		fputc('\n', stdout);
>   		if (*opts->help)
> -			fprintf(stderr, "%s\n", opts->help);
> +			fprintf(stdout, "%s\n", opts->help);
>   		return;
>   	}
>   	if (!full && (opts->flags & PARSE_OPT_HIDDEN))
> @@ -573,16 +573,16 @@ static void print_option_help(const struct option *opts, int full)
>   	if (opts->flags & PARSE_OPT_DISABLED)
>   		return;
>   
> -	pos = fprintf(stderr, "    ");
> +	pos = fprintf(stdout, "    ");
>   	if (opts->short_name)
> -		pos += fprintf(stderr, "-%c", opts->short_name);
> +		pos += fprintf(stdout, "-%c", opts->short_name);
>   	else
> -		pos += fprintf(stderr, "    ");
> +		pos += fprintf(stdout, "    ");
>   
>   	if (opts->long_name && opts->short_name)
> -		pos += fprintf(stderr, ", ");
> +		pos += fprintf(stdout, ", ");
>   	if (opts->long_name)
> -		pos += fprintf(stderr, "--%s", opts->long_name);
> +		pos += fprintf(stdout, "--%s", opts->long_name);
>   
>   	switch (opts->type) {
>   	case OPTION_ARGUMENT:
> @@ -593,11 +593,11 @@ static void print_option_help(const struct option *opts, int full)
>   	case OPTION_UINTEGER:
>   		if (opts->flags & PARSE_OPT_OPTARG)
>   			if (opts->long_name)
> -				pos += fprintf(stderr, "[=<n>]");
> +				pos += fprintf(stdout, "[=<n>]");
>   			else
> -				pos += fprintf(stderr, "[<n>]");
> +				pos += fprintf(stdout, "[<n>]");
>   		else
> -			pos += fprintf(stderr, " <n>");
> +			pos += fprintf(stdout, " <n>");
>   		break;
>   	case OPTION_CALLBACK:
>   		if (opts->flags & PARSE_OPT_NOARG)
> @@ -607,19 +607,19 @@ static void print_option_help(const struct option *opts, int full)
>   		if (opts->argh) {
>   			if (opts->flags & PARSE_OPT_OPTARG)
>   				if (opts->long_name)
> -					pos += fprintf(stderr, "[=<%s>]", opts->argh);
> +					pos += fprintf(stdout, "[=<%s>]", opts->argh);
>   				else
> -					pos += fprintf(stderr, "[<%s>]", opts->argh);
> +					pos += fprintf(stdout, "[<%s>]", opts->argh);
>   			else
> -				pos += fprintf(stderr, " <%s>", opts->argh);
> +				pos += fprintf(stdout, " <%s>", opts->argh);
>   		} else {
>   			if (opts->flags & PARSE_OPT_OPTARG)
>   				if (opts->long_name)
> -					pos += fprintf(stderr, "[=...]");
> +					pos += fprintf(stdout, "[=...]");
>   				else
> -					pos += fprintf(stderr, "[...]");
> +					pos += fprintf(stdout, "[...]");
>   			else
> -				pos += fprintf(stderr, " ...");
> +				pos += fprintf(stdout, " ...");
>   		}
>   		break;
>   	default: /* OPTION_{BIT,BOOLEAN,SET_UINT,SET_PTR} */
> @@ -636,10 +636,10 @@ static void print_option_help(const struct option *opts, int full)
>   	if (pos <= USAGE_OPTS_WIDTH)
>   		pad = USAGE_OPTS_WIDTH - pos;
>   	else {
> -		fputc('\n', stderr);
> +		fputc('\n', stdout);
>   		pad = USAGE_OPTS_WIDTH;
>   	}
> -	fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
> +	fprintf(stdout, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
>   }
>   
>   int usage_with_options_internal(const char * const *usagestr,
> @@ -648,23 +648,23 @@ int usage_with_options_internal(const char * const *usagestr,
>   	if (!usagestr)
>   		return PARSE_OPT_HELP;
>   
> -	fprintf(stderr, "\n usage: %s\n", *usagestr++);
> +	fprintf(stdout, "\n usage: %s\n", *usagestr++);
>   	while (*usagestr && **usagestr)
> -		fprintf(stderr, "    or: %s\n", *usagestr++);
> +		fprintf(stdout, "    or: %s\n", *usagestr++);
>   	while (*usagestr) {
> -		fprintf(stderr, "%s%s\n",
> +		fprintf(stdout, "%s%s\n",
>   				**usagestr ? "    " : "",
>   				*usagestr);
>   		usagestr++;
>   	}
>   
>   	if (opts->type != OPTION_GROUP)
> -		fputc('\n', stderr);
> +		fputc('\n', stdout);
>   
>   	for (  ; opts->type != OPTION_END; opts++)
>   		print_option_help(opts, full);
>   
> -	fputc('\n', stderr);
> +	fputc('\n', stdout);
>   
>   	return PARSE_OPT_HELP;
>   }
> @@ -684,16 +684,16 @@ int parse_options_usage(const char * const *usagestr,
>   	if (!usagestr)
>   		goto opt;
>   
> -	fprintf(stderr, "\n usage: %s\n", *usagestr++);
> +	fprintf(stdout, "\n usage: %s\n", *usagestr++);
>   	while (*usagestr && **usagestr)
> -		fprintf(stderr, "    or: %s\n", *usagestr++);
> +		fprintf(stdout, "    or: %s\n", *usagestr++);
>   	while (*usagestr) {
> -		fprintf(stderr, "%s%s\n",
> +		fprintf(stdout, "%s%s\n",
>   				**usagestr ? "    " : "",
>   				*usagestr);
>   		usagestr++;
>   	}
> -	fputc('\n', stderr);
> +	fputc('\n', stdout);
>   
>   opt:
>   	for (  ; opts->type != OPTION_END; opts++) {

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ