From: "Jastrzebski, MichalX K" <michalx.k.jastrzebski@intel.com>
To: Thomas Monjalon <thomas.monjalon@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"Richardson, Bruce" <bruce.richardson@intel.com>,
"Kobylinski, MichalX" <michalx.kobylinski@intel.com>,
"Gonzalez Monroy, Sergio" <sergio.gonzalez.monroy@intel.com>,
"david.marchand@6wind.com" <david.marchand@6wind.com>
Subject: Re: [dpdk-dev] [PATCH] eal: fix check number of bytes from read function
Date: Thu, 21 Jul 2016 20:50:41 +0000 [thread overview]
Message-ID: <60ABE07DBB3A454EB7FAD707B4BB158213AB97E7@irsmsx110.ger.corp.intel.com> (raw)
In-Reply-To: <1862165.0hl8WtbyGd@xps13>
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Thursday, July 21, 2016 4:36 PM
> To: Jastrzebski, MichalX K <michalx.k.jastrzebski@intel.com>
> Cc: dev@dpdk.org; Richardson, Bruce <bruce.richardson@intel.com>;
> Kobylinski, MichalX <michalx.kobylinski@intel.com>; Gonzalez Monroy,
> Sergio <sergio.gonzalez.monroy@intel.com>; david.marchand@6wind.com
> Subject: Re: [dpdk-dev] [PATCH] eal: fix check number of bytes from read
> function
>
> Hi,
>
> 2016-07-20 16:24, Michal Jastrzebski:
> > - if (read(fd, &page, sizeof(uint64_t)) < 0) {
> > +
> > + retval = read(fd, &page, sizeof(uint64_t));
> > + if (retval < 0) {
> > RTE_LOG(ERR, EAL, "%s(): cannot read /proc/self/pagemap:
> %s\n",
> > __func__, strerror(errno));
> > close(fd);
> > return RTE_BAD_PHYS_ADDR;
> > + } else if (retval >= 0 && retval < (int)sizeof(uint64_t)) {
>
Hi Thomas,
> I have 4 comments about the above line:
That's too much for one line. I should improve next time:)
> - the check retval >= 0 is not needed because implied by else
> - why not checking retval != sizeof(uint64_t) as it is the exact expected
> value?
Yes, it is better solution,
> - (int)sizeof(uint64_t) can be replaced by 8 but it's shorter ;)
I didn't want to change all invokes of read() function here.
I can use some macro:
#define PFN_MASK_SIZE 8
How do You think?
> - only 1 space is required between } and else
>
> > + RTE_LOG(ERR, EAL, "%s(): read %d bytes from
> /proc/self/pagemap "
> > + "but expected %d: %s\n",
> > + __func__, retval, (int)sizeof(uint64_t),
> strerror(errno));
>
> Are you sure errno is meaningful here?
I think it is not. Will send v2.
>
> > + close(fd);
> > + return RTE_BAD_PHYS_ADDR;
> > }
Thanks for a review
Michal.
next prev parent reply other threads:[~2016-07-21 20:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-20 14:24 Michal Jastrzebski
2016-07-21 14:35 ` Thomas Monjalon
2016-07-21 20:50 ` Jastrzebski, MichalX K [this message]
2016-07-21 23:09 ` Thomas Monjalon
2016-07-21 14:37 ` Sergio Gonzalez Monroy
2016-07-22 14:38 ` Jastrzebski, MichalX K
2016-07-22 14:33 ` [dpdk-dev] [PATCH v2] " Michal Jastrzebski
2016-07-22 15:24 ` Thomas Monjalon
2016-07-22 16:02 ` Sergio Gonzalez Monroy
2016-07-22 16:22 ` Thomas Monjalon
2016-07-22 16:23 ` Jastrzebski, MichalX K
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=60ABE07DBB3A454EB7FAD707B4BB158213AB97E7@irsmsx110.ger.corp.intel.com \
--to=michalx.k.jastrzebski@intel.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@6wind.com \
--cc=dev@dpdk.org \
--cc=michalx.kobylinski@intel.com \
--cc=sergio.gonzalez.monroy@intel.com \
--cc=thomas.monjalon@6wind.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 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).