Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RebootCount storage on Darwin. #29134

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/platform/Darwin/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks()
return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetRebootCount(uint16_t & rebootCount)
{
uint32_t count = 0;
Copy link
Contributor

@nivi-apple nivi-apple Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this uint32_t? and then cast to uint16_t on line 101? could it be uint16_t count?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this uint32_t? and then cast to uint16_t on line 101?

Because the configuration manager API is:

virtual CHIP_ERROR GetRebootCount(uint32_t & rebootCount)                          = 0;

Now why is that one 32-bit while the actual value in the spec is 16-bit? I don't really know, and it's very out of scope for this PR to change.


CHIP_ERROR err = ConfigurationMgr().GetRebootCount(count);

if (err == CHIP_NO_ERROR)
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
{
VerifyOrReturnError(count <= UINT16_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE);
rebootCount = static_cast<uint16_t>(count);
}

return err;
}

DiagnosticDataProvider & GetDiagnosticDataProviderImpl()
{
return DiagnosticDataProviderImpl::GetDefaultInstance();
Expand Down
1 change: 1 addition & 0 deletions src/platform/Darwin/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider
// ===== Methods that implement the DiagnosticDataProvider abstract interface.
bool SupportsWatermarks() override { return true; }
CHIP_ERROR ResetWatermarks() override;
CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override;
};

/**
Expand Down