DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>
Cc: dev@dpdk.org, sarosh.arif@emumba.com, stephen@networkplumber.org
Subject: Re: [dpdk-dev] [PATCH] usertools: check 0-division with hugepage size
Date: Fri, 12 Feb 2021 12:34:53 +0100	[thread overview]
Message-ID: <6402439.QoXlHTGXZI@thomas> (raw)
In-Reply-To: <ef1d1777-a680-a5bb-dcc0-0c1a6035b584@intel.com>

12/02/2021 12:27, Burakov, Anatoly:
> On 11-Feb-21 10:05 PM, Thomas Monjalon wrote:
> > The default page size can be None, and the page size from user request
> > can be 0 kB if lower than 1024. In these cases, a division will fail.
> > In order to avoid a Python exception, the page size is checked
> > and an error message "Invalid page size" is printed.
> > 
> > A similar error message is printed in set_hugepages()
> > if the size is not supported, except at this stage the message can be
> > completed with "Valid page sizes".
> > Unfortunately the first check is too early to print such information.
> > 
> > A third error message can be printed in a different place (get_memsize)
> > in case of a format issue, e.g. a negative size.
> > The function get_memsize() is also used for total requested size,
> > so the error message "not a valid page size" was potentially wrong.
> > This message is replaced with the more general "is not a valid size".
> > 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> > @@ -254,6 +254,8 @@ def main():
> >           pagesize_kb = get_memsize(args.pagesize)
> >       else:
> >           pagesize_kb = default_pagesize()
> > +    if pagesize_kb is None or pagesize_kb == 0:
> > +        sys.exit("Invalid page size: {}kB".format(pagesize_kb))
> 
> Both None and 0 evaluate to False for boolean comparisons, so you can 
> replace it with:
> 
> if not pagesize_kb:
>     sys.exit(...)

Oh yes better :)



  reply	other threads:[~2021-02-12 11:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11 22:05 Thomas Monjalon
2021-02-11 23:18 ` Stephen Hemminger
2021-02-12 11:27 ` Burakov, Anatoly
2021-02-12 11:34   ` Thomas Monjalon [this message]
2021-03-21  9:09 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2021-03-23 11:30   ` Burakov, Anatoly
2021-03-25 17:04     ` Thomas Monjalon

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=6402439.QoXlHTGXZI@thomas \
    --to=thomas@monjalon.net \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=sarosh.arif@emumba.com \
    --cc=stephen@networkplumber.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 NNTP newsgroup(s).