From 1cb301cf3b397252e85310c2e368c58c43ab64d5 Mon Sep 17 00:00:00 2001
From: Alexander Babikov <lemondrops358@gmail.com>
Date: Mon, 7 Feb 2022 18:05:58 +0500
Subject: [PATCH] Refactor NIC logging

---
 src/Makefile.local       |  2 +-
 src/network/net_ne2000.c | 15 +++------------
 src/network/net_pcnet.c  |  9 ---------
 src/network/net_wd8003.c |  8 +-------
 src/network/network.c    |  9 +--------
 5 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/src/Makefile.local b/src/Makefile.local
index 16df56b3d..c927037d8 100644
--- a/src/Makefile.local
+++ b/src/Makefile.local
@@ -123,7 +123,7 @@ STUFF	:=
 # -DENABLE_3COM503_LOG=N sets logging level at N.
 # -DENABLE_DP8390_LOG=N sets logging level at N.
 # -DENABLE_NETWORK_LOG=N sets logging level at N.
-# -DENABLE_NIC_LOG=N sets logging level at N.
+# -DENABLE_NE2K_LOG=N sets logging level at N.
 # -DENABLE_PCAP_LOG=N sets logging level at N.
 # -DENABLE_PCNET_LOG=N sets logging level at N.
 # -DENABLE_SLIRP_LOG=N sets logging level at N.
diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c
index db2a08bf1..6878e4f94 100644
--- a/src/network/net_ne2000.c
+++ b/src/network/net_ne2000.c
@@ -124,15 +124,15 @@ typedef struct {
 } nic_t;
 
 
-#ifdef ENABLE_NIC_LOG
-int nic_do_log = ENABLE_NIC_LOG;
+#ifdef ENABLE_NE2K_LOG
+int ne2k_do_log = ENABLE_NE2K_LOG;
 
 static void
 nelog(int lvl, const char *fmt, ...)
 {
     va_list ap;
 
-    if (nic_do_log >= lvl) {
+    if (ne2k_do_log >= lvl) {
 	va_start(ap, fmt);
 	pclog_ex(fmt, ap);
 	va_end(ap);
@@ -920,15 +920,6 @@ nic_init(const device_t *info)
     uint32_t mac;
     char *rom;
     nic_t *dev;
-#ifdef ENABLE_NIC_LOG
-    int i;
-#endif
-
-    /* Get the desired debug level. */
-#ifdef ENABLE_NIC_LOG
-    i = device_get_config_int("debug");
-    if (i > 0) nic_do_log = i;
-#endif
 
     dev = malloc(sizeof(nic_t));
     memset(dev, 0x00, sizeof(nic_t));
diff --git a/src/network/net_pcnet.c b/src/network/net_pcnet.c
index 373299732..441c50f67 100644
--- a/src/network/net_pcnet.c
+++ b/src/network/net_pcnet.c
@@ -2905,18 +2905,9 @@ pcnet_init(const device_t *info)
 {
     uint32_t mac;
     nic_t *dev;
-#ifdef ENABLE_NIC_LOG
-    int i;
-#endif
     int c;
     uint16_t checksum;
 
-    /* Get the desired debug level. */
-#ifdef ENABLE_NIC_LOG
-    i = device_get_config_int("debug");
-    if (i > 0) pcnet_do_log = i;
-#endif
-
     dev = malloc(sizeof(nic_t));
     memset(dev, 0x00, sizeof(nic_t));
     dev->name = info->name;
diff --git a/src/network/net_wd8003.c b/src/network/net_wd8003.c
index 4a8559dc4..33aa1578c 100644
--- a/src/network/net_wd8003.c
+++ b/src/network/net_wd8003.c
@@ -120,7 +120,7 @@ typedef struct {
 
 
 #ifdef ENABLE_WD_LOG
-int WE_do_log = ENABLE_WD_LOG;
+int wd_do_log = ENABLE_WD_LOG;
 
 static void
 wdlog(const char *fmt, ...)
@@ -596,12 +596,6 @@ wd_init(const device_t *info)
     uint32_t mac;
     wd_t *dev;
 
-    /* Get the desired debug level. */
-#ifdef ENABLE_NIC_LOG
-    i = device_get_config_int("debug");
-    if (i > 0) WE_do_log = i;
-#endif
-
     dev = malloc(sizeof(wd_t));
     memset(dev, 0x00, sizeof(wd_t));
     dev->name = info->name;
diff --git a/src/network/network.c b/src/network/network.c
index 1112d397e..fad9eacbc 100644
--- a/src/network/network.c
+++ b/src/network/network.c
@@ -112,9 +112,6 @@ char		network_host[522];
 netdev_t	network_devs[32];
 int		network_rx_pause = 0,
 		network_tx_pause = 0;
-#ifdef ENABLE_NIC_LOG
-int		nic_do_log = ENABLE_NIC_LOG;
-#endif
 
 
 /* Local variables. */
@@ -490,13 +487,9 @@ network_reset(void)
 {
     int i = -1;
 
-#ifdef ENABLE_NIC_LOG
-    network_log("NETWORK: reset (type=%d, card=%d) debug=%d\n",
-			network_type, network_card, nic_do_log);
-#else
     network_log("NETWORK: reset (type=%d, card=%d)\n",
 				network_type, network_card);
-#endif
+
     ui_sb_update_icon(SB_NETWORK, 0);
 
     /* Just in case.. */