From fb6834e875a0199a9f0d75b82273b6dcbc5d9f3e Mon Sep 17 00:00:00 2001
From: Maxim Menshikov <maxim.menshikov@iopsys.eu>
Date: Tue, 26 Jul 2022 12:05:44 +0300
Subject: [PATCH] libethernet/generic: fix static analysis errors

---
 ethernet.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/ethernet.c b/ethernet.c
index a69748c..451aa92 100644
--- a/ethernet.c
+++ b/ethernet.c
@@ -38,11 +38,11 @@
 
 #include "ethernet.h"
 
-#ifdef IOPSYS_BROADCOM
+#if defined(IOPSYS_BROADCOM)
 extern const struct eth_ops bcm_eth_ops;
-#elif IOPSYS_TEST
+#elif defined(IOPSYS_TEST)
 extern const struct eth_ops test_eth_ops;
-#elif IOPSYS_ECONET
+#elif defined(IOPSYS_ECONET)
 extern const struct eth_ops econet_gen_eth_ops;
 extern const struct eth_ops econet_nas_wan_eth_ops;
 extern const struct eth_ops econet_ae_wan_eth_ops;
@@ -51,11 +51,11 @@ extern const struct eth_ops ethsw_ops;
 #endif
 
 const struct eth_ops *eth_ops[] = {
-#ifdef IOPSYS_BROADCOM
+#if defined(IOPSYS_BROADCOM)
 	&bcm_eth_ops,
-#elif IOPSYS_TEST
+#elif defined(IOPSYS_TEST)
 	&test_eth_ops,
-#elif IOPSYS_ECONET
+#elif defined(IOPSYS_ECONET)
 	&econet_gen_eth_ops,
 	&econet_nas_wan_eth_ops,
 	&econet_ae_wan_eth_ops,
@@ -244,7 +244,7 @@ int eth_mii_get_phy_id(const char *ifname, int port, int *phy_id)
 
 	mii = if_mii(&ifr);
 	memset(mii, 0, sizeof(struct mii_ioctl_data));
-	mii->val_in = port;
+	mii->val_in = (uint16_t)port;
 
 	if (ioctl(s, SIOCGMIIPHY, &ifr) < 0) {
 		libethernet_err("SIOCGMIIPHY failed!\n");
@@ -283,9 +283,9 @@ static int eth_mii_ioctl(const char *ifname, int cmd, int phy_id, int reg,
 	memset(mii, 0, sizeof(struct mii_ioctl_data));
 
 	//PHYID_2_MII_IOCTL(phy_id, mii);
-	mii->phy_id = phy_id;
-	mii->reg_num = reg;
-	mii->val_in = in;
+	mii->phy_id = (uint16_t)phy_id;
+	mii->reg_num = (uint16_t)reg;
+	mii->val_in = (uint16_t)in;
 
 	if (ioctl(s, cmd, &ifr) < 0) {
 		libethernet_err("MII cmd on %s failed\n", ifr.ifr_name);
-- 
GitLab