mirror of
https://github.com/espressif/openthread.git
synced 2026-08-23 10:49:51 +00:00
[encoding] avoid the use of using for Big/LittleEndian functions (#9621)
This commit refactors the code to eliminate the use of `using` for `BigEndian` or `LittleEndian` functions like `HostSwap` and `ReadUint`. As these functions are frequently used in header files, using the direct namespace enhances code safety by mitigating potential conflicts arising from the order of included headers in the absence of explicit `using` declarations. Generally, avoiding the `using` keyword in headers is considered a recommended practice. Additionally, this commit removes the `Encoding` namespace to shorten the full function names.
This commit is contained in:
@@ -31,8 +31,6 @@
|
||||
|
||||
#include "test_util.hpp"
|
||||
|
||||
using ot::Encoding::BigEndian::ReadUint16;
|
||||
|
||||
namespace ot {
|
||||
namespace Ip6 {
|
||||
|
||||
@@ -97,7 +95,7 @@ void TestIp6Header(void)
|
||||
|
||||
// Verify the offsets to different fields.
|
||||
|
||||
VerifyOrQuit(ReadUint16(headerBytes + Header::kPayloadLengthFieldOffset) == kPayloadLength,
|
||||
VerifyOrQuit(BigEndian::ReadUint16(headerBytes + Header::kPayloadLengthFieldOffset) == kPayloadLength,
|
||||
"kPayloadLengthFieldOffset is incorrect");
|
||||
VerifyOrQuit(headerBytes[Header::kNextHeaderFieldOffset] == kProtoUdp, "kNextHeaderFieldOffset is incorrect");
|
||||
VerifyOrQuit(headerBytes[Header::kHopLimitFieldOffset] == kHopLimit, "kHopLimitFieldOffset is incorrect");
|
||||
|
||||
Reference in New Issue
Block a user