diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index d930351e1108a3..365990cd4c9cc4 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -380,7 +380,7 @@ void DoorLockServer::setUserCommandHandler(chip::app::CommandHandler * commandOb return; } - if (!userType.IsNull() && userType.Value() == UserTypeEnum::kUnknownEnumValue) + if (userType == UserTypeEnum::kUnknownEnumValue) { emberAfDoorLockClusterPrintln( "[SetUser] Unable to set the user: user type is unknown [endpointId=%d,userIndex=%d,userType=%u]", @@ -693,7 +693,7 @@ void DoorLockServer::setCredentialCommandHandler( return; } - if (!userType.IsNull() && userType.Value() == UserTypeEnum::kUnknownEnumValue) + if (userType == UserTypeEnum::kUnknownEnumValue) { emberAfDoorLockClusterPrintln("[SetCredential] Unable to set the credential: user type is unknown " "[endpointId=%d,credentialIndex=%d,userType=%u]", diff --git a/src/app/data-model/Nullable.h b/src/app/data-model/Nullable.h index 46586e0742f328..c9d02791de4154 100644 --- a/src/app/data-model/Nullable.h +++ b/src/app/data-model/Nullable.h @@ -84,6 +84,8 @@ struct Nullable : protected Optional bool operator==(const Nullable & other) const { return Optional::operator==(other); } bool operator!=(const Nullable & other) const { return !(*this == other); } + bool operator==(const T & other) const { return !IsNull() && Value() == other; } + bool operator!=(const T & other) const { return IsNull() || Value() != other; } }; template