All of lore.kernel.org
 help / color / mirror / Atom feed
From: skunberg.kelsey at gmail.com (Kelsey Skunberg)
Subject: [Linux-kernel-mentees] [PATCH v2 2/3] lspci: Remove unnecessary !verbose check in show_range()
Date: Thu, 16 May 2019 15:26:16 -0600	[thread overview]
Message-ID: <20190516212615.GA4369@asus> (raw)
In-Reply-To: <CABhMZUWviq7O7f3eaDk45JKYUz+Gg_4TdtTkx3HC5WgLWh5Umg@mail.gmail.com>

On Thu, May 16, 2019 at 07:58:37AM -0500, Bjorn Helgaas wrote:
> On Sat, May 11, 2019 at 6:05 PM Kelsey Skunberg
> <skunberg.kelsey at gmail.com> wrote:
> >
> > Remove 'if (!verbose)' code in show_range() due to not being called.
> > show_range() will only be called when verbose is true. Additional call
> > to check for verbosity within show_range() is dead code.
> >
> > !verbose was used so nothing would print if the range behind a bridge
> > had a base > limit and verbose == false. Since show_range() will not be
> > called when verbose == false, not printing bridge information is
> > still accomplished.
> >
> > Signed-off-by: Kelsey Skunberg <skunberg.kelsey at gmail.com>
> > ---
> >  lspci.c | 12 +++---------
> >  1 file changed, 3 insertions(+), 9 deletions(-)
> >
> > diff --git a/lspci.c b/lspci.c
> > index 937c6e4..419f386 100644
> > --- a/lspci.c
> > +++ b/lspci.c
> > @@ -376,17 +376,11 @@ show_size(u64 x)
> >  static void
> >  show_range(char *prefix, u64 base, u64 limit, int is_64bit)
> >  {
> > -  if (base > limit)
> > +  if (base > limit || verbose < 3)
> >      {
> > -      if (!verbose)
> > -       return;
> > -      else if (verbose < 3)
> > -       {
> > -         printf("%s: None\n", prefix);
> > -         return;
> > -       }
> 
> I don't think this works quite right.  The resulting code is:
> 
>   if (base > limit || verbose < 3) {
>     printf("%s: None\n", prefix);
>     return;
>   }
> 
> but that means we print "None" when the window is *enabled* (base <=
> limit) and verbose < 3.  We should print the window in that case.
> 
> > +      printf("%s: None\n", prefix);
> > +      return;
> >      }
> > -
> >    printf("%s: ", prefix);
> >    if (is_64bit)
> >      printf("%016" PCI_U64_FMT_X "-%016" PCI_U64_FMT_X, base, limit);
> > --
> > 2.20.1
> >

You're absolutely right and I should have caught this. Revised and v3
sumbitted. Thank you for reviewing and letting me know.

WARNING: multiple messages have this Message-ID (diff)
From: skunberg.kelsey@gmail.com (Kelsey Skunberg)
Subject: [Linux-kernel-mentees] [PATCH v2 2/3] lspci: Remove unnecessary !verbose check in show_range()
Date: Thu, 16 May 2019 15:26:16 -0600	[thread overview]
Message-ID: <20190516212615.GA4369@asus> (raw)
Message-ID: <20190516212616.JZ7qjCC6hRRlPS9GEDroXTTO-hVdr-loQ6OgXaJRlsY@z> (raw)
In-Reply-To: <CABhMZUWviq7O7f3eaDk45JKYUz+Gg_4TdtTkx3HC5WgLWh5Umg@mail.gmail.com>

On Thu, May 16, 2019 at 07:58:37AM -0500, Bjorn Helgaas wrote:
> On Sat, May 11, 2019 at 6:05 PM Kelsey Skunberg
> <skunberg.kelsey at gmail.com> wrote:
> >
> > Remove 'if (!verbose)' code in show_range() due to not being called.
> > show_range() will only be called when verbose is true. Additional call
> > to check for verbosity within show_range() is dead code.
> >
> > !verbose was used so nothing would print if the range behind a bridge
> > had a base > limit and verbose == false. Since show_range() will not be
> > called when verbose == false, not printing bridge information is
> > still accomplished.
> >
> > Signed-off-by: Kelsey Skunberg <skunberg.kelsey at gmail.com>
> > ---
> >  lspci.c | 12 +++---------
> >  1 file changed, 3 insertions(+), 9 deletions(-)
> >
> > diff --git a/lspci.c b/lspci.c
> > index 937c6e4..419f386 100644
> > --- a/lspci.c
> > +++ b/lspci.c
> > @@ -376,17 +376,11 @@ show_size(u64 x)
> >  static void
> >  show_range(char *prefix, u64 base, u64 limit, int is_64bit)
> >  {
> > -  if (base > limit)
> > +  if (base > limit || verbose < 3)
> >      {
> > -      if (!verbose)
> > -       return;
> > -      else if (verbose < 3)
> > -       {
> > -         printf("%s: None\n", prefix);
> > -         return;
> > -       }
> 
> I don't think this works quite right.  The resulting code is:
> 
>   if (base > limit || verbose < 3) {
>     printf("%s: None\n", prefix);
>     return;
>   }
> 
> but that means we print "None" when the window is *enabled* (base <=
> limit) and verbose < 3.  We should print the window in that case.
> 
> > +      printf("%s: None\n", prefix);
> > +      return;
> >      }
> > -
> >    printf("%s: ", prefix);
> >    if (is_64bit)
> >      printf("%016" PCI_U64_FMT_X "-%016" PCI_U64_FMT_X, base, limit);
> > --
> > 2.20.1
> >

You're absolutely right and I should have caught this. Revised and v3
sumbitted. Thank you for reviewing and letting me know.

  reply	other threads:[~2019-05-16 21:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-11 23:03 [Linux-kernel-mentees] [PATCH v2 0/3] lspci: Update verbose help and show_range() skunberg.kelsey
2019-05-11 23:03 ` Kelsey Skunberg
2019-05-11 23:03 ` [Linux-kernel-mentees] [PATCH v2 1/3] lspci: Include -vvv option in help skunberg.kelsey
2019-05-11 23:03   ` Kelsey Skunberg
2019-05-16 12:51   ` bjorn.helgaas
2019-05-16 12:51     ` Bjorn Helgaas
2019-05-11 23:03 ` [Linux-kernel-mentees] [PATCH v2 2/3] lspci: Remove unnecessary !verbose check in show_range() skunberg.kelsey
2019-05-11 23:03   ` Kelsey Skunberg
2019-05-16 12:58   ` bjorn.helgaas
2019-05-16 12:58     ` Bjorn Helgaas
2019-05-16 21:26     ` skunberg.kelsey [this message]
2019-05-16 21:26       ` Kelsey Skunberg
2019-05-11 23:03 ` [Linux-kernel-mentees] [PATCH v2 3/3] lspci: Replace output for bridge with empty range from 'None' to '[empty]' skunberg.kelsey
2019-05-11 23:03   ` Kelsey Skunberg
2019-05-16 21:23 ` [Linux-kernel-mentees] [PATCH v3 0/3] Update verbose help and show_range() skunberg.kelsey
2019-05-16 21:23   ` Kelsey Skunberg
2019-05-16 21:23   ` [Linux-kernel-mentees] [PATCH v3 1/3] lspci: Include -vvv option in help skunberg.kelsey
2019-05-16 21:23     ` Kelsey Skunberg
2019-05-16 21:23   ` [Linux-kernel-mentees] [PATCH v3 2/3] lspci: Remove unnecessary !verbose check in show_range() skunberg.kelsey
2019-05-16 21:23     ` Kelsey Skunberg
2019-05-16 21:23   ` [Linux-kernel-mentees] [PATCH v3 3/3] lspci: Replace output for bridge with empty range from 'None' to '[empty]' skunberg.kelsey
2019-05-16 21:23     ` Kelsey Skunberg
2019-06-11 20:25     ` bjorn.helgaas
2019-06-11 20:25       ` Bjorn Helgaas
2019-06-17 22:29       ` skunberg.kelsey
2019-06-17 22:29         ` Kelsey Skunberg
2019-06-17 22:56         ` bjorn.helgaas
2019-06-17 22:56           ` Bjorn Helgaas

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=20190516212615.GA4369@asus \
    --to=unknown@example.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.