Xen-Devel Archive mirror
 help / color / mirror / Atom feed
From: Fouad Hilly <fouad.hilly@cloud.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Anthony PERARD <anthony@xenproject.org>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v3 3/5] x86: Add usage() to print out usage message
Date: Thu, 9 May 2024 14:59:20 +0100	[thread overview]
Message-ID: <CAJKAvHbdcq2yf9Om22HY+CkKvBTrLiApHtEqxzhs5yUZKLAmDw@mail.gmail.com> (raw)
In-Reply-To: <cc1f42bf-7629-41fa-99b5-f77f15a371be@suse.com>

On Mon, May 6, 2024 at 9:20 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 30.04.2024 14:47, Fouad Hilly wrote:
> > Refactor xen-ucode tool by adding usage() to handle usage\help messages.
> > As we add more command options this will keep help\usage messages in a common block.
> > Only generic error message is printed to stderr. usage and show_curr_cpu are printed to stdout.
> >
> > Signed-off-by: Fouad Hilly <fouad.hilly@cloud.com>
> > ---
> > [v3]
> > 1- Reverted usage message.
> > 2- Utilized usage().
> >
> > [v2]
> > 1- Improved message description.
> > 2- Fixed formatting and indentation.
> > 3- Error message to print to stderr.
>
> Already on v2 I pointed out that this change wasn't really done. And now,
> in v3, ...
>
In V4 all printing within ext_err path will be printed to stder

> >  tools/misc/xen-ucode.c | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c
> > index c6ae6498d659..005bf85b6551 100644
> > --- a/tools/misc/xen-ucode.c
> > +++ b/tools/misc/xen-ucode.c
> > @@ -17,6 +17,13 @@ static xc_interface *xch;
> >  static const char intel_id[] = "GenuineIntel";
> >  static const char   amd_id[] = "AuthenticAMD";
> >
> > +static void usage(const char *name)
> > +{
> > +    printf("%s: Xen microcode updating tool\n"
> > +           "Usage: %s [<microcode file> | show-cpu-info]\n",
> > +           name, name);
> > +}
>
> ... you're still unconditionally printing to stdout, when ...
>
> >  static void show_curr_cpu(FILE *f)
> >  {
> >      int ret;
> > @@ -89,9 +96,8 @@ int main(int argc, char *argv[])
> >      if ( argc < 2 )
> >      {
> >          fprintf(stderr,
> > -                "xen-ucode: Xen microcode updating tool\n"
> > -                "Usage: %s [<microcode file> | show-cpu-info]\n", argv[0]);
> > -        show_curr_cpu(stderr);
> > +                "%s: unable to process command line arguments\n", argv[0]);
> > +        usage(argv[0]);
> >          exit(2);
> >      }
>
> ... originally the usage message (correctly) went to stderr in this case.
> It ought to go to stdout only in response to something like a --help
> command line option.
>
> Jan


  reply	other threads:[~2024-05-09 14:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 12:47 [PATCH v3 0/5] x86/xen-ucode: Introduce --force option Fouad Hilly
2024-04-30 12:47 ` [PATCH v3 1/5] x86: Update x86 low level version check of microcode Fouad Hilly
2024-05-06  8:45   ` Jan Beulich
2024-05-09 14:33     ` Fouad Hilly
2024-04-30 12:47 ` [PATCH v3 2/5] x86: Refactor microcode_update() hypercall with flags Fouad Hilly
2024-05-06  9:14   ` Jan Beulich
2024-05-09 14:15     ` Fouad Hilly
2024-04-30 12:47 ` [PATCH v3 3/5] x86: Add usage() to print out usage message Fouad Hilly
2024-05-06  8:20   ` Jan Beulich
2024-05-09 13:59     ` Fouad Hilly [this message]
2024-04-30 12:47 ` [PATCH v3 4/5] x86: Use getopt to handle command line args Fouad Hilly
2024-05-06  8:21   ` Jan Beulich
2024-05-09 13:59     ` Fouad Hilly
2024-04-30 12:47 ` [PATCH v3 5/5] Add --force option to xen-ucode to override microcode version check Fouad Hilly
2024-05-06  9:39   ` Jan Beulich
2024-05-09 14:31     ` Fouad Hilly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJKAvHbdcq2yf9Om22HY+CkKvBTrLiApHtEqxzhs5yUZKLAmDw@mail.gmail.com \
    --to=fouad.hilly@cloud.com \
    --cc=anthony@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).