[4/4] net/tap: fix warning about comparison of fd

Message ID 20181106193005.5383-5-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series Coverity issue fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Stephen Hemminger Nov. 6, 2018, 7:30 p.m. UTC
  Static analysis tools don't like the fact that fd could be zero
in the error path. This won't happen in real world because
stdin would have to be closed, then other error occurring.

Coverity issue: 14079
Fixes: 02f96a0a82d1 ("net/tap: add TUN/TAP device PMD")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/tap/rte_eth_tap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Wiles, Keith Nov. 7, 2018, 10:03 a.m. UTC | #1
> On Nov 6, 2018, at 7:30 PM, Stephen Hemminger <stephen@networkplumber.org> wrote:
> 
> Static analysis tools don't like the fact that fd could be zero
> in the error path. This won't happen in real world because
> stdin would have to be closed, then other error occurring.

Acked-by: Keith Wiles <keith.wiles@intel.com>
> 
> Coverity issue: 14079
> Fixes: 02f96a0a82d1 ("net/tap: add TUN/TAP device PMD")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> drivers/net/tap/rte_eth_tap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 84aaf241019a..f7087222b319 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -231,7 +231,7 @@ tun_alloc(struct pmd_internals *pmd, int is_keepalive)
> 	return fd;
> 
> error:
> -	if (fd > 0)
> +	if (fd >= 0)
> 		close(fd);
> 	return -1;
> }
> -- 
> 2.17.1
> 

Regards,
Keith
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 84aaf241019a..f7087222b319 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -231,7 +231,7 @@  tun_alloc(struct pmd_internals *pmd, int is_keepalive)
 	return fd;
 
 error:
-	if (fd > 0)
+	if (fd >= 0)
 		close(fd);
 	return -1;
 }