Skip to content

Commit 94d876d

Browse files
committed
Configstore: enforce exclusive backend and cleanups
Add compile-time guards to ensure only one storage backend is enabled (error out if multiple of RAM/ROM/SPI/I2C are defined), update copyright years to 2026, and apply small tidy-ups across device implementations. Changes include inserting #if/#error checks, undef NDEBUG when DEBUG_CONFIGSTORE is defined, add IWYU pragma: keep to some includes to silence include-tool warnings, and expand single-line destructors to multi-line blocks with DEBUG_ENTRY/DEBUG_EXIT for consistency. Affected files: lib-configstore/device/gd32/ram/storedevice.cpp, lib-configstore/device/gd32/rom/storedevice.cpp, lib-configstore/device/i2c/storedevice.cpp, lib-configstore/device/spi/storedevice.cpp.
1 parent a7a20ec commit 94d876d

5 files changed

Lines changed: 58 additions & 23 deletions

File tree

common/make/gd32/Board.mk

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ endif
1717
ifeq ($(strip $(BOARD)),BOARD_GD32F107RC)
1818
MCU=GD32F107RC
1919
DEFINES+=-DCONFIG_STORE_USE_ROM
20+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_NONE
2021
endif
2122

2223
ifeq ($(strip $(BOARD)),BOARD_GD32F207RG)
2324
MCU=GD32F207RG
2425
DEFINES+=-DCONFIG_STORE_USE_SPI
25-
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
26+
endif
27+
28+
ifeq ($(strip $(BOARD)),BOARD_GD32F303CB)
29+
MCU=GD32F303CB
30+
DEFINES+=-DCONFIG_STORE_USE_ROM
31+
DEFINES+=-DNO_EMAC
2632
endif
2733

2834
ifeq ($(strip $(BOARD)),BOARD_GD32F303RC)
@@ -34,22 +40,20 @@ endif
3440
ifeq ($(strip $(BOARD)),BOARD_GD32F407RE)
3541
MCU=GD32F407RE
3642
DEFINES+=-DCONFIG_STORE_USE_SPI
37-
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
3843
endif
3944

4045
ifeq ($(strip $(BOARD)),BOARD_GD32F450VI)
4146
MCU=GD32F450VI
42-
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
4347
endif
4448

4549
ifeq ($(strip $(BOARD)),BOARD_16X4U_PIXEL)
4650
MCU=GD32F450VI
47-
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
51+
DEFINES+=-DCONFIG_STORE_USE_SPI
4852
endif
4953

5054
ifeq ($(strip $(BOARD)),BOARD_GD32F470VG)
5155
MCU=GD32F470VG
52-
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
56+
DEFINES+=-DCONFIG_STORE_USE_SPI
5357
endif
5458

5559
ifeq ($(strip $(BOARD)),BOARD_GD32F207C_EVAL)
@@ -70,19 +74,16 @@ endif
7074
ifeq ($(strip $(BOARD)),BOARD_BW_OPIDMX4)
7175
BOARD_DMX=4
7276
DEFINES+=-DCONFIG_STORE_USE_SPI
73-
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
7477
endif
7578

7679
ifeq ($(strip $(BOARD)),BOARD_DMX3)
7780
BOARD_DMX=3
7881
DEFINES+=-DCONFIG_STORE_USE_SPI
79-
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
8082
endif
8183

8284
ifeq ($(strip $(BOARD)),BOARD_DMX4)
83-
BOARD_DMX=4
8485
DEFINES+=-DCONFIG_STORE_USE_SPI
85-
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
86+
BOARD_DMX=4
8687
endif
8788

8889
ifdef BOARD_DMX

lib-configstore/device/gd32/ram/storedevice.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file storedevice.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
@@ -23,13 +23,20 @@
2323
* THE SOFTWARE.
2424
*/
2525

26+
#if defined(CONFIG_STORE_USE_SPI) || defined(CONFIG_STORE_USE_I2C) || defined(CONFIG_STORE_USE_ROM)
27+
#error Configuration error
28+
#endif
29+
30+
#if defined(DEBUG_CONFIGSTORE)
31+
#undef NDEBUG
32+
#endif
33+
2634
#include <cstdint>
2735
#include <cstdio>
2836
#include <cassert>
2937

