Skip to content

Commit 90a45cd

Browse files
committed
Improve assertions, update copyrights & formatting
Replace bare assert(0) usages with assert(false && "<message>") or assert(false) to provide clearer diagnostics and mark unreachable cases. Update copyright years to include 2026 across several GD32/HAL files. Apply minor whitespace, include ordering and formatting fixes, adjust NDEBUG handling in pixel DMX JSON code, and small API/indentation cleanups. Affected files include artnet, e131, gd32, hal and pixeldmx source/header files.
1 parent 27e4bd7 commit 90a45cd

File tree

12 files changed

+51
-55
lines changed

12 files changed

+51
-55
lines changed

lib-artnet/src/controller/artnetcontroller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ void ArtNetController::ActiveUniversesAdd(uint16_t universe)
534534

535535
if (m_nActiveUniverses == (sizeof(s_active_universes) / sizeof(s_active_universes[0])))
536536
{
537-
assert(0);
537+
assert(false);
538538
return;
539539
}
540540

lib-artnet/src/node/artnetnode.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @file artnetnode.cpp
33
*
44
*/
5-
65
/* Copyright (C) 2016-2026 by Arjan van Vught mailto:info@gd32-dmx.org
76
*
87
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -557,13 +556,13 @@ void ArtNetNode::SetFailSafe(artnet::FailSafe fail_safe)
557556

558557
case artnet::FailSafe::kRecord:
559558
#if defined(ARTNET_HAVE_FAILSAFE_RECORD)
560-
assert(0);
559+
assert(false && "case artnet::FailSafe::kRecord");
561560
__builtin_unreachable();
562561
#endif
563562
break;
564563

565564
default:
566-
[[unlikely]] assert(0);
565+
[[unlikely]] assert(false && "Invalid fail_safe");
567566
__builtin_unreachable();
568567
break;
569568
}
@@ -672,7 +671,7 @@ void ArtNetNode::SetNetworkDataLossCondition()
672671
#endif
673672
break;
674673
default:
675-
assert(0);
674+
assert(false && "Invalid kNetworkloss");
676675
break;
677676
}
678677

lib-e131/src/node/e131bridge.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include "hal_panelled.h"
5050
#include "hal_statusled.h"
5151
#include "hal.h"
52-
#include "firmware/debug/debug_debug.h"
52+
#include "firmware/debug/debug_debug.h"
5353

5454
E131Bridge::E131Bridge()
5555
{
@@ -79,7 +79,7 @@ E131Bridge::E131Bridge()
7979
#if defined(E131_HAVE_DMXIN) || defined(NODE_SHOWFILE)
8080
char source_name[e131::kSourceNameLength];
8181
uint8_t length;
82-
snprintf(source_name, e131::kSourceNameLength, "%.48s %s", network::iface::HostName(), hal::BoardName(length));
82+
snprintf(source_name, e131::kSourceNameLength, "%.48s %s", network::iface::HostName(), hal::BoardName(length));
8383
SetSourceName(source_name);
8484

8585
hal::UuidCopy(cid_);
@@ -348,12 +348,12 @@ void E131Bridge::SetUniverse(uint32_t port_index, uint16_t universe)
348348

349349
assert(port_index < dmxnode::kMaxPorts);
350350
assert((universe >= e131::universe::kDefault) && (universe <= e131::universe::kMax));
351-
351+
352352
if (bridge_.port[port_index].universe == universe)
353353
{
354-
DEBUG_EXIT();
355-
return;
356-
}
354+
DEBUG_EXIT();
355+
return;
356+
}
357357

358358
if (bridge_.port[port_index].direction == dmxnode::PortDirection::kOutput)
359359
{
@@ -363,14 +363,14 @@ void E131Bridge::SetUniverse(uint32_t port_index, uint16_t universe)
363363

364364
bridge_.port[port_index].universe = universe;
365365
input_port_[port_index].multicast_ip = e131::UniverseToMulticastIp(universe);
366-
367-
#if defined(E131_HAVE_DMXIN)
366+
367+
#if defined(E131_HAVE_DMXIN)
368368
if (state_.status == e131bridge::Status::kOn)
369369
{
370-
SetLocalMerging();
371-
}
372-
#endif
373-
370+
SetLocalMerging();
371+
}
372+
#endif
373+
374374
DEBUG_EXIT();
375375
}
376376

@@ -440,13 +440,13 @@ void E131Bridge::SetDirection(uint32_t port_index, dmxnode::PortDirection port_d
440440

441441
bridge_.port[port_index].direction = dmxnode::PortDirection::kOutput;
442442
}
443-
444-
#if defined(E131_HAVE_DMXIN)
443+
444+
#if defined(E131_HAVE_DMXIN)
445445
if (state_.status == e131bridge::Status::kOn)
446446
{
447-
SetLocalMerging();
448-
}
449-
#endif
447+
SetLocalMerging();
448+
}
449+
#endif
450450
}
451451

452452
#if defined(E131_HAVE_DMXIN)
@@ -1066,7 +1066,7 @@ void E131Bridge::SetNetworkDataLossCondition(bool source_a, bool source_b)
10661066
break;
10671067
default:
10681068
DEBUG_PRINTF("state_.failsafe=%u", static_cast<uint32_t>(state_.failsafe));
1069-
assert(0);
1069+
assert(false && "Invalid state_.failsafe");
10701070
break;
10711071
}
10721072
}

lib-gd32/include/gd32_dma.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file gd32_dma.h
33
*
44
*/
5-
/* Copyright (C) 2024-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2024-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -63,7 +63,7 @@ template <uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag> inline
6363
interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_ERRIE;
6464
break;
6565
default:
66-
[[unlikely]] assert(0);
66+
[[unlikely]] assert(false && "Invalid flag");
6767
}
6868

6969
return interrupt_flag && interrupt_enable;
@@ -97,7 +97,7 @@ template <uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag> inline
9797
interrupt_enable = DMA_CHCTL(dma_periph, channelx) & gif_enable;
9898
break;
9999
default:
100-
[[unlikely]] assert(0);
100+
[[unlikely]] assert(false && "Invalid flag");
101101
}
102102

103103
return (interrupt_flag && interrupt_enable);
@@ -132,7 +132,7 @@ template <uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag> inline
132132
interrupt_enable = (DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_FTFIE);
133133
break;
134134
default:
135-
[[unlikely]] assert(0);
135+
[[unlikely]] assert(false && "Invalid flag");
136136
break;
137137
}
138138
}
@@ -162,13 +162,13 @@ template <uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag> inline
162162
interrupt_enable = DMA_CHCTL(dma_periph, channelx) & DMA_CHXCTL_FTFIE;
163163
break;
164164
default:
165-
[[unlikely]] assert(0);
165+
[[unlikely]] assert(false && "Invalid flag");
166166
break;
167167
}
168168
}
169169
else
170170
{
171-
[[unlikely]] assert(0);
171+
[[unlikely]] assert(false && "Invalid channelx");
172172
}
173173

174174
return (interrupt_flag && interrupt_enable);

lib-gd32/include/gd32_gpio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ inline uint32_t Gd32GpioToPeriph(uint32_t gpio)
196196
break;
197197
#endif
198198
default:
199-
assert(0);
199+
assert(false && "Invalid gpio");
200200
return 0;
201201
break;
202202
}

lib-gd32/src/f/gd32_i2c.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file gd32_i2c.cpp
33
*
44
*/
5-
/* Copyright (C) 2021-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2021-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -345,7 +345,7 @@ static void GpioConfigI2c()
345345
}
346346
else
347347
{
348-
assert(0);
348+
assert(false && "Invalid I2C_REMAP");
349349
}
350350
#endif
351351
#else
@@ -380,7 +380,7 @@ static void GpioConfigI2c1()
380380
}
381381
else
382382
{
383-
assert(0);
383+
assert(false && "Invalid I2C1_REMAP");
384384
}
385385
#endif
386386
#else

lib-gd32/src/gd32_bkp.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file gd32_bkp.cpp
33
*
44
*/
5-
/* Copyright (C) 2022-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2022-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -38,7 +38,7 @@ void bkp_data_write(bkp_data_register_enum register_number, uint16_t data)
3838
RTC_BKP1 = static_cast<uint32_t>(data);
3939
break;
4040
default:
41-
assert(0);
41+
assert(false && "Invalid register_number");
4242
break;
4343
}
4444
}
@@ -54,11 +54,10 @@ uint16_t bkp_data_read(bkp_data_register_enum register_number)
5454
return RTC_BKP1;
5555
break;
5656
default:
57-
assert(0);
57+
assert(false && "Invalid register_number");
5858
break;
5959
}
6060

61-
assert(0);
6261
return 0;
6362
}
6463
#endif

lib-gd32/src/gd32_uart.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file gd32_uart.cpp
33
*
44
*/
5-
/* Copyright (C) 2021-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2021-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -100,7 +100,7 @@ static void RcuConfig(uint32_t usart_periph)
100100
break;
101101
#endif
102102
default:
103-
assert(0);
103+
assert(false && "Invalid usart_periph");
104104
__builtin_unreachable();
105105
break;
106106
}
@@ -175,7 +175,7 @@ static void GpioConfig(uint32_t usart_periph)
175175
break;
176176
#endif
177177
default:
178-
assert(0);
178+
assert(false && "Invalid usart_periph");
179179
__builtin_unreachable();
180180
break;
181181
}
@@ -257,7 +257,7 @@ static void GpioConfig(uint32_t usart_periph)
257257
break;
258258
#endif
259259
default:
260-
assert(0);
260+
assert(false && "Invalid usart_periph");
261261
__builtin_unreachable();
262262
break;
263263
}

lib-hal/src/hal_statusled.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* hal_statusled.cpp
33
*/
4-
/* Copyright (C) 2025 by Arjan van Vught mailto:infogd32-dmx.org
4+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:infogd32-dmx.org
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -29,8 +29,7 @@
2929
#include <cstdint>
3030

3131
#include "hal_statusled.h"
32-
33-
#include "firmware/debug/debug_debug.h"
32+
#include "firmware/debug/debug_debug.h"
3433

3534
namespace hal::statusled
3635
{

lib-hal/superloop/softwaretimers.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file softwaretimers.cpp
33
*/
4-
/* Copyright (C) 2024-2025 by Arjan van Vught mailto:info@gd32-dmx.org
4+
/* Copyright (C) 2024-2026 by Arjan van Vught mailto:info@gd32-dmx.org
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@
3939

4040
#include "softwaretimers.h"
4141
#include "hal_millis.h"
42-
#include "firmware/debug/debug_debug.h"
42+
#include "firmware/debug/debug_debug.h"
4343

4444
namespace console
4545
{
@@ -55,9 +55,9 @@ struct Timer
5555
};
5656

5757
static Timer s_timers[hal::kSoftwareTimersMax]; ///< Timer storage pool.
58-
static uint32_t s_timers_count = 0; ///< Number of active timers (0..hal::SOFTWARE_TIMERS_MAX).
59-
static int32_t s_next_id = 0; ///< Monotonically increasing ID source (may wrap, see notes).
60-
static uint32_t s_timer_current = 0; ///< bRound-robin cursor for SoftwareTimerRun().
58+
static uint32_t s_timers_count = 0; ///< Number of active timers (0..hal::SOFTWARE_TIMERS_MAX).
59+
static int32_t s_next_id = 0; ///< Monotonically increasing ID source (may wrap, see notes).
60+
static uint32_t s_timer_current = 0; ///< bRound-robin cursor for SoftwareTimerRun().
6161

6262
/**
6363
* @brief Create and start a periodic (or one-shot) software timer.

0 commit comments

Comments
 (0)