eal/linuxapp: fix return value check of mknod()
PATCH 1/1 eal/linuxapp: fix return value check of mknod()
From: Wei Dai <[email protected]>
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().
--- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1 -1
@@ -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 ;
Signature · 1 line
2.5.5
PATCH v2 1/1 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().
---
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(-)
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1 -1
@@ -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 ;
Signature · 1 line
2.5.5
Hi Wei,
Quoted 25 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Dai
Sent: Wednesday, November 16, 2016 10:41 AM
To: [email protected]; Burakov, Anatoly; [email protected]; Dai, Wei
Subject: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check ofmknod()In function
pci_mknod_uio_dev()inlib/librte_eal/eal/eal_pci_uio.c, The return value ofmknod()is ret, not f got byfopen().
So the value of ret should be checked formknod().Fixes 67c536bdad93 ("pci: move uio mapping in a dedicated file")Signed-off-by Wei Dai <[email protected]>---
fix my local git setting and send same patch again to make merging easierlib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/linuxapp/eal/eal_pci_uio.c +0
-0
lib/librte_eal/linuxapp/eal/eal_pci_uio.c pci_mknod_uio_dev(const char *sysfs_uio_path, · line 137
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1
-1@@ -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)
Hi Wenzhuo,
Quoted 21 lines · Wenzhuo
Hi Wei,
Quoted 19 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Dai
Sent: Wednesday, November 16, 2016 10:41 AM
To: [email protected]; Burakov, Anatoly; [email protected]; Dai, Wei
Subject: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check ofmknod()In function
pci_mknod_uio_dev()inlib/librte_eal/eal/eal_pci_uio.c, The return value ofmknod()is ret, not f got byfopen().
So the value of ret should be checked formknod().Fixes 67c536bdad93 ("pci: move uio mapping in a dedicated file")Signed-off-by Wei Dai <[email protected]>---
fix my local git setting and send same patch again to make merging easierlib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
lib/librte_eal/linuxapp/eal/eal_pci_uio.c pci_mknod_uio_dev(const char *sysfs_uio_path, · line 137
Quoted 12 lines
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1
-1@@ -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.
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.
Quoted 68 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Wednesday, November 16, 2016 7:04 PM
To: Lu, Wenzhuo <[email protected]>; Dai, Wei <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check ofmknod()Hi Wenzhuo,
Quoted 24 lines · Wenzhuo
Hi Wei,
Quoted 22 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wei Dai
Sent: Wednesday, November 16, 2016 10:41 AM
To: [email protected]; Burakov, Anatoly; [email protected]; Dai, Wei
Subject: [dpdk-dev] [PATCH v2] eal/linuxapp: fix return value check ofmknod()In function
pci_mknod_uio_dev()inlib/librte_eal/eal/eal_pci_uio.c, The return value ofmknod()is ret, not f got byfopen(). So the value of ret should be checked formknod().Fixes 67c536bdad93 ("pci: move uio mapping in a dedicated file")Signed-off-by Wei Dai <[email protected]>---
fix my local git setting and send same patch again to make merging easierlib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
lib/librte_eal/linuxapp/eal/eal_pci_uio.c pci_mknod_uio_dev(const char *sysfs_uio_path, · line 137
Quoted 12 lines
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1
-1@@ -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.shby "--ignoreCOMPARISON_TO_NULL", so it shouldn't complain.
Hello Wei,
Quoted 5 lines · Wei Dai
In function
pci_mknod_uio_dev()inlib/librte_eal/eal/eal_pci_uio.c, The return value ofmknod()is ret, not f got byfopen(). So the value of ret should be checked formknod().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.
Signature · 1 line
David Marchand
Thanks to David, I will submit v3 patch to indicate correct Fixes.
Quoted 25 lines
-----Original Message-----
From: David Marchand [mailto:[email protected]]
Sent: Wednesday, November 16, 2016 7:24 PM
To: Dai, Wei <[email protected]>
Cc: [email protected]; Burakov, Anatoly <[email protected]>
Subject: Re: [PATCH v2] eal/linuxapp: fix return value check ofmknod()Hello Wei,
Quoted 5 lines · Wei Dai
In function
pci_mknod_uio_dev()inlib/librte_eal/eal/eal_pci_uio.c, The return value ofmknod()is ret, not f got byfopen(). So the value of ret should be checked formknod().Fixes 67c536bdad93 ("pci: move uio mapping in a dedicated file")The commit you are pointing is just moving the code.
I would incriminatef7f97c16048e("pci: add option --create-uio-dev to run without hotplug")The rest looks good to me.
--
David Marchand
PATCH v3 1/1 eal/linuxapp: fix return value check of mknod()
In reply to Wei DaiIn 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().
---
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 <[email protected]>" 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(-)
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1 -1
@@ -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 ;
Signature · 1 line
2.5.5
Hi Wei,
Quoted 8 lines · Wei Dai
In function
pci_mknod_uio_dev()inlib/librte_eal/eal/eal_pci_uio.c, The return value ofmknod()is ret, not f got byfopen(). So the value of ret should be checked formknod().Fixes f7f97c16048e ("pci: add option --create-uio-dev to run withouthotplug")
Signed-off-by Wei Dai <[email protected]>
Thanks
Thomas Monjalon
Applied2016-12-06 11:44, Olivier Matz:
Quoted 9 lines
Hi Wei,
Quoted 6 lines · Wei Dai
In function
pci_mknod_uio_dev()inlib/librte_eal/eal/eal_pci_uio.c, The return value ofmknod()is ret, not f got byfopen(). So the value of ret should be checked formknod().Fixes f7f97c16048e ("pci: add option --create-uio-dev to run withouthotplug")
Quoted 5 lines
Quoted 1 line
Signed-off-by Wei Dai <[email protected]>Acked-by Olivier Matz <[email protected]>Thanks
Applied, thanks