behavior_info: Mark CopyErrorInfo as const

This doesn't modify member state.

We can also mark the parameter of AppendError as const as well, since it
isn't modified.
master
Lioncash 2022-09-16 09:55:14 +07:00
parent b862d5d8d8
commit b2c2138af7
4 changed files with 6 additions and 6 deletions

@ -34,7 +34,7 @@ void BehaviorInfo::ClearError() {
error_count = 0; error_count = 0;
} }
void BehaviorInfo::AppendError(ErrorInfo& error) { void BehaviorInfo::AppendError(const ErrorInfo& error) {
LOG_ERROR(Service_Audio, "Error during RequestUpdate, reporting code {:04X} address {:08X}", LOG_ERROR(Service_Audio, "Error during RequestUpdate, reporting code {:04X} address {:08X}",
error.error_code.raw, error.address); error.error_code.raw, error.address);
if (error_count < MaxErrors) { if (error_count < MaxErrors) {
@ -42,7 +42,7 @@ void BehaviorInfo::AppendError(ErrorInfo& error) {
} }
} }
void BehaviorInfo::CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count) { void BehaviorInfo::CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count) const {
out_count = std::min(error_count, MaxErrors); out_count = std::min(error_count, MaxErrors);
for (size_t i = 0; i < MaxErrors; i++) { for (size_t i = 0; i < MaxErrors; i++) {

@ -94,7 +94,7 @@ public:
* *
* @param error - The new error. * @param error - The new error.
*/ */
void AppendError(ErrorInfo& error); void AppendError(const ErrorInfo& error);
/** /**
* Copy errors to the given output container. * Copy errors to the given output container.
@ -102,7 +102,7 @@ public:
* @param out_errors - Output container to receive the errors. * @param out_errors - Output container to receive the errors.
* @param out_count - The number of errors written. * @param out_count - The number of errors written.
*/ */
void CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count); void CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count) const;
/** /**
* Update the behaviour flags. * Update the behaviour flags.

@ -485,7 +485,7 @@ Result InfoUpdater::UpdateBehaviorInfo(BehaviorInfo& behaviour_) {
return ResultSuccess; return ResultSuccess;
} }
Result InfoUpdater::UpdateErrorInfo(BehaviorInfo& behaviour_) { Result InfoUpdater::UpdateErrorInfo(const BehaviorInfo& behaviour_) {
auto out_params{reinterpret_cast<BehaviorInfo::OutStatus*>(output)}; auto out_params{reinterpret_cast<BehaviorInfo::OutStatus*>(output)};
behaviour_.CopyErrorInfo(out_params->errors, out_params->error_count); behaviour_.CopyErrorInfo(out_params->errors, out_params->error_count);

@ -130,7 +130,7 @@ public:
* @param behaviour - Behaviour to update. * @param behaviour - Behaviour to update.
* @return Result code. * @return Result code.
*/ */
Result UpdateErrorInfo(BehaviorInfo& behaviour); Result UpdateErrorInfo(const BehaviorInfo& behaviour);
/** /**
* Update splitter. * Update splitter.