Skip to content

Commit c4fbab0

Browse files
tejlmandcarlescufi
authored andcommitted
openthread: moving declaration of variable to top of function
Declaration of variables after a label inside a switch statement is a c23 extension, not c99. This results in the following warning when compiling with clang: > .../subsys/net/openthread/rpc/server/ot_rpc_netdiag.c:86:3: warning: > label followed by a declaration is a C23 extension [-Wc23-extensions] > 86 | uint8_t mode = 0; > | ^ > 1 warning generated. There are no practical reasons why the variable should be declared inside the switch statement, therefore move the declaration to top of function. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent c6e4497 commit c4fbab0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

subsys/net/openthread/rpc/server/ot_rpc_netdiag.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static size_t ot_rpc_network_diag_tlv_size(otNetworkDiagTlv *aNetworkDiagTlv)
7272
static void ot_rpc_encode_network_diag_tlv(struct nrf_rpc_cbor_ctx *ctx,
7373
otNetworkDiagTlv *aNetworkDiagTlv)
7474
{
75+
uint8_t mode;
7576
nrf_rpc_encode_uint(ctx, aNetworkDiagTlv->mType);
7677

7778
switch (aNetworkDiagTlv->mType) {
@@ -83,7 +84,7 @@ static void ot_rpc_encode_network_diag_tlv(struct nrf_rpc_cbor_ctx *ctx,
8384
nrf_rpc_encode_buffer(ctx, aNetworkDiagTlv->mData.mEui64.m8, OT_EXT_ADDRESS_SIZE);
8485
break;
8586
case OT_NETWORK_DIAGNOSTIC_TLV_MODE:
86-
uint8_t mode = 0;
87+
mode = 0;
8788

8889
WRITE_BIT(mode, 0, aNetworkDiagTlv->mData.mMode.mRxOnWhenIdle);
8990
WRITE_BIT(mode, 1, aNetworkDiagTlv->mData.mMode.mDeviceType);
@@ -210,7 +211,7 @@ static void ot_rpc_encode_network_diag_tlv(struct nrf_rpc_cbor_ctx *ctx,
210211
nrf_rpc_encode_uint(ctx, aNetworkDiagTlv->mData.mChildTable.mCount);
211212
zcbor_list_start_encode(ctx->zs, aNetworkDiagTlv->mData.mChildTable.mCount);
212213
for (int i = 0; i < aNetworkDiagTlv->mData.mChildTable.mCount; i++) {
213-
uint8_t mode = 0;
214+
mode = 0;
214215

215216
nrf_rpc_encode_uint(ctx,
216217
aNetworkDiagTlv->mData.mChildTable.mTable[i].mTimeout);

0 commit comments

Comments
 (0)