Skip to content

Commit 64a68b3

Browse files
committed
Clean up StoreDevice style and logging
Normalize function/namespace brace formatting in both StoreDevice backends, add explicit unsigned casts for size values in printf calls, and remove verbose DEBUG_PRINTF alignment traces from GD32 BSRAM read/write paths. This keeps output cleaner while preserving behavior.
1 parent d9965f0 commit 64a68b3

2 files changed

Lines changed: 20 additions & 39 deletions

File tree

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,31 @@
4242
static constexpr uint32_t kFlashSectorSize = 4096U;
4343
static constexpr uint32_t kBsramSize = 4096U;
4444

45-
StoreDevice::StoreDevice()
46-
{
45+
StoreDevice::StoreDevice() {
4746
DEBUG_ENTRY();
4847

4948
detected_ = true;
5049

51-
printf("StoreDevice: BSRAM with total %d bytes [%d kB]\n", GetSize(), GetSize() / 1024U);
50+
printf("StoreDevice: BSRAM with total %d bytes [%d kB]\n", static_cast<unsigned>(GetSize()), static_cast<unsigned>(GetSize() / 1024U));
5251
DEBUG_EXIT();
5352
}
5453

55-
StoreDevice::~StoreDevice()
56-
{
54+
StoreDevice::~StoreDevice() {
5755
DEBUG_ENTRY();
5856

5957
DEBUG_EXIT();
6058
}
6159

62-
uint32_t StoreDevice::GetSize() const
63-
{
60+
uint32_t StoreDevice::GetSize() const {
6461
return kBsramSize;
6562
}
6663

67-
uint32_t StoreDevice::GetSectorSize() const
68-
{
64+
uint32_t StoreDevice::GetSectorSize() const {
6965
return kFlashSectorSize;
7066
}
7167

72-
bool StoreDevice::Read(__attribute__((unused)) uint32_t offset, __attribute__((unused)) uint32_t length, __attribute__((unused)) uint8_t* buffer, storedevice::Result& result)
73-
{
68+
bool StoreDevice::Read(__attribute__((unused)) uint32_t offset, __attribute__((unused)) uint32_t length, __attribute__((unused)) uint8_t* buffer, storedevice::Result& result) {
7469
DEBUG_ENTRY();
75-
DEBUG_PRINTF("offset=%p[%d], len=%u[%d], data=%p[%d]", offset, (((uint32_t)(offset) & 0x3) == 0), length, (((uint32_t)(length) & 0x3) == 0), buffer, (((uint32_t)(buffer) & 0x3) == 0));
7670
assert((offset + length) <= BSRAM_SIZE);
7771

7872
result = storedevice::Result::kOk;
@@ -81,20 +75,18 @@ bool StoreDevice::Read(__attribute__((unused)) uint32_t offset, __attribute__((u
8175
return true;
8276
}
8377

84-
bool StoreDevice::Erase(__attribute__((unused)) uint32_t offset, __attribute__((unused)) uint32_t length, storedevice::Result& result)
85-
{
78+
bool StoreDevice::Erase(__attribute__((unused)) uint32_t offset, __attribute__((unused)) uint32_t length, storedevice::Result& result) {
8679
DEBUG_ENTRY();
8780

8881
result = storedevice::Result::kOk;
82+
8983

9084
DEBUG_EXIT();
9185
return true;
9286
}
9387

94-
bool StoreDevice::Write(__attribute__((unused)) uint32_t offset, __attribute__((unused)) uint32_t length, __attribute__((unused)) const uint8_t* buffer, storedevice::Result& result)
95-
{
88+
bool StoreDevice::Write(__attribute__((unused)) uint32_t offset, __attribute__((unused)) uint32_t length, __attribute__((unused)) const uint8_t* buffer, storedevice::Result& result) {
9689
DEBUG_ENTRY();
97-
DEBUG_PRINTF("offset=%p[%d], len=%u[%d], data=%p[%d]", offset, (((uint32_t)(offset) & 0x3) == 0), length, (((uint32_t)(length) & 0x3) == 0), buffer, (((uint32_t)(buffer) & 0x3) == 0));
9890
assert((offset + length) <= BSRAM_SIZE);
9991

10092
result = storedevice::Result::kOk;

lib-configstore/device/i2c/storedevice.cpp

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
#include "i2c/at24cxx.h" // IWYU pragma: keep
4040
#include "firmware/debug/debug_debug.h"
4141

42-
namespace storedevice
43-
{
42+
namespace storedevice {
4443
#if !defined(CONFIG_FLASHROM_I2C_INDEX)
4544
#define CONFIG_FLASHROM_I2C_INDEX 0
4645
#endif
@@ -50,42 +49,34 @@ static constexpr auto kFlashSectorSize = 4096U;
5049
static constexpr auto kRomSize = 4096U;
5150
} // namespace storedevice
5251

53-
StoreDevice::StoreDevice() : AT24C32(storedevice::kI2CIndex)
54-
{
52+
StoreDevice::StoreDevice() : AT24C32(storedevice::kI2CIndex) {
5553
DEBUG_ENTRY();
5654

5755
detected_ = AT24C32::IsConnected();
5856

59-
if (!detected_)
60-
{
57+
if (!detected_) {
6158
printf("StoreDevice: No AT24C32 at %2x", AT24C32::GetAddress());
62-
}
63-
else
64-
{
65-
printf("StoreDevice: AT24C32 total %u bytes [%u kB]\n", GetSize(), GetSize() / 1024U);
59+
} else {
60+
printf("StoreDevice: AT24C32 total %u bytes [%u kB]\n", static_cast<unsigned>(GetSize()), static_cast<unsigned>(GetSize() / 1024U));
6661
}
6762

6863
DEBUG_EXIT();
6964
}
7065

71-
StoreDevice::~StoreDevice()
72-
{
66+
StoreDevice::~StoreDevice() {
7367
DEBUG_ENTRY();
7468
DEBUG_EXIT();
7569
}
7670

77-
uint32_t StoreDevice::GetSize() const
78-
{
71+
uint32_t StoreDevice::GetSize() const {
7972
return storedevice::kRomSize;
8073
}
8174

82-
uint32_t StoreDevice::GetSectorSize() const
83-
{
75+
uint32_t StoreDevice::GetSectorSize() const {
8476
return storedevice::kFlashSectorSize;
8577
}
8678

87-
bool StoreDevice::Read(uint32_t offset, uint32_t length, uint8_t* buffer, storedevice::Result& result)
88-
{
79+
bool StoreDevice::Read(uint32_t offset, uint32_t length, uint8_t* buffer, storedevice::Result& result) {
8980
DEBUG_ENTRY();
9081
assert((offset + length) <= storedevice::ROM_SIZE);
9182

@@ -97,8 +88,7 @@ bool StoreDevice::Read(uint32_t offset, uint32_t length, uint8_t* buffer, stored
9788
return true;
9889
}
9990

100-
bool StoreDevice::Erase([[maybe_unused]] uint32_t offset, [[maybe_unused]] uint32_t length, storedevice::Result& result)
101-
{
91+
bool StoreDevice::Erase([[maybe_unused]] uint32_t offset, [[maybe_unused]] uint32_t length, storedevice::Result& result) {
10292
DEBUG_ENTRY();
10393

10494
result = storedevice::Result::kOk;
@@ -107,8 +97,7 @@ bool StoreDevice::Erase([[maybe_unused]] uint32_t offset, [[maybe_unused]] uint3
10797
return true;
10898
}
10999

110-
bool StoreDevice::Write(uint32_t offset, uint32_t length, const uint8_t* buffer, storedevice::Result& result)
111-
{
100+
bool StoreDevice::Write(uint32_t offset, uint32_t length, const uint8_t* buffer, storedevice::Result& result) {
112101
DEBUG_ENTRY();
113102
assert((offset + length) <= ROM_SIZE);
114103

0 commit comments

Comments
 (0)