[dpdk-dev,3/6] bsd: remove useless assignments

Message ID 1423925950-5201-3-git-send-email-shemming@brocade.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Stephen Hemminger Feb. 14, 2015, 2:59 p.m. UTC
  If variable is set in the next line, it doesn't need to be
initialized.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/bsdapp/eal/eal.c     | 3 ++-
 lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
  

Comments

Bruce Richardson Feb. 16, 2015, 11:31 a.m. UTC | #1
On Sat, Feb 14, 2015 at 09:59:07AM -0500, Stephen Hemminger wrote:
> If variable is set in the next line, it doesn't need to be
> initialized.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/librte_eal/bsdapp/eal/eal.c     | 3 ++-
>  lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
> index 69f3c03..71ae33c 100644
> --- a/lib/librte_eal/bsdapp/eal/eal.c
> +++ b/lib/librte_eal/bsdapp/eal/eal.c
> @@ -417,7 +417,8 @@ int rte_eal_has_hugepages(void)
>  int
>  rte_eal_iopl_init(void)
>  {
> -	int fd = -1;
> +	int fd;
> +
>  	fd = open("/dev/io", O_RDWR);

Why not just merge the two lines and make it "int fd = open(...);". 

/Bruce
  

Patch

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 69f3c03..71ae33c 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -417,7 +417,8 @@  int rte_eal_has_hugepages(void)
 int
 rte_eal_iopl_init(void)
 {
-	int fd = -1;
+	int fd;
+
 	fd = open("/dev/io", O_RDWR);
 	if (fd < 0)
 		return -1;
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 74ecce7..d191323 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -382,7 +382,7 @@  skipdev:
 static int
 pci_scan(void)
 {
-	int fd = -1;
+	int fd;
 	unsigned dev_count = 0;
 	struct pci_conf matches[16];
 	struct pci_conf_io conf_io = {