[spinel] fix little endian in lib (#10522)

This commit is contained in:
Li Cao
2024-07-17 10:10:12 -07:00
committed by GitHub
parent aba7aede14
commit 0897b50a27
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -464,12 +464,12 @@ private:
public:
static uint16_t ReadUint16(const uint8_t *aBuffer)
{
return static_cast<uint16_t>((aBuffer[0] << 8) | aBuffer[1]);
return static_cast<uint16_t>((aBuffer[0]) | aBuffer[1] << 8);
}
static void WriteUint16(uint16_t aValue, uint8_t *aBuffer)
{
aBuffer[0] = (aValue >> 8) & 0xff;
aBuffer[1] = (aValue >> 0) & 0xff;
aBuffer[0] = (aValue >> 0) & 0xff;
aBuffer[1] = (aValue >> 8) & 0xff;
}
};
+3 -3
View File
@@ -238,12 +238,12 @@ private:
public:
static uint16_t ReadUint16(const uint8_t *aBuffer)
{
return static_cast<uint16_t>((aBuffer[0] << 8) | aBuffer[1]);
return static_cast<uint16_t>((aBuffer[0]) | aBuffer[1] << 8);
}
static void WriteUint16(uint16_t aValue, uint8_t *aBuffer)
{
aBuffer[0] = (aValue >> 8) & 0xff;
aBuffer[1] = (aValue >> 0) & 0xff;
aBuffer[0] = (aValue >> 0) & 0xff;
aBuffer[1] = (aValue >> 8) & 0xff;
}
};