Skip to content

Commit

Permalink
refactored members names to mMember to avoid shadowing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs authored and pull[bot] committed Feb 19, 2024
1 parent ec298a7 commit 1b28000
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 124 deletions.
36 changes: 18 additions & 18 deletions src/app/clusters/scenes/ExtensionFieldsSetsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ CHIP_ERROR ExtensionFieldsSetsImpl::Serialize(TLV::TLVWriter & writer) const
{
TLV::TLVType container;
ReturnErrorOnFailure(writer.StartContainer(TLV::ContextTag(1), TLV::kTLVType_Structure, container));
ReturnErrorOnFailure(writer.Put(TagFieldNum(), static_cast<uint8_t>(this->fieldNum)));
ReturnErrorOnFailure(writer.Put(TagFieldNum(), static_cast<uint8_t>(this->mFieldNum)));
if (!this->is_empty())
{
for (uint8_t i = 0; i < kMaxClusterPerScenes; i++)
{
if (!this->EFS[i].is_empty())
if (!this->mEFS[i].is_empty())
{
LogErrorOnFailure(this->EFS[i].Serialize(writer));
LogErrorOnFailure(this->mEFS[i].Serialize(writer));
}
}
}
Expand All @@ -48,13 +48,13 @@ CHIP_ERROR ExtensionFieldsSetsImpl::Deserialize(TLV::TLVReader & reader)
ReturnErrorOnFailure(reader.EnterContainer(container));

ReturnErrorOnFailure(reader.Next(TagFieldNum()));
ReturnErrorOnFailure(reader.Get(this->fieldNum));
ReturnErrorOnFailure(reader.Get(this->mFieldNum));

if (!this->is_empty())
{
for (uint8_t i = 0; i < this->fieldNum; i++)
for (uint8_t i = 0; i < this->mFieldNum; i++)
{
ReturnErrorOnFailure(this->EFS[i].Deserialize(reader));
ReturnErrorOnFailure(this->mEFS[i].Deserialize(reader));
}
}

Expand All @@ -66,15 +66,15 @@ void ExtensionFieldsSetsImpl::Clear()
{
for (uint8_t i = 0; i < kMaxClusterPerScenes; i++)
{
this->EFS[i].Clear();
this->mEFS[i].Clear();
}
}
this->fieldNum = 0;
this->mFieldNum = 0;
}

bool ExtensionFieldsSetsImpl::is_empty() const
{
return (this->fieldNum <= 0);
return (this->mFieldNum <= 0);
}

