Skip to content

Commit 041ba6e

Browse files
committed
AP_Networking: disable assert messages for production builds
The string description for the asserts was costing us a lot of flash for not a lot of gain. By not displaying those strings in production builds we save about 11k
1 parent a61671c commit 041ba6e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

libraries/AP_Networking/AP_Networking.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,17 @@ const char *AP_Networking::address_to_str(uint32_t addr)
470470
}
471471

472472
#ifdef LWIP_PLATFORM_ASSERT
473+
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL || defined(HAL_DEBUG_BUILD)
473474
void ap_networking_platform_assert(const char *msg, int line)
474475
{
475-
AP_HAL::panic("LWIP: %s: %u", msg, line);
476+
AP_HAL::panic("LWIP:%u %s", line, msg);
476477
}
478+
#else
479+
void ap_networking_platform_assert(int line)
480+
{
481+
AP_HAL::panic("LWIP:%u", line);
482+
}
483+
#endif
477484
#endif
478485

479486
#ifdef LWIP_HOOK_IP4_ROUTE

libraries/AP_Networking/config/lwipopts.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,13 @@ void sys_check_core_locking(void);
400400

401401
#ifndef LWIP_PLATFORM_ASSERT
402402
/* Define LWIP_PLATFORM_ASSERT to something to catch missing stdio.h includes */
403+
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL || defined(HAL_DEBUG_BUILD)
403404
void ap_networking_platform_assert(const char *msg, int line);
404405
#define LWIP_PLATFORM_ASSERT(x) ap_networking_platform_assert(x, __LINE__)
406+
#else
407+
void ap_networking_platform_assert(int line);
408+
#define LWIP_PLATFORM_ASSERT(x) ap_networking_platform_assert(__LINE__)
409+
#endif
405410
#endif
406411

407412
/*

0 commit comments

Comments
 (0)