Skip to content

Commit 3cbce9e

Browse files
committed
Tidy StoreDevice formatting and size logging
Normalize brace placement in `storedevice.cpp` to match the preferred style, and make the AT24C32 size logging explicit by casting `GetSize()` results to `unsigned` before passing them to `printf`.
1 parent 8220617 commit 3cbce9e

1 file changed

Lines changed: 11 additions & 22 deletions

File tree

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)