DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal/linuxapp: fix return value check of mknod()
@ 2016-11-16  2:12 Zhiyong Yang
  2016-11-16  2:40 ` [dpdk-dev] [PATCH v2] " Wei Dai
  0 siblings, 1 reply; 10+ messages in thread
From: Zhiyong Yang @ 2016-11-16  2:12 UTC (permalink / raw)
  To: dev, anatoly.burakov, david.marchand; +Cc: Wei Dai

From: Wei Dai <wei.dai@intel.com>

In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
The return value of mknod() is ret, not f got by fopen().
So the value of ret should be checked for mknod().

Fixes: 67c536bdad93 ("pci: move uio mapping in a dedicated file")

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index 1786b75..3e4ffb5 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -133,7 +133,7 @@ pci_mknod_uio_dev(const char *sysfs_uio_path, unsigned uio_num)
 	snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num);
 	dev = makedev(major, minor);
 	ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev);
-	if (f == NULL) {
+	if (ret != 0) {
 		RTE_LOG(ERR, EAL, "%s(): mknod() failed %s\n",
 			__func__, strerror(errno));
 		return -1;
-- 
2.5.5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of mknod()
  2016-11-16  2:12 [dpdk-dev] [PATCH] eal/linuxapp: fix return value check of mknod() Zhiyong Yang
@ 2016-11-16  2:40 ` Wei Dai
  2016-11-16  3:28   ` Lu, Wenzhuo
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Wei Dai @ 2016-11-16  2:40 UTC (permalink / raw)
  To: dev, anatoly.burakov, david.marchand, wei.dai

In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
The return value of mknod() is ret, not f got by fopen().
So the value of ret should be checked for mknod().

Fixes: 67c536bdad93 ("pci: move uio mapping in a dedicated file")

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
fix my local git setting and send same patch again to
make merging easier

 lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index 1786b75..3e4ffb5 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -133,7 +133,7 @@ pci_mknod_uio_dev(const char *sysfs_uio_path, unsigned uio_num)
 	snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num);
 	dev = makedev(major, minor);
 	ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev);
-	if (f == NULL) {
+	if (ret != 0) {
 		RTE_LOG(ERR, EAL, "%s(): mknod() failed %s\n",
 			__func__, strerror(errno));
 		return -1;
-- 
2.5.5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of mknod()
  2016-11-16  2:40 ` [dpdk-dev] [PATCH v2] " Wei Dai
@ 2016-11-16  3:28   ` Lu, Wenzhuo
  2016-11-16 11:04     ` Ferruh Yigit
  2016-11-16 11:23   ` David Marchand
  2016-11-17  6:47   ` [dpdk-dev] [PATCH v3] " Wei Dai
  2 siblings, 1 reply; 10+ messages in thread
From: Lu, Wenzhuo @ 2016-11-16  3:28 UTC (permalink / raw)
  To: Dai, Wei, dev, Burakov, Anatoly, david.marchand, Dai, Wei

