diff mbox

[2/6] mtdinfo: send help/version info to stdout

Message ID 1307427548-29306-2-git-send-email-vapier@gentoo.org
State Accepted, archived
Headers show

Commit Message

Mike Frysinger June 7, 2011, 6:19 a.m. UTC
Usage/version information should go to stdout when it is expected behavior
(i.e. the user requested it explicitly).  This info should go to stderr
only when the usage info is being shown as a result of incorrect options.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 ubi-utils/src/mtdinfo.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Comments

Artem Bityutskiy June 7, 2011, 6:36 a.m. UTC | #1
On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
> Usage/version information should go to stdout when it is expected behavior
> (i.e. the user requested it explicitly).  This info should go to stderr
> only when the usage info is being shown as a result of incorrect options.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

This is fine, but all other ubi utils need this change then as well. I
think this piece of code was copypasted in all ubi-utils, so you should
easily find it and change.
Florian Fainelli June 7, 2011, 8:40 a.m. UTC | #2
On Tuesday 07 June 2011 08:19:04 Mike Frysinger wrote:
> Usage/version information should go to stdout when it is expected behavior
> (i.e. the user requested it explicitly).  This info should go to stderr
> only when the usage info is being shown as a result of incorrect options.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
>  ubi-utils/src/mtdinfo.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/ubi-utils/src/mtdinfo.c b/ubi-utils/src/mtdinfo.c
> index c9f6f58..f20fe49 100644
> --- a/ubi-utils/src/mtdinfo.c
> +++ b/ubi-utils/src/mtdinfo.c
> @@ -110,13 +110,13 @@ static int parse_opt(int argc, char * const argv[])
>  			break;
> 
>  		case 'h':
> -			fprintf(stderr, "%s\n\n", doc);
> -			fprintf(stderr, "%s\n\n", usage);
> -			fprintf(stderr, "%s\n", optionsstr);
> +			printf("%s\n\n", doc);
> +			printf("%s\n\n", usage);
> +			printf("%s\n", optionsstr);

Why not use fprintf(stdout ...), instead of printf()? to be consistent with was is existing?

>  			exit(EXIT_SUCCESS);
> 
>  		case 'V':
> -			fprintf(stderr, "%s\n", PROGRAM_VERSION);
> +			printf("%s\n", PROGRAM_VERSION);
>  			exit(EXIT_SUCCESS);
> 
>  		case ':':
Mike Frysinger June 7, 2011, 3 p.m. UTC | #3
On Tue, Jun 7, 2011 at 02:36, Artem Bityutskiy wrote:
> On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
>> Usage/version information should go to stdout when it is expected behavior
>> (i.e. the user requested it explicitly).  This info should go to stderr
>> only when the usage info is being shown as a result of incorrect options.
>
> This is fine, but all other ubi utils need this change then as well. I
> think this piece of code was copypasted in all ubi-utils, so you should
> easily find it and change.

you just like making me work :p
-mike
Artem Bityutskiy June 8, 2011, 11:10 a.m. UTC | #4
On Tue, 2011-06-07 at 11:00 -0400, Mike Frysinger wrote:
> On Tue, Jun 7, 2011 at 02:36, Artem Bityutskiy wrote:
> > On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
> >> Usage/version information should go to stdout when it is expected behavior
> >> (i.e. the user requested it explicitly).  This info should go to stderr
> >> only when the usage info is being shown as a result of incorrect options.
> >
> > This is fine, but all other ubi utils need this change then as well. I
> > think this piece of code was copypasted in all ubi-utils, so you should
> > easily find it and change.
> 
> you just like making me work :p

It is difficult to not like this - you are doing very good job! :-)
diff mbox

Patch

diff --git a/ubi-utils/src/mtdinfo.c b/ubi-utils/src/mtdinfo.c
index c9f6f58..f20fe49 100644
--- a/ubi-utils/src/mtdinfo.c
+++ b/ubi-utils/src/mtdinfo.c
@@ -110,13 +110,13 @@  static int parse_opt(int argc, char * const argv[])
 			break;
 
 		case 'h':
-			fprintf(stderr, "%s\n\n", doc);
-			fprintf(stderr, "%s\n\n", usage);
-			fprintf(stderr, "%s\n", optionsstr);
+			printf("%s\n\n", doc);
+			printf("%s\n\n", usage);
+			printf("%s\n", optionsstr);
 			exit(EXIT_SUCCESS);
 
 		case 'V':
-			fprintf(stderr, "%s\n", PROGRAM_VERSION);
+			printf("%s\n", PROGRAM_VERSION);
 			exit(EXIT_SUCCESS);
 
 		case ':':