diff --git a/bcm/bcm.c b/bcm/bcm.c
index 805c154cd1dda0e673b109fcad3df798c80a0a94..4133430c7d089f3a2220a77a5cbc987c482c59e4 100644
--- a/bcm/bcm.c
+++ b/bcm/bcm.c
@@ -4,6 +4,7 @@
* Copyright (C) 2018 iopsys Software Solutions AB. All rights reserved.
*
* Author: anjan.chanda@iopsys.eu
+ * oussama.ghorbel@iopsys.eu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -225,10 +226,10 @@ static int bcm_eth_get_stats_from_proc(const char *ifname, struct eth_stats *s)
unsigned long rx_fifo, rx_frame, rx_comp, rx_multi;
unsigned long tx_bytes, tx_packets, tx_err, tx_drop;
unsigned long tx_fifo, tx_coll, tx_carr, tx_comp;
- unsigned long tx_mcast_packets, rx_mcast_bytes, tx_mcast_bytes;
- unsigned long rx_ucast_packets, tx_ucast_packets;
- unsigned long rx_bcast_packets, tx_bcast_packets;
- unsigned long rx_err_unknown;
+ unsigned long tx_mcast_packets = 0, rx_mcast_bytes = 0, tx_mcast_bytes = 0;
+ unsigned long rx_ucast_packets = 0, tx_ucast_packets = 0;
+ unsigned long rx_bcast_packets = 0, tx_bcast_packets = 0;
+ unsigned long rx_err_unknown = 0;
char cmdbuf[512] = {0};
char *ptr;
int ret;
@@ -253,7 +254,7 @@ static int bcm_eth_get_stats_from_proc(const char *ifname, struct eth_stats *s)
&rx_bcast_packets, &tx_bcast_packets,
&rx_err_unknown);
- if (ret != 12)
+ if (ret < 16)
return -1;
s->tx_bytes = tx_bytes;
@@ -262,14 +263,14 @@ static int bcm_eth_get_stats_from_proc(const char *ifname, struct eth_stats *s)
s->rx_packets = rx_packets;
s->tx_errors = tx_err;
s->rx_errors = rx_err;
+ s->tx_discard_packets = tx_drop;
+ s->rx_discard_packets = rx_drop;
s->tx_ucast_packets = tx_ucast_packets;
s->rx_ucast_packets = rx_ucast_packets;
s->tx_mcast_packets = tx_mcast_packets;
s->rx_mcast_packets = INVALID_UINT32; /* 'rx_mcast_bytes' available */
s->tx_bcast_packets = tx_bcast_packets;
s->rx_bcast_packets = rx_bcast_packets;
- s->tx_discard_packets = tx_drop;
- s->rx_discard_packets = rx_drop;
s->rx_unknown_packets = rx_err_unknown;
return 0;
diff --git a/ethernet.c b/ethernet.c
index 6650810397d95ed654fdca305963bc1caed5503d..8e151f714ea39b17ebe2781eec08013bfd34779e 100644
--- a/ethernet.c
+++ b/ethernet.c
@@ -55,10 +55,11 @@ const struct eth_ops *get_eth_driver(const char *ifname)
{
int i;
- for (i = 0; i < sizeof(eth_ops)/sizeof(eth_ops[0]); i++)
+ for (i = 0; i < sizeof(eth_ops)/sizeof(eth_ops[0]); i++) {
if (!strncmp(eth_ops[i]->ifname, ifname,
strlen(eth_ops[i]->ifname)))
return eth_ops[i];
+ }
return NULL;
}