mirror of
https://github.com/espressif/openthread.git
synced 2026-08-11 05:07:47 +00:00
[dhcp6-pd-client] initialize msgType to fix compiler warning (#11631)
This commit updates `SendMessage()` to initialize the `msgType` variable before the `switch` statement. This change addresses a compiler warning for a possibly uninitialized variable, flagged by `-Werror=maybe-uninitialized`. Note that the situation where `mState` would be an undefined value is not technically possible in the current logic. However, the compiler cannot guarantee this and therefore generates a warning. Initializing the variable upfront resolves this issue.
This commit is contained in:
@@ -198,9 +198,9 @@ void Dhcp6PdClient::SendMessage(void)
|
||||
{
|
||||
static const uint16_t kRequestedOptions[] = {BigEndian::HostSwap16(Option::kSolMaxRt)};
|
||||
|
||||
MsgType msgType = kMsgTypeNone;
|
||||
OwnedPtr<Message> message;
|
||||
Header header;
|
||||
MsgType msgType;
|
||||
Ip6::Address dstAddr;
|
||||
|
||||
switch (mState)
|
||||
@@ -226,6 +226,8 @@ void Dhcp6PdClient::SendMessage(void)
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
VerifyOrExit(msgType != kMsgTypeNone);
|
||||
|
||||
if (!mRetxTracker.ShouldRetx())
|
||||
{
|
||||
// Message exchanges can optionally define limits: A maximum
|
||||
|
||||
@@ -63,6 +63,7 @@ constexpr uint16_t kDhcpServerPort = 547; ///< DHCP Server port number.
|
||||
*/
|
||||
enum MsgType : uint8_t
|
||||
{
|
||||
kMsgTypeNone = 0, ///< Unused message type (reserved).
|
||||
kMsgTypeSolicit = 1, ///< Solicit message (client sends to locate servers).
|
||||
kMsgTypeAdvertise = 2, ///< Advertise message (server sends to indicate it is available).
|
||||
kMsgTypeRequest = 3, ///< Request message (client sends to request config parameters).
|
||||
|
||||
Reference in New Issue
Block a user