Skip to content

Commit b0e99d2

Browse files
committed
fix: remove debugging
1 parent ad13a7c commit b0e99d2

File tree

4 files changed

+1
-77
lines changed

4 files changed

+1
-77
lines changed

w5500/debug.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

w5500/io.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
package w5500
22

3-
import (
4-
"fmt"
5-
"time"
6-
)
3+
import "time"
74

85
func (d *Device) irqPoll(sockn uint8, state uint8, deadline time.Time) uint8 {
96
waitTime := 500 * time.Microsecond
107
for {
118
if !deadline.IsZero() && time.Now().After(deadline) {
12-
if debugging(debugDetail) {
13-
fmt.Println(time.Now(), deadline)
14-
fmt.Printf("[Socket %d] Polling for IRQ %08b timed out.\r\n", sockn, state)
15-
}
16-
179
// If a deadline is set and it has passed, return 0.
1810
return sockIntUnknown
1911
}
@@ -23,10 +15,6 @@ func (d *Device) irqPoll(sockn uint8, state uint8, deadline time.Time) uint8 {
2315
// Acknowledge the interrupt.
2416
d.writeByte(sockInt, sockAddr(sockn), got)
2517

26-
if debugging(debugDetail) {
27-
fmt.Printf("[Socket %d] Got IRQ %08b\r\n", sockn, got)
28-
}
29-
3018
return got
3119
}
3220

w5500/netdev.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ func (d *Device) GetHostByName(name string) (netip.Addr, error) {
6464
}
6565

6666
func (d *Device) Socket(domain int, stype int, protocol int) (int, error) {
67-
if debugging(debugNetdev) {
68-
fmt.Printf("[Socket] domain: %d, type: %d, protocol: %d\r\n",
69-
domain, stype, protocol)
70-
}
71-
7267
if domain != netdev.AF_INET {
7368
return -1, netdev.ErrFamilyNotSupported
7469
}
@@ -108,10 +103,6 @@ func (d *Device) openSocket(sockn uint8, proto byte) {
108103
}
109104

110105
func (d *Device) Bind(sockfd int, ip netip.AddrPort) error {
111-
if debugging(debugNetdev) {
112-
fmt.Printf("[Bind] sockfd: %d, addr: %s:%d\r\n", sockfd, ip.Addr(), ip.Port())
113-
}
114-
115106
// The IP address is irrelevant. The configured ip will always be used.
116107
port := ip.Port()
117108
if port < 1 || port > 65535 {
@@ -154,14 +145,6 @@ func (d *Device) SetSockOpt(int, int, int, any) error {
154145
// If the host is an empty string, it will use the provided ip address and port,
155146
// otherwise it will resolve the host name to an IP address.
156147
func (d *Device) Connect(sockfd int, host string, ip netip.AddrPort) error {
157-
if debugging(debugNetdev) {
158-
if host == "" {
159-
fmt.Printf("[Connect] sockfd: %d, addr: %s\r\n", sockfd, ip)
160-
} else {
161-
fmt.Printf("[Connect] sockfd: %d, host: %s:%d\r\n", sockfd, host, ip.Port())
162-
}
163-
}
164-
165148
destIP := ip.Addr()
166149
if host != "" {
167150
var err error
@@ -196,10 +179,6 @@ func (d *Device) Connect(sockfd int, host string, ip netip.AddrPort) error {
196179
//
197180
// The backlog parameter is ignored, as the W5500 does not support it.
198181
func (d *Device) Listen(sockfd int, _ int) error {
199-
if debugging(debugNetdev) {
200-
fmt.Printf("[Listen] sockfd: %d\r\n", sockfd)
201-
}
202-
203182
d.mu.Lock()
204183
defer d.mu.Unlock()
205184

@@ -229,10 +208,6 @@ func (d *Device) listen(sockn uint8) error {
229208

230209
// Accept waits for an incoming connection on the specified socket file descriptor.
231210
func (d *Device) Accept(sockfd int) (int, netip.AddrPort, error) {
232-
if debugging(debugNetdev) {
233-
fmt.Printf("[Accept] sockfd: %d\r\n", sockfd)
234-
}
235-
236211
d.mu.Lock()
237212
defer d.mu.Unlock()
238213

@@ -264,10 +239,6 @@ func (d *Device) Accept(sockfd int) (int, netip.AddrPort, error) {
264239

265240
csock.setInUse(true)
266241

267-
if debugging(debugNetdev) {
268-
fmt.Printf("[Accepted] sockfd: %d\r\n", csockfd)
269-
}
270-
271242
remoteIP := d.remoteIP(csock.sockn)
272243
return csockfd, remoteIP, nil
273244
}
@@ -306,11 +277,6 @@ func (d *Device) remoteIP(sockn uint8) netip.AddrPort {
306277
// Send sends data to the socket with the given file descriptor.
307278
// It blocks until all data is sent or the deadline is reached.
308279
func (d *Device) Send(sockfd int, buf []byte, _ int, deadline time.Time) (int, error) {
309-
if debugging(debugNetdev) {
310-
fmt.Printf("[Send] sockfd: %d, len(buf): %d\r\n",
311-
sockfd, len(buf))
312-
}
313-
314280
bufLen := len(buf)
315281
if bufLen <= d.maxSockSize {
316282
// Fast path for small buffers.
@@ -399,11 +365,6 @@ func (d *Device) waitForFreeBuffer(sockn uint8, len uint16, deadline time.Time)
399365
// Recv reads data from the socket with the given file descriptor into the provided buffer.
400366
// It blocks until data is available or the deadline is reached.
401367
func (d *Device) Recv(sockfd int, buf []byte, _ int, deadline time.Time) (int, error) {
402-
if debugging(debugNetdev) {
403-
fmt.Printf("[Recv] sockfd: %d, len(buf): %d\r\n",
404-
sockfd, len(buf))
405-
}
406-
407368
d.mu.Lock()
408369
defer d.mu.Unlock()
409370

@@ -450,10 +411,6 @@ func (d *Device) waitForData(sock *socket, deadline time.Time) (int, error) {
450411

451412
// Close closes the socket with the given file descriptor.
452413
func (d *Device) Close(sockfd int) error {
453-
if debugging(debugNetdev) {
454-
fmt.Printf("[Close] sockfd: %d\r\n", sockfd)
455-
}
456-
457414
d.mu.Lock()
458415
defer d.mu.Unlock()
459416

w5500/w5500.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313

1414
var _ netdev.Netdever = &Device{}
1515

16-
var _debug debug = debugOff
17-
1816
// Resolver is a function that resolves a hostname to an IP address.
1917
type Resolver func(host string) (netip.Addr, error)
2018

@@ -156,10 +154,6 @@ func (d *Device) reset() {
156154

157155
// GetHardwareAddr returns the hardware address of the device.
158156
func (d *Device) GetHardwareAddr() (net.HardwareAddr, error) {
159-
if debugging(debugNetdev) {
160-
fmt.Printf("[GetHardwareAddr]\r\n")
161-
}
162-
163157
d.mu.Lock()
164158
defer d.mu.Unlock()
165159

0 commit comments

Comments
 (0)