Skip to content

Commit

Permalink
[Infineon] Fix CYW30739 KVS. (#23145)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsusid authored Oct 17, 2022
1 parent 083c9f5 commit 57a8bfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::Init(void)
{
KeyStorage keyStorage;
size_t keyStorageLength;
memset(keyStorage.mKey, 0, sizeof(keyStorage.mKey));
err = CYW30739Config::ReadConfigValueBin(CYW30739ConfigKey(Config::kChipKvsKey_KeyBase, configID), &keyStorage,
sizeof(keyStorage), keyStorageLength);
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -188,7 +189,7 @@ KeyValueStoreManagerImpl::KeyStorage::KeyStorage(const char * key) : mValueSize(

bool KeyValueStoreManagerImpl::KeyStorage::IsMatchKey(const char * key) const
{
return strncmp(mKey, key, sizeof(mKey)) == 0;
return strcmp(mKey, key) == 0;
}

KeyValueStoreManagerImpl::KeyConfigIdEntry * KeyValueStoreManagerImpl::AllocateEntry(const char * key)
Expand Down
8 changes: 4 additions & 4 deletions src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager
{
KeyStorage(const char * key = nullptr);

constexpr size_t GetSize() const { return sizeof(mValueSize) + strnlen(mKey, sizeof(mKey)); }
constexpr size_t GetSize() const { return sizeof(mValueSize) + strlen(mKey); }
bool IsMatchKey(const char * key) const;

uint16_t mValueSize;
char mKey[PersistentStorageDelegate::kKeyLengthMax];
char mKey[PersistentStorageDelegate::kKeyLengthMax + 1];
};

struct KeyConfigIdEntry : public slist_node_t
{
KeyConfigIdEntry(uint8_t configID, const KeyStorage & keyStorage) : mConfigID(configID), mStorage(keyStorage) {}
KeyConfigIdEntry(uint8_t configID, const KeyStorage & keyStorage) : mStorage(keyStorage), mConfigID(configID) {}

constexpr Config::Key GetValueConfigKey() const
{
Expand All @@ -85,8 +85,8 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager
constexpr uint16_t GetValueSize() const { return mStorage.mValueSize; }
constexpr void SetValueSize(uint16_t valueSize) { mStorage.mValueSize = valueSize; }

uint8_t mConfigID;
KeyStorage mStorage;
uint8_t mConfigID;
};

KeyConfigIdEntry * AllocateEntry(const char * key);
Expand Down

0 comments on commit 57a8bfa

Please sign in to comment.