Skip to content

Commit

Permalink
Fix typo in "endianness"
Browse files Browse the repository at this point in the history
Ported from 0d43e51
Closes #2071
  • Loading branch information
RoboSchmied authored and bblanchon committed Mar 26, 2024
1 parent 8d3d9c7 commit 0741bd9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion extras/tests/MsgPackDeserializer/doubleToFloat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static void check(const char* input, T expected) {
uint8_t* f = reinterpret_cast<uint8_t*>(&actual);
const uint8_t* d = reinterpret_cast<const uint8_t*>(input);
doubleToFloat(d, f);
fixEndianess(actual);
fixEndianness(actual);
CHECK(actual == expected);
}

Expand Down
10 changes: 5 additions & 5 deletions src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <ArduinoJson/Deserialization/deserialize.hpp>
#include <ArduinoJson/Memory/MemoryPool.hpp>
#include <ArduinoJson/MsgPack/endianess.hpp>
#include <ArduinoJson/MsgPack/endianness.hpp>
#include <ArduinoJson/MsgPack/ieee754.hpp>
#include <ArduinoJson/Polyfills/type_traits.hpp>
#include <ArduinoJson/Variant/VariantData.hpp>
Expand Down Expand Up @@ -258,7 +258,7 @@ class MsgPackDeserializer {
if (err)
return err;

fixEndianess(value);
fixEndianness(value);

return DeserializationError::Ok;
}
Expand Down Expand Up @@ -287,7 +287,7 @@ class MsgPackDeserializer {
if (err)
return err;

fixEndianess(value);
fixEndianness(value);
variant->setFloat(value);

return DeserializationError::Ok;
Expand All @@ -303,7 +303,7 @@ class MsgPackDeserializer {
if (err)
return err;

fixEndianess(value);
fixEndianness(value);
variant->setFloat(value);

return DeserializationError::Ok;
Expand All @@ -322,7 +322,7 @@ class MsgPackDeserializer {
return err;

doubleToFloat(i, o);
fixEndianess(value);
fixEndianness(value);
variant->setFloat(value);

return DeserializationError::Ok;
Expand Down
4 changes: 2 additions & 2 deletions src/ArduinoJson/MsgPack/MsgPackSerializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include <ArduinoJson/MsgPack/endianess.hpp>
#include <ArduinoJson/MsgPack/endianness.hpp>
#include <ArduinoJson/Polyfills/assert.hpp>
#include <ArduinoJson/Polyfills/type_traits.hpp>
#include <ArduinoJson/Serialization/CountingDecorator.hpp>
Expand Down Expand Up @@ -190,7 +190,7 @@ class MsgPackSerializer : public Visitor<size_t> {

template <typename T>
void writeInteger(T value) {
fixEndianess(value);
fixEndianness(value);
writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ inline void swapBytes(uint8_t& a, uint8_t& b) {
b = t;
}

inline void fixEndianess(uint8_t* p, integral_constant<size_t, 8>) {
inline void fixEndianness(uint8_t* p, integral_constant<size_t, 8>) {
swapBytes(p[0], p[7]);
swapBytes(p[1], p[6]);
swapBytes(p[2], p[5]);
swapBytes(p[3], p[4]);
}

inline void fixEndianess(uint8_t* p, integral_constant<size_t, 4>) {
inline void fixEndianness(uint8_t* p, integral_constant<size_t, 4>) {
swapBytes(p[0], p[3]);
swapBytes(p[1], p[2]);
}

inline void fixEndianess(uint8_t* p, integral_constant<size_t, 2>) {
inline void fixEndianness(uint8_t* p, integral_constant<size_t, 2>) {
swapBytes(p[0], p[1]);
}

inline void fixEndianess(uint8_t*, integral_constant<size_t, 1>) {}
inline void fixEndianness(uint8_t*, integral_constant<size_t, 1>) {}

template <typename T>
inline void fixEndianess(T& value) {
fixEndianess(reinterpret_cast<uint8_t*>(&value),
integral_constant<size_t, sizeof(T)>());
inline void fixEndianness(T& value) {
fixEndianness(reinterpret_cast<uint8_t*>(&value),
integral_constant<size_t, sizeof(T)>());
}
#else
template <typename T>
inline void fixEndianess(T&) {}
inline void fixEndianness(T&) {}
#endif

ARDUINOJSON_END_PRIVATE_NAMESPACE

0 comments on commit 0741bd9

Please sign in to comment.