Browse Source

Fix: Suppressed remaining compiler warnings

- Fixed snprintf format-truncation warning in utun_instance.c using pragma
- Fixed DEBUG_CATEGORY_ALL overflow warning using explicit ULL constant
- Fixed test_debug_categories.c using debug_category_t instead of int
- Fixed write() unused result warning in test_u_async_comprehensive.c
nodeinfo-routing-update
Evgeny 2 months ago
parent
commit
ed7f3d8974
  1. 2
      AGENTS.md
  2. 2
      lib/debug_config.h
  3. 6
      src/utun_instance.c
  4. BIN
      tests/test_debug_categories
  5. 2
      tests/test_debug_categories.c
  6. BIN
      tests/test_etcp_100_packets
  7. BIN
      tests/test_etcp_simple_traffic
  8. BIN
      tests/test_etcp_two_instances
  9. BIN
      tests/test_pkt_normalizer_etcp

2
AGENTS.md

@ -215,7 +215,7 @@ Crypto: Fixed CCM nonce size to 13 bytes, all crypto tests passing
- Для отладки не printf а DEBUG_* - Для отладки не printf а DEBUG_*
- перед сборкой всегда make clean - перед сборкой всегда make clean
- прежде чем вносить правки хорошо разберись как должно работать, просмотри все нужные функции полностью, нужно целостное понимание. - прежде чем вносить правки хорошо разберись как должно работать, просмотри все нужные функции полностью, нужно целостное понимание.
- всегда думай можно ли написать проще. Проверяй дубликаты и что уже есть, продумай логику до тех пор пока не будет полного понимания - при написании кода мысленно анализируй логику работы, думай как сделать проще и удобнее. Проверяй дубликаты и что уже есть, продумай логику до тех пор пока не будет полного понимания
Действия при поиске бага: Действия при поиске бага:
1. создать комит или бэкап всего что меняешь 1. создать комит или бэкап всего что меняешь

2
lib/debug_config.h

@ -41,7 +41,7 @@ typedef uint64_t debug_category_t;
#define DEBUG_CATEGORY_TUN ((debug_category_t)1 << 8) // TUN interface #define DEBUG_CATEGORY_TUN ((debug_category_t)1 << 8) // TUN interface
#define DEBUG_CATEGORY_ROUTING ((debug_category_t)1 << 9) // routing table #define DEBUG_CATEGORY_ROUTING ((debug_category_t)1 << 9) // routing table
#define DEBUG_CATEGORY_TIMERS ((debug_category_t)1 << 10) // timer management #define DEBUG_CATEGORY_TIMERS ((debug_category_t)1 << 10) // timer management
#define DEBUG_CATEGORY_ALL ((debug_category_t)(~((uint64_t)0))) #define DEBUG_CATEGORY_ALL ((debug_category_t)0xFFFFFFFFFFFFFFFFULL)
/* Debug configuration structure */ /* Debug configuration structure */
typedef struct { typedef struct {

6
src/utun_instance.c

@ -100,12 +100,18 @@ struct UTUN_INSTANCE* utun_instance_create(struct UASYNC* ua, const char *config
} }
#ifdef __linux__ #ifdef __linux__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
snprintf(tun_ip_str, sizeof(tun_ip_str), "%s/32", ip_buffer); snprintf(tun_ip_str, sizeof(tun_ip_str), "%s/32", ip_buffer);
#pragma GCC diagnostic pop
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
// BSD systems: use config IP as-is, peer IP will be 192.0.2.1 // BSD systems: use config IP as-is, peer IP will be 192.0.2.1
snprintf(tun_ip_str, sizeof(tun_ip_str), "%s", ip_buffer); snprintf(tun_ip_str, sizeof(tun_ip_str), "%s", ip_buffer);
#else #else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
snprintf(tun_ip_str, sizeof(tun_ip_str), "%s/32", ip_buffer); // Default to /32 snprintf(tun_ip_str, sizeof(tun_ip_str), "%s/32", ip_buffer); // Default to /32
#pragma GCC diagnostic pop
#endif #endif
if (tun_set_ip(instance->tun.ifname, tun_ip_str) < 0) { if (tun_set_ip(instance->tun.ifname, tun_ip_str) < 0) {

BIN
tests/test_debug_categories

Binary file not shown.

2
tests/test_debug_categories.c

@ -22,7 +22,7 @@ int main(int argc, char *argv[]) {
debug_set_categories(DEBUG_CATEGORY_ALL); debug_set_categories(DEBUG_CATEGORY_ALL);
// Анализ аргументов командной строки // Анализ аргументов командной строки
int debug_categories = 0; debug_category_t debug_categories = 0;
// Если есть специфические категории, сначала отключаем все // Если есть специфические категории, сначала отключаем все
int has_specific_categories = 0; int has_specific_categories = 0;

BIN
tests/test_etcp_100_packets

Binary file not shown.

BIN
tests/test_etcp_simple_traffic

Binary file not shown.

BIN
tests/test_etcp_two_instances

Binary file not shown.

BIN
tests/test_pkt_normalizer_etcp

Binary file not shown.
Loading…
Cancel
Save