Skip to content

Commit b75b249

Browse files
authored
Explicitly call the EndianPutSigned for signed integers. (project-chip#28374)
* Explicitly call the EndianPutSigned for signed integers. * Added constexpr to compile for Android.
1 parent 367a0c6 commit b75b249

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/app/SafeAttributePersistenceProvider.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ class SafeAttributePersistenceProvider
5454
{
5555
uint8_t value[sizeof(T)];
5656
auto w = Encoding::LittleEndian::BufferWriter(value, sizeof(T));
57-
w.EndianPut(uint64_t(aValue), sizeof(T));
57+
if constexpr (std::is_signed_v<T>)
58+
{
59+
w.EndianPutSigned(aValue, sizeof(T));
60+
}
61+
else
62+
{
63+
w.EndianPut(aValue, sizeof(T));
64+
}
5865

5966
return SafeWriteValue(aPath, ByteSpan(value));
6067
}
@@ -76,7 +83,7 @@ class SafeAttributePersistenceProvider
7683
return err;
7784
}
7885

79-
chip::Encoding::LittleEndian::Reader r(tempVal.data(), tempVal.size());
86+
Encoding::LittleEndian::Reader r(tempVal.data(), tempVal.size());
8087
r.RawReadLowLevelBeCareful(&aValue);
8188
return r.StatusCode();
8289
}

0 commit comments

Comments
 (0)