Hi Wei,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Dai
> Sent: Wednesday, November 16, 2016 10:41 AM
> To: dev@dpdk.org; Burakov, Anatoly; david.marchand@6wind.com; Dai, Wei
> Subject: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of mknod()
> 
> In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c, The return
> value of mknod() is ret, not f got by fopen().
> So the value of ret should be checked for mknod().
> 
> Fixes: 67c536bdad93 ("pci: move uio mapping in a dedicated file")
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> ---
> fix my local git setting and send same patch again to make merging easier
> 
>  lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> index 1786b75..3e4ffb5 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> @@ -133,7 +133,7 @@ pci_mknod_uio_dev(const char *sysfs_uio_path,
> unsigned uio_num)
>  	snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num);
>  	dev = makedev(major, minor);
>  	ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev);
> -	if (f == NULL) {
> +	if (ret != 0) {
I think checkpatch will suggest to just use if (ret)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of mknod()
  2016-11-16  3:28   ` Lu, Wenzhuo
@ 2016-11-16 11:04     ` Ferruh Yigit
  2016-11-16 15:17       ` Dai, Wei
  0 siblings, 1 reply; 10+ messages in thread
From: Ferruh Yigit @ 2016-11-16 11:04 UTC (permalink / raw)
  To: Lu, Wenzhuo, Dai, Wei, dev, Burakov, Anatoly, david.marchand

Hi Wenzhuo,

On 11/16/2016 3:28 AM, Lu, Wenzhuo wrote:
> Hi Wei,
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Dai
>> Sent: Wednesday, November 16, 2016 10:41 AM
>> To: dev@dpdk.org; Burakov, Anatoly; david.marchand@6wind.com; Dai, Wei
>> Subject: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of mknod()
>>
>> In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c, The return
>> value of mknod() is ret, not f got by fopen().
>> So the value of ret should be checked for mknod().
>>
>> Fixes: 67c536bdad93 ("pci: move uio mapping in a dedicated file")
>>
>> Signed-off-by: Wei Dai <wei.dai@intel.com>
>> ---
>> fix my local git setting and send same patch again to make merging easier
>>
>>  lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
>> b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
>> index 1786b75..3e4ffb5 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
>> @@ -133,7 +133,7 @@ pci_mknod_uio_dev(const char *sysfs_uio_path,
>> unsigned uio_num)
>>  	snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num);
>>  	dev = makedev(major, minor);
>>  	ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev);
>> -	if (f == NULL) {
>> +	if (ret != 0) {
> I think checkpatch will suggest to just use if (ret)

Your are right, default checkpatch.pl complains about this usage (with
--strict option), but:

- According DPDK coding style this usage is preferred (although I
personally prefer kernel one..)

http://dpdk.org/doc/guides/contributing/coding_style.html#null-pointers

"
if (p == NULL) /* Good, compare pointer to NULL */

if (!p) /* Bad, using ! on pointer */
"

- This warning disabled in dpdk scripts/checkpatches.sh by "--ignore
COMPARISON_TO_NULL", so it shouldn't complain.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of mknod()
  2016-11-16  2:40 ` [dpdk-dev] [PATCH v2] " Wei Dai
  2016-11-16  3:28   ` Lu, Wenzhuo
@ 2016-11-16 11:23   ` David Marchand
  2016-11-16 15:18     ` Dai, Wei
  2016-11-17  6:47   ` [dpdk-dev] [PATCH v3] " Wei Dai
  2 siblings, 1 reply; 10+ messages in thread
From: David Marchand @ 2016-11-16 11:23 UTC (permalink / raw)
  To: Wei Dai; +Cc: dev, Burakov, Anatoly

Hello Wei,

On Wed, Nov 16, 2016 at 3:40 AM, Wei Dai <wei.dai@intel.com> wrote:
> In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
> The return value of mknod() is ret, not f got by fopen().
> So the value of ret should be checked for mknod().
>
> Fixes: 67c536bdad93 ("pci: move uio mapping in a dedicated file")

The commit you are pointing is just moving the code.
I would incriminate f7f97c16048e ("pci: add option --create-uio-dev to
run without hotplug")

The rest looks good to me.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of mknod()
  2016-11-16 11:04     ` Ferruh Yigit
@ 2016-11-16 15:17       ` Dai, Wei
  0 siblings, 0 replies; 10+ messages in thread
From: Dai, Wei @ 2016-11-16 15:17 UTC (permalink / raw)
  To: Yigit, Ferruh, Lu, Wenzhuo, dev, Burakov, Anatoly, david.marchand

Thanks to Yigit Ferruh and Wenzhuo for your guide.
Several months ago, I download checkpatch.pl and put it in /root/bin/.
In /root/.bash_profile in my server,  there is line :export DPDK_CHECKPATCH_PATH=/root/bin/checkpatch.pl
Before I send this patch, I have run checkpath.sh to check it and it show no error.
./scripts/checkpatch.sh -v v2-0001-eal-*.patch

By search ' != 0', there are many lines in many modules of DPDK.
So I think ' !=0' is OK.

> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, November 16, 2016 7:04 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Dai, Wei <wei.dai@intel.com>;
> dev@dpdk.org; Burakov, Anatoly <anatoly.burakov@intel.com>;
> david.marchand@6wind.com
> Subject: Re: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of
> mknod()
> 
> Hi Wenzhuo,
> 
> On 11/16/2016 3:28 AM, Lu, Wenzhuo wrote:
> > Hi Wei,
> >
> >> -----Original Message-----
> >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Dai
> >> Sent: Wednesday, November 16, 2016 10:41 AM
> >> To: dev@dpdk.org; Burakov, Anatoly; david.marchand@6wind.com; Dai,
> >> Wei
> >> Subject: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check
> >> of mknod()
> >>
> >> In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
> >> The return value of mknod() is ret, not f got by fopen().
> >> So the value of ret should be checked for mknod().
> >>
> >> Fixes: 67c536bdad93 ("pci: move uio mapping in a dedicated file")
> >>
> >> Signed-off-by: Wei Dai <wei.dai@intel.com>
> >> ---
> >> fix my local git setting and send same patch again to make merging
> >> easier
> >>
> >>  lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> >> b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> >> index 1786b75..3e4ffb5 100644
> >> --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> >> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> >> @@ -133,7 +133,7 @@ pci_mknod_uio_dev(const char *sysfs_uio_path,
> >> unsigned uio_num)
> >>  	snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num);
> >>  	dev = makedev(major, minor);
> >>  	ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev);
> >> -	if (f == NULL) {
> >> +	if (ret != 0) {
> > I think checkpatch will suggest to just use if (ret)
> 
> Your are right, default checkpatch.pl complains about this usage (with --strict
> option), but:
> 
> - According DPDK coding style this usage is preferred (although I personally
> prefer kernel one..)
> 
> http://dpdk.org/doc/guides/contributing/coding_style.html#null-pointers
> 
> "
> if (p == NULL) /* Good, compare pointer to NULL */
> 
> if (!p) /* Bad, using ! on pointer */
> "
> 
> - This warning disabled in dpdk scripts/checkpatches.sh by "--ignore
> COMPARISON_TO_NULL", so it shouldn't complain.
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check of mknod()
  2016-11-16 11:23   ` David Marchand
@ 2016-11-16 15:18     ` Dai, Wei
  0 siblings, 0 replies; 10+ messages in thread
From: Dai, Wei @ 2016-11-16 15:18 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Burakov, Anatoly

Thanks to David, I will submit v3 patch to indicate correct Fixes.

> -----Original Message-----
> From: David Marchand [mailto:david.marchand@6wind.com]
> Sent: Wednesday, November 16, 2016 7:24 PM
> To: Dai, Wei <wei.dai@intel.com>
> Cc: dev@dpdk.org; Burakov, Anatoly <anatoly.burakov@intel.com>
> Subject: Re: [PATCH v2] eal/linuxapp: fix return value check of mknod()
> 
> Hello Wei,
> 
> On Wed, Nov 16, 2016 at 3:40 AM, Wei Dai <wei.dai@intel.com> wrote:
> > In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
> > The return value of mknod() is ret, not f got by fopen().
> > So the value of ret should be checked for mknod().
> >
> > Fixes: 67c536bdad93 ("pci: move uio mapping in a dedicated file")
> 
> The commit you are pointing is just moving the code.
> I would incriminate f7f97c16048e ("pci: add option --create-uio-dev to run
> without hotplug")
> 
> The rest looks good to me.
> 
> 
> --
> David Marchand

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v3] eal/linuxapp: fix return value check of mknod()
  2016-11-16  2:40 ` [dpdk-dev] [PATCH v2] " Wei Dai
  2016-11-16  3:28   ` Lu, Wenzhuo
  2016-11-16 11:23   ` David Marchand
@ 2016-11-17  6:47   ` Wei Dai
  2016-12-06 10:44     ` Olivier Matz
  2 siblings, 1 reply; 10+ messages in thread
From: Wei Dai @ 2016-11-17  6:47 UTC (permalink / raw)
  To: david.marchand, olivier.matz; +Cc: dev, Wei Dai

In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
The return value of mknod() is ret, not f got by fopen().
So the value of ret should be checked for mknod().

Fixes: f7f97c16048e ("pci: add option --create-uio-dev to run without hotplug")

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
v3:
* correct Fixes: line in git commit message body

v2:
* fix my local git setting and send same patch again to remove
  "From: Wei Dai <wei.dai@intel.com>" in git commit message body
  and make merging easier

 lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index 1786b75..3e4ffb5 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -133,7 +133,7 @@ pci_mknod_uio_dev(const char *sysfs_uio_path, unsigned uio_num)
 	snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num);
 	dev = makedev(major, minor);
 	ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev);
-	if (f == NULL) {
+	if (ret != 0) {
 		RTE_LOG(ERR, EAL, "%s(): mknod() failed %s\n",
 			__func__, strerror(errno));
 		return -1;
-- 
2.5.5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v3] eal/linuxapp: fix return value check of mknod()
  2016-11-17  6:47   ` [dpdk-dev] [PATCH v3] " Wei Dai
@ 2016-12-06 10:44     ` Olivier Matz
  2016-12-06 11:01       ` Thomas Monjalon
  0 siblings, 1 reply; 10+ messages in thread
From: Olivier Matz @ 2016-12-06 10:44 UTC (permalink / raw)
  To: Wei Dai; +Cc: david.marchand, dev

Hi Wei,

On Thu, 17 Nov 2016 14:47:15 +0800, Wei Dai <wei.dai@intel.com> wrote:
> In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
> The return value of mknod() is ret, not f got by fopen().
> So the value of ret should be checked for mknod().
> 
> Fixes: f7f97c16048e ("pci: add option --create-uio-dev to run without
> hotplug")
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v3] eal/linuxapp: fix return value check of mknod()
  2016-12-06 10:44     ` Olivier Matz
@ 2016-12-06 11:01       ` Thomas Monjalon
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Monjalon @ 2016-12-06 11:01 UTC (permalink / raw)
  To: Wei Dai; +Cc: dev, Olivier Matz, david.marchand, stable

2016-12-06 11:44, Olivier Matz:
> Hi Wei,
> 
> On Thu, 17 Nov 2016 14:47:15 +0800, Wei Dai <wei.dai@intel.com> wrote:
> > In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
> > The return value of mknod() is ret, not f got by fopen().
> > So the value of ret should be checked for mknod().
> > 
> > Fixes: f7f97c16048e ("pci: add option --create-uio-dev to run without
> > hotplug")

CC: stable@dpdk.org

> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> 
> Thanks

Applied, thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-12-06 11:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-16  2:12 [dpdk-dev] [PATCH] eal/linuxapp: fix return value check of mknod() Zhiyong Yang
2016-11-16  2:40 ` [dpdk-dev] [PATCH v2] " Wei Dai
2016-11-16  3:28   ` Lu, Wenzhuo
2016-11-16 11:04     ` Ferruh Yigit
2016-11-16 15:17       ` Dai, Wei
2016-11-16 11:23   ` David Marchand
2016-11-16 15:18     ` Dai, Wei
2016-11-17  6:47   ` [dpdk-dev] [PATCH v3] " Wei Dai
2016-12-06 10:44     ` Olivier Matz
2016-12-06 11:01       ` Thomas Monjalon

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).