3038
#include "configstoredevice.h"
31-
#include "gd32.h"
32-
39+
#include "gd32.h" // IWYU pragma: keep
3340
#include "firmware/debug/debug_debug.h"
3441

3542
static constexpr uint32_t kFlashSectorSize = 4096U;
@@ -45,9 +52,12 @@ StoreDevice::StoreDevice()
4552
DEBUG_EXIT();
4653
}
4754

48-
StoreDevice::~StoreDevice(){DEBUG_ENTRY();
55+
StoreDevice::~StoreDevice()
56+
{
57+
DEBUG_ENTRY();
4958

50-
DEBUG_EXIT();}
59+
DEBUG_EXIT();
60+
}
5161

5262
uint32_t StoreDevice::GetSize() const
5363
{

lib-configstore/device/gd32/rom/storedevice.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file storedevice.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
@@ -23,6 +23,14 @@
2323
* THE SOFTWARE.
2424
*/
2525

26+
#if defined(CONFIG_STORE_USE_SPI) || defined(CONFIG_STORE_USE_I2C) || defined(CONFIG_STORE_USE_RAM)
27+
#error Configuration error
28+
#endif
29+
30+
#if defined(DEBUG_CONFIGSTORE)
31+
#undef NDEBUG
32+
#endif
33+
2634
#include <cstdint>
2735

2836
#include "configstoredevice.h"
@@ -40,8 +48,8 @@ StoreDevice::StoreDevice()
4048

4149
StoreDevice::~StoreDevice()
4250
{
43-
DEBUG_ENTRY();
44-
DEBUG_EXIT();
51+
DEBUG_ENTRY();
52+
DEBUG_EXIT();
4553
}
4654

4755
uint32_t StoreDevice::GetSize() const

lib-configstore/device/i2c/storedevice.cpp

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

26+
#if defined(CONFIG_STORE_USE_SPI) || defined(CONFIG_STORE_USE_ROM) || defined(CONFIG_STORE_USE_RAM)
27+
#error Configuration error
28+
#endif
29+
2630
#if defined(DEBUG_CONFIGSTORE)
2731
#undef NDEBUG
2832
#endif
@@ -32,8 +36,8 @@
3236
#include <cassert>
3337

3438
#include "configstoredevice.h"
35-
#include "i2c/at24cxx.h"
36-
#include "firmware/debug/debug_debug.h"
39+
#include "i2c/at24cxx.h" // IWYU pragma: keep
40+
#include "firmware/debug/debug_debug.h"
3741

3842
namespace storedevice
3943
{
@@ -64,7 +68,11 @@ StoreDevice::StoreDevice() : AT24C32(storedevice::kI2CIndex)
6468
DEBUG_EXIT();
6569
}
6670

67-
StoreDevice::~StoreDevice(){DEBUG_ENTRY(); DEBUG_EXIT();}
71+
StoreDevice::~StoreDevice()
72+
{
73+
DEBUG_ENTRY();
74+
DEBUG_EXIT();
75+
}
6876

6977
uint32_t StoreDevice::GetSize() const
7078
{

lib-configstore/device/spi/storedevice.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file storedevice.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
@@ -23,6 +23,10 @@
2323
* THE SOFTWARE.
2424
*/
2525

26+
#if defined(CONFIG_STORE_USE_I2C) || defined(CONFIG_STORE_USE_ROM) || defined(CONFIG_STORE_USE_RAM)
27+
#error Configuration error
28+
#endif
29+
2630
#if defined(DEBUG_CONFIGSTORE)
2731
#undef NDEBUG
2832
#endif
@@ -32,7 +36,7 @@
3236

3337
#include "configstoredevice.h"
3438
#include "spi/spi_flash.h"
35-
#include "firmware/debug/debug_debug.h"
39+
#include "firmware/debug/debug_debug.h"
3640

3741
StoreDevice::StoreDevice()
3842
{
@@ -52,7 +56,11 @@ StoreDevice::StoreDevice()
5256
DEBUG_EXIT();
5357
}
5458

55-
StoreDevice::~StoreDevice(){DEBUG_ENTRY(); DEBUG_EXIT();}
59+
StoreDevice::~StoreDevice()
60+
{
61+
DEBUG_ENTRY();
62+
DEBUG_EXIT();
63+
}
5664

5765
uint32_t StoreDevice::GetSize() const
5866
{

0 commit comments

Comments
 (0)