Skip to content

Commit

Permalink
Rename Nullable::HasValidValue so people won't try to use it. (#26535)
Browse files Browse the repository at this point in the history
This function is a pretty specific thing, and people are confusing it with
IsNull().  Rename to something that will make it less likely.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jan 22, 2024
1 parent 90c40a5 commit 1238855
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ CHIP_ERROR Encode(const ConcreteReadAttributePath & aPath, AttributeValueEncoder
// CONFIG_BUILD_FOR_HOST_UNIT_TEST is true, so we can test how the other side
// responds.
#if !CONFIG_BUILD_FOR_HOST_UNIT_TEST
if (!x.HasValidValue())
if (!x.ExistingValueInEncodableRange())
{
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
}
Expand Down Expand Up @@ -313,7 +313,7 @@ CHIP_ERROR Decode(const ConcreteDataAttributePath & aPath, AttributeValueDecoder

// We have a value; decode it.
ReturnErrorOnFailure(Decode(aPath, aDecoder, x.SetNonNull()));
if (!x.HasValidValue())
if (!x.ExistingValueInEncodableRange())
{
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model/Decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ CHIP_ERROR Decode(TLV::TLVReader & reader, Nullable<X> & x)

// We have a value; decode it.
ReturnErrorOnFailure(Decode(reader, x.SetNonNull()));
if (!x.HasValidValue())
if (!x.ExistingValueInEncodableRange())
{
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model/Encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, const Nullable<X> & x)
// CONFIG_BUILD_FOR_HOST_UNIT_TEST is true, so we can test how the other side
// responds.
#if !CONFIG_BUILD_FOR_HOST_UNIT_TEST
if (!x.HasValidValue())
if (!x.ExistingValueInEncodableRange())
{
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/data-model/Nullable.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct Nullable : protected Optional<T>
template <
typename U = std::decay_t<T>,
typename std::enable_if_t<(std::is_integral<U>::value && !std::is_same<U, bool>::value) || std::is_enum<U>::value, int> = 0>
constexpr bool HasValidValue() const
constexpr bool ExistingValueInEncodableRange() const
{
return NumericAttributeTraits<T>::CanRepresentValue(/* isNullable = */ true, Value());
}
Expand All @@ -74,7 +74,7 @@ struct Nullable : protected Optional<T>
template <typename U = std::decay_t<T>,
typename std::enable_if_t<(!std::is_integral<U>::value || std::is_same<U, bool>::value) && !std::is_enum<U>::value,
int> = 0>
constexpr bool HasValidValue() const
constexpr bool ExistingValueInEncodableRange() const
{
return true;
}
Expand Down

0 comments on commit 1238855

Please sign in to comment.