Skip to content

Commit aa2aced

Browse files
committed
Rename debug macros, header guard, and logging
Standardize debug macro names and clean up private header guard across core network files. Renamed DEBUG_NET_NETIF/DEBUG_NET_TCP/DEBUG_NET_UDP to DEBUG_NETIF/DEBUG_TCP/DEBUG_UDP, and replaced NET_NET_PRIVATE_H_ with NETWORK_PRIVATE_H_ (updated include cleanup and endif comment) in network_private.h. In tcp.cpp, wrap GCC optimization pragmas with CONFIG_TCP_NO_OPTIMIZE to allow opt-out, and replace several network::Error(...) calls with the ERROR(...) logging macro. Also minor formatting tweaks in tcp.cpp (else block) and udp/netif debug guards.
1 parent 2e0bcff commit aa2aced

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

lib-network/src/core/netif.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#if defined(DEBUG_NET_NETIF)
26+
#if defined(DEBUG_NETIF)
2727
#undef NDEBUG
2828
#endif
2929

lib-network/src/core/network_private.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#ifndef NET_NET_PRIVATE_H_
27-
#define NET_NET_PRIVATE_H_
26+
#ifndef NETWORK_PRIVATE_H_
27+
#define NETWORK_PRIVATE_H_
2828

2929
#include <cstdint>
3030
#include <cstdio>
@@ -33,7 +33,6 @@
3333
#include "core/protocol/igmp.h"
3434
#include "core/protocol/udp.h"
3535
#include "core/protocol/tcp.h"
36-
3736
#include "net_platform.h" // IWYU pragma: keep
3837

3938
#ifndef ALIGNED
@@ -127,4 +126,4 @@ void Run();
127126
} // namespace tcp
128127
} // namespace network
129128

130-
#endif // NET_NET_PRIVATE_H_
129+
#endif // NETWORK_PRIVATE_H_

lib-network/src/core/tcp.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@
4343
* - Zero-window probing
4444
*/
4545

46-
#if defined(DEBUG_NET_TCP)
46+
#if defined(DEBUG_TCP)
4747
#undef NDEBUG
4848
#endif
4949
#pragma GCC diagnostic push
5050
#if (__GNUC__ < 10)
5151
#pragma GCC diagnostic ignored "-Wconversion"
5252
#pragma GCC diagnostic ignored "-Wsign-conversion"
5353
#endif
54+
#if !defined(CONFIG_TCP_NO_OPTIMIZE)
5455
#pragma GCC push_options
5556
#pragma GCC optimize("O2")
5657
#pragma GCC optimize("no-tree-loop-distribute-patterns")
58+
#endif
5759

5860
#include <cstdint>
5961
#include <cstring>
@@ -1494,15 +1496,15 @@ static uint16_t s_local_port = kLocalPortRangeStart;
14941496
ConnHandle Connect(uint32_t remote_ip, uint16_t remote_port, CallbackConnect cb_connect, CallbackData cb_data, void* context) {
14951497
const auto& netif = netif::global::netif_default;
14961498
if (__builtin_expect((netif.ip.addr == 0), 0)) {
1497-
network::Error(__func__, "Connect: No ip!");
1499+
ERROR("Connect: No ip!");
14981500
return kInvalidConnHandle;
14991501
}
15001502

15011503
uint32_t out_index = 0;
15021504

15031505
auto* tcb = AllocTcb(remote_port, &out_index);
15041506
if (tcb == nullptr) {
1505-
network::Error(__func__, "Connect: No TCB!");
1507+
ERROR("Connect: No TCB!");
15061508
return kInvalidConnHandle;
15071509
}
15081510

@@ -1542,14 +1544,14 @@ ConnHandle Connect(uint32_t remote_ip, uint16_t remote_port, CallbackConnect cb_
15421544
int32_t Close(ConnHandle conn_handle) // graceful FIN
15431545
{
15441546
if (conn_handle >= TCP_MAX_TCBS_ALLOWED) {
1545-
network::Error(__func__, "Close: Connection handle!");
1547+
ERROR("Close: Connection handle!");
15461548
return -1;
15471549
}
15481550

15491551
auto* c = &s_tcbs[conn_handle];
15501552

15511553
if (!c->in_use || c->state == kStateClosed) {
1552-
network::Error(__func__, "Close: TCB!");
1554+
ERROR("Close: TCB!");
15531555
return -1;
15541556
}
15551557

@@ -1568,7 +1570,7 @@ int32_t Close(ConnHandle conn_handle) // graceful FIN
15681570

15691571
// We only support graceful close from states where FIN makes sense here.
15701572
if (c->state != kStateEstablished && c->state != kStateCloseWait) {
1571-
network::Error(__func__, "Close: Not graceful!");
1573+
ERROR("Close: Not graceful!");
15721574
return -1;
15731575
}
15741576

@@ -1588,8 +1590,7 @@ int32_t Close(ConnHandle conn_handle) // graceful FIN
15881590

15891591
if (c->state == kStateEstablished) {
15901592
NEW_STATE(c, kStateFinWait1);
1591-
} else /* kStateCloseWait */
1592-
{
1593+
} else {
15931594
NEW_STATE(c, kStateLastAck);
15941595
}
15951596

lib-network/src/core/udp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
#include "core/protocol/ethernet.h"
27-
#if defined(DEBUG_NET_UDP)
27+
#if defined(DEBUG_UDP)
2828
#undef NDEBUG
2929
#endif
3030

0 commit comments

Comments
 (0)