Skip to content

Commit fc7b2bd

Browse files
committed
Fix some compile errors ... std::optional now detects unused variables
1 parent 773136d commit fc7b2bd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,6 @@ CHIP_ERROR SetValveLevel(EndpointId ep, DataModel::Nullable<Percent> level, Data
311311
{
312312
Delegate * delegate = GetDelegate(ep);
313313
Optional<Status> status = Optional<Status>::Missing();
314-
DataModel::Nullable<Percent> openLevel;
315-
DataModel::Nullable<uint64_t> autoCloseTime;
316314
CHIP_ERROR attribute_error = CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute);
317315

318316
if (HasFeature(ep, ValveConfigurationAndControl::Feature::kTimeSync))
@@ -328,6 +326,7 @@ CHIP_ERROR SetValveLevel(EndpointId ep, DataModel::Nullable<Percent> level, Data
328326
VerifyOrReturnError(UnixEpochToChipEpochMicros(utcTime.count(), chipEpochTime), CHIP_ERROR_INVALID_TIME);
329327

330328
uint64_t time = openDuration.Value() * chip::kMicrosecondsPerSecond;
329+
DataModel::Nullable<uint64_t> autoCloseTime;
331330
autoCloseTime.SetNonNull(chipEpochTime + time);
332331
VerifyOrReturnError(Status::Success == AutoCloseTime::Set(ep, autoCloseTime), attribute_error);
333332
}

src/app/data-model/Nullable.h

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct Nullable : protected std::optional<T>
5555
// NOTE: as we transition to std::optional, these should be removed
5656
T & Value() & { return value(); }
5757
const T & Value() const & { return value(); }
58+
const T & ValueOr(const T & defaultValue) const { return value_or(defaultValue); }
5859
Nullable(NullOptionalType) : std::optional<T>(std::nullopt) {}
5960

6061
// Some consumers need an easy way to determine our underlying type.

0 commit comments

Comments
 (0)