/// @brief Inserts a field set into the array of extension field sets for a scene entry if the same ID is present in the EFS array,
Expand All @@ -86,13 +86,13 @@ CHIP_ERROR ExtensionFieldsSetsImpl::insertField(ExtensionFieldsSet & field)
uint8_t idPosition = 0xff, fisrtEmptyPosition = 0xff;
for (uint8_t i = 0; i < kMaxClusterPerScenes; i++)
{
if (this->EFS[i].ID == field.ID)
if (this->mEFS[i].mID == field.mID)
{
idPosition = i;
break;
}

if (this->EFS[i].is_empty() && fisrtEmptyPosition == 0xFF)
if (this->mEFS[i].is_empty() && fisrtEmptyPosition == 0xFF)
{
fisrtEmptyPosition = i;
}
Expand All @@ -101,13 +101,13 @@ CHIP_ERROR ExtensionFieldsSetsImpl::insertField(ExtensionFieldsSet & field)
// if found, insert at found position, otherwise at first free possition, otherwise return error
if (idPosition < kMaxClusterPerScenes)
{
ReturnErrorOnFailure(this->EFS[idPosition] = field);
ReturnErrorOnFailure(this->mEFS[idPosition] = field);
return CHIP_NO_ERROR;
}
else if (fisrtEmptyPosition < kMaxClusterPerScenes)
{
ReturnErrorOnFailure(this->EFS[fisrtEmptyPosition] = field);
this->fieldNum++;
ReturnErrorOnFailure(this->mEFS[fisrtEmptyPosition] = field);
this->mFieldNum++;
return CHIP_NO_ERROR;
}
else
Expand All @@ -120,7 +120,7 @@ CHIP_ERROR ExtensionFieldsSetsImpl::getFieldAtPosition(ExtensionFieldsSet & fiel
{
if (position < kMaxClusterPerScenes)
{
ReturnErrorOnFailure(field = this->EFS[position]);
ReturnErrorOnFailure(field = this->mEFS[position]);
}

return CHIP_NO_ERROR;
Expand All @@ -132,10 +132,10 @@ CHIP_ERROR ExtensionFieldsSetsImpl::removeFieldAtPosition(uint8_t position)
{
if (position < kMaxClusterPerScenes)
{
if (!this->EFS[position].is_empty())
if (!this->mEFS[position].is_empty())
{
this->EFS[position].Clear();
this->fieldNum--;
this->mEFS[position].Clear();
this->mFieldNum--;
}
}
else
Expand Down
52 changes: 26 additions & 26 deletions src/app/clusters/scenes/ExtensionFieldsSetsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ struct ExtensionFieldsSet
{
static constexpr TLV::Tag TagClusterId() { return TLV::ContextTag(1); }
static constexpr TLV::Tag TagEFS() { return TLV::ContextTag(2); }
clusterId ID = kInvalidClusterId;
uint8_t bytesBuffer[kMaxFieldsPerCluster] = { 0 };
uint8_t usedBytes = 0;
clusterId mID = kInvalidClusterId;
uint8_t mBytesBuffer[kMaxFieldsPerCluster] = { 0 };
uint8_t mUsedBytes = 0;

ExtensionFieldsSet() = default;
ExtensionFieldsSet(clusterId cID, uint8_t * data, uint8_t dataSize) : ID(cID), usedBytes(dataSize)
ExtensionFieldsSet(clusterId cmID, uint8_t * data, uint8_t dataSize) : mID(cmID), mUsedBytes(dataSize)
{
if (dataSize <= kMaxFieldsPerCluster)
{
memcpy(bytesBuffer, data, usedBytes);
memcpy(mBytesBuffer, data, mUsedBytes);
}
}
~ExtensionFieldsSet() = default;
Expand All @@ -48,8 +48,8 @@ struct ExtensionFieldsSet
TLV::TLVType container;
ReturnErrorOnFailure(writer.StartContainer(TLV::ContextTag(1), TLV::kTLVType_Structure, container));

ReturnErrorOnFailure(writer.Put(TagClusterId(), static_cast<uint16_t>(this->ID)));
ReturnErrorOnFailure(writer.PutBytes(TagEFS(), bytesBuffer, usedBytes));
ReturnErrorOnFailure(writer.Put(TagClusterId(), static_cast<uint16_t>(this->mID)));
ReturnErrorOnFailure(writer.PutBytes(TagEFS(), mBytesBuffer, mUsedBytes));

return writer.EndContainer(container);
}
Expand All @@ -61,50 +61,50 @@ struct ExtensionFieldsSet
ReturnErrorOnFailure(reader.EnterContainer(container));

ReturnErrorOnFailure(reader.Next(TagClusterId()));
ReturnErrorOnFailure(reader.Get(this->ID));
ReturnErrorOnFailure(reader.Get(this->mID));

ReturnErrorOnFailure(reader.Next(TagEFS()));
ReturnErrorOnFailure(reader.Get(buffer));
if (buffer.size() > kMaxFieldsPerCluster)
{
this->usedBytes = kMaxFieldsPerCluster;
this->mUsedBytes = kMaxFieldsPerCluster;
}
else
{
this->usedBytes = static_cast<uint8_t>(buffer.size());
this->mUsedBytes = static_cast<uint8_t>(buffer.size());
}
memcpy(this->bytesBuffer, buffer.data(), this->usedBytes);
memcpy(this->mBytesBuffer, buffer.data(), this->mUsedBytes);

return reader.ExitContainer(container);
}

void Clear()
{
this->ID = kInvalidClusterId;
memset(this->bytesBuffer, 0, kMaxFieldsPerCluster);
this->usedBytes = 0;
this->mID = kInvalidClusterId;
memset(this->mBytesBuffer, 0, kMaxFieldsPerCluster);
this->mUsedBytes = 0;
}

bool is_empty() const { return (this->usedBytes == 0); }
bool is_empty() const { return (this->mUsedBytes == 0); }

bool operator==(const ExtensionFieldsSet & other)
{
return (this->ID == other.ID && !memcmp(this->bytesBuffer, other.bytesBuffer, this->usedBytes) &&
this->usedBytes == other.usedBytes);
return (this->mID == other.mID && !memcmp(this->mBytesBuffer, other.mBytesBuffer, this->mUsedBytes) &&
this->mUsedBytes == other.mUsedBytes);
}

CHIP_ERROR operator=(const ExtensionFieldsSet & other)
{
if (other.usedBytes <= kMaxFieldsPerCluster)
if (other.mUsedBytes <= kMaxFieldsPerCluster)
{
memcpy(this->bytesBuffer, other.bytesBuffer, other.usedBytes);
memcpy(this->mBytesBuffer, other.mBytesBuffer, other.mUsedBytes);
}
else
{
return CHIP_ERROR_BUFFER_TOO_SMALL;
}
this->ID = other.ID;
this->usedBytes = other.usedBytes;
this->mID = other.mID;
this->mUsedBytes = other.mUsedBytes;

return CHIP_NO_ERROR;
}
Expand All @@ -131,7 +131,7 @@ class ExtensionFieldsSetsImpl : public ExtensionFieldsSets
{
for (uint8_t i = 0; i < kMaxClusterPerScenes; i++)
{
if (!(this->EFS[i] == other.EFS[i]))
if (!(this->mEFS[i] == other.mEFS[i]))
{
return false;
}
Expand All @@ -143,17 +143,17 @@ class ExtensionFieldsSetsImpl : public ExtensionFieldsSets
{
for (uint8_t i = 0; i < kMaxClusterPerScenes; i++)
{
ReturnErrorOnFailure(this->EFS[i] = other.EFS[i]);
ReturnErrorOnFailure(this->mEFS[i] = other.mEFS[i]);
}
fieldNum = other.fieldNum;
mFieldNum = other.mFieldNum;

return CHIP_NO_ERROR;
}

protected:
static constexpr TLV::Tag TagFieldNum() { return TLV::ContextTag(1); }
ExtensionFieldsSet EFS[kMaxClusterPerScenes];
uint8_t fieldNum = 0;
ExtensionFieldsSet mEFS[kMaxClusterPerScenes];
uint8_t mFieldNum = 0;
};
} // namespace scenes
} // namespace chip
Loading

0 comments on commit 1b28000

Please sign in to comment.