From 26e556cc099acbb97569db5208a05c7b5de808b6 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 6 Feb 2023 16:11:34 -0500 Subject: [PATCH] Address review commment. --- src/app/clusters/door-lock-server/door-lock-server.cpp | 4 ++-- src/app/data-model/Nullable.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) 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