Skip to content

Commit

Permalink
Manual check for last written saves 16 bytes of flash on QPG.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreilitvin committed Jan 30, 2025
1 parent d6cb071 commit 9d38910
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,17 +791,12 @@ DataModel::ActionReturnStatus WriteHandler::CheckWriteAllowed(const Access::Subj
// In particular `request.path` is a DATA path (contains a list index)
// and we do not want mLastSuccessfullyWrittenPath to be auto-cast to a
// data path with a empty list and fail the compare.
//
// This could be `mLastSuccessfullyWrittenPath != request.path` (where order
// is important) however that would seem more brittle (relying that a != b
// behaves differently than b != a due to casts). Overall Data paths are not
// the same as attribute paths.
//
// Also note that Concrete path have a mExpanded that is not used in compares.
const ConcreteAttributePath & attributePathA = aPath;
const ConcreteAttributePath & attributePathB = *mLastSuccessfullyWrittenPath;

checkAcl = (attributePathA != attributePathB);
if ((aPath.mEndpointId == mLastSuccessfullyWrittenPath->mEndpointId) &&
(aPath.mClusterId == mLastSuccessfullyWrittenPath->mClusterId) &&
(aPath.mAttributeId == mLastSuccessfullyWrittenPath->mAttributeId))
{
checkAcl = false;
}
}

if (checkAcl)
Expand Down

0 comments on commit 9d38910

Please sign in to comment.