[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:
Abtin Keshavarzian
2023-11-19 21:19:13 -08:00
committed by GitHub
parent ce9edaf8b5
commit 6e7ed5cb55
62 changed files with 559 additions and 607 deletions
+1 -3
View File
@@ -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");