Skip to content

Commit efeb2d1

Browse files
dcpleungfabiobaltieri
authored andcommitted
tests: net: renames shadow variables
Renames shadow variables found by -Wshadow. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
1 parent 5bc08ae commit efeb2d1

File tree

22 files changed

+272
-266
lines changed

22 files changed

+272
-266
lines changed

tests/net/arp/src/main.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static struct net_eth_addr *expected_hwaddr;
4141

4242
static struct net_pkt *pending_pkt;
4343

44-
static struct net_eth_addr hwaddr = { { 0x42, 0x11, 0x69, 0xde, 0xfa, 0xec } };
44+
static struct net_eth_addr eth_hwaddr = { { 0x42, 0x11, 0x69, 0xde, 0xfa, 0xec } };
4545

4646
static int send_status = -EINVAL;
4747

@@ -107,7 +107,7 @@ static int tester_send(const struct device *dev, struct net_pkt *pkt)
107107
return -EINVAL;
108108
}
109109

110-
if (!req_test && memcmp(&hdr->dst, &hwaddr,
110+
if (!req_test && memcmp(&hdr->dst, &eth_hwaddr,
111111
sizeof(struct net_eth_addr))) {
112112
char out[sizeof("xx:xx:xx:xx:xx:xx")];
113113

@@ -118,14 +118,14 @@ static int tester_send(const struct device *dev, struct net_pkt *pkt)
118118
printk("Invalid dst hwaddr %s, should be %s\n",
119119
out,
120120
net_sprint_ll_addr(
121-
(uint8_t *)&hwaddr,
121+
(uint8_t *)&eth_hwaddr,
122122
sizeof(struct net_eth_addr)));
123123
send_status = -EINVAL;
124124
return send_status;
125125
}
126126

127127
} else if (ntohs(arp_hdr->opcode) == NET_ARP_REQUEST) {
128-
if (memcmp(&hdr->src, &hwaddr,
128+
if (memcmp(&hdr->src, &eth_hwaddr,
129129
sizeof(struct net_eth_addr))) {
130130
char out[sizeof("xx:xx:xx:xx:xx:xx")];
131131

@@ -136,7 +136,7 @@ static int tester_send(const struct device *dev, struct net_pkt *pkt)
136136
printk("Invalid src hwaddr %s, should be %s\n",
137137
out,
138138
net_sprint_ll_addr(
139-
(uint8_t *)&hwaddr,
139+
(uint8_t *)&eth_hwaddr,
140140
sizeof(struct net_eth_addr)));
141141
send_status = -EINVAL;
142142
return send_status;
@@ -529,7 +529,7 @@ ZTEST(arp_fn_tests, test_arp)
529529
net_ipv4_addr_copy_raw(arp_hdr->dst_ipaddr, (uint8_t *)&dst);
530530
net_ipv4_addr_copy_raw(arp_hdr->src_ipaddr, (uint8_t *)&src);
531531

532-
pkt2 = prepare_arp_reply(iface, pkt, &hwaddr, &eth_hdr);
532+
pkt2 = prepare_arp_reply(iface, pkt, &eth_hwaddr, &eth_hdr);
533533

534534
zassert_not_null(pkt2, "ARP reply generation failed.");
535535

@@ -561,7 +561,7 @@ ZTEST(arp_fn_tests, test_arp)
561561

562562
send_status = -EINVAL;
563563

564-
setup_eth_header(iface, pkt, &hwaddr, NET_ETH_PTYPE_ARP);
564+
setup_eth_header(iface, pkt, &eth_hwaddr, NET_ETH_PTYPE_ARP);
565565

566566
arp_hdr = (struct net_arp_hdr *)(pkt->buffer->data +
567567
(sizeof(struct net_eth_hdr)));
@@ -570,7 +570,7 @@ ZTEST(arp_fn_tests, test_arp)
570570
net_ipv4_addr_copy_raw(arp_hdr->dst_ipaddr, (uint8_t *)&src);
571571
net_ipv4_addr_copy_raw(arp_hdr->src_ipaddr, (uint8_t *)&dst);
572572

573-
pkt2 = prepare_arp_request(iface, pkt, &hwaddr, &eth_hdr);
573+
pkt2 = prepare_arp_request(iface, pkt, &eth_hwaddr, &eth_hdr);
574574

575575
/**TESTPOINT: Check if ARP request generation failed*/
576576
zassert_not_null(pkt2, "ARP request generation failed.");
@@ -602,7 +602,7 @@ ZTEST(arp_fn_tests, test_arp)
602602

603603
/* First make sure that we have an entry in cache */
604604
entry_found = false;
605-
expected_hwaddr = &hwaddr;
605+
expected_hwaddr = &eth_hwaddr;
606606
net_arp_foreach(arp_cb, &dst);
607607
zassert_true(entry_found, "Entry not found");
608608

tests/net/buf/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ ZTEST(net_buf_tests, test_net_buf_4)
270270
removed = 0;
271271

272272
while (buf->frags) {
273-
struct net_buf *frag = buf->frags;
273+
struct net_buf *frag2 = buf->frags;
274274

275-
net_buf_frag_del(buf, frag);
276-
net_buf_unref(frag);
275+
net_buf_frag_del(buf, frag2);
276+
net_buf_unref(frag2);
277277
removed++;
278278
}
279279

tests/net/icmpv4/src/main.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static const unsigned char icmpv4_echo_req_opt_bad[] = {
112112

113113
static uint8_t current = TEST_ICMPV4_UNKNOWN;
114114
static struct in_addr my_addr = { { { 192, 0, 2, 1 } } };
115-
static struct net_if *iface;
115+
static struct net_if *net_iface;
116116

117117
static enum net_verdict handle_reply_msg(struct net_pkt *pkt,
118118
struct net_ipv4_hdr *ip_hdr,
@@ -418,12 +418,12 @@ static void *icmpv4_setup(void)
418418
{
419419
struct net_if_addr *ifaddr;
420420

421-
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY));
422-
if (!iface) {
421+
net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY));
422+
if (!net_iface) {
423423
zassert_true(false, "Interface not available");
424424
}
425425

426-
ifaddr = net_if_ipv4_addr_add(iface, &my_addr, NET_ADDR_MANUAL, 0);
426+
ifaddr = net_if_ipv4_addr_add(net_iface, &my_addr, NET_ADDR_MANUAL, 0);
427427
if (!ifaddr) {
428428
zassert_true(false, "Failed to add address");
429429
}
@@ -434,9 +434,9 @@ static void icmpv4_teardown(void *dummy)
434434
{
435435
ARG_UNUSED(dummy);
436436

437-
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY));
437+
net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY));
438438

439-
net_if_ipv4_addr_rm(iface, &my_addr);
439+
net_if_ipv4_addr_rm(net_iface, &my_addr);
440440
}
441441

442442
static void icmpv4_send_echo_req(void)
@@ -445,7 +445,7 @@ static void icmpv4_send_echo_req(void)
445445

446446
current = TEST_ICMPV4_ECHO_REQ;
447447

448-
pkt = prepare_echo_request(iface);
448+
pkt = prepare_echo_request(net_iface);
449449
if (!pkt) {
450450
zassert_true(false, "EchoRequest packet prep failed");
451451
}
@@ -462,7 +462,7 @@ static void icmpv4_send_echo_rep(void)
462462

463463
net_icmpv4_register_handler(&echo_rep_handler);
464464

465-
pkt = prepare_echo_reply(iface);
465+
pkt = prepare_echo_reply(net_iface);
466466
if (!pkt) {
467467
zassert_true(false, "EchoReply packet prep failed");
468468
}
@@ -480,7 +480,7 @@ ZTEST(net_icmpv4, test_icmpv4_send_echo_req_opt)
480480

481481
current = TEST_ICMPV4_ECHO_REQ_OPTS;
482482

483-
pkt = prepare_echo_request_with_options(iface);
483+
pkt = prepare_echo_request_with_options(net_iface);
484484
if (!pkt) {
485485
zassert_true(false, "EchoRequest with opts packet prep failed");
486486
}
@@ -495,7 +495,7 @@ ZTEST(net_icmpv4, test_send_echo_req_bad_opt)
495495
{
496496
struct net_pkt *pkt;
497497

498-
pkt = prepare_echo_request_with_bad_options(iface);
498+
pkt = prepare_echo_request_with_bad_options(net_iface);
499499
if (!pkt) {
500500
zassert_true(false,
501501
"EchoRequest with bad opts packet prep failed");

tests/net/ieee802154/l2/src/ieee802154_shell_test.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern struct net_pkt *current_pkt;
2525
extern struct k_sem driver_lock;
2626
extern uint8_t mock_ext_addr_be[8];
2727

28-
static struct net_if *iface;
28+
static struct net_if *net_iface;
2929

3030
static struct net_mgmt_event_callback scan_cb;
3131
K_SEM_DEFINE(scan_lock, 0, 1);
@@ -205,7 +205,7 @@ ZTEST(ieee802154_l2_shell, test_active_scan)
205205
};
206206
struct net_pkt *pkt;
207207

208-
pkt = net_pkt_rx_alloc_with_buffer(iface, sizeof(beacon_pkt), AF_UNSPEC, 0, K_FOREVER);
208+
pkt = net_pkt_rx_alloc_with_buffer(net_iface, sizeof(beacon_pkt), AF_UNSPEC, 0, K_FOREVER);
209209
if (!pkt) {
210210
NET_ERR("*** No buffer to allocate\n");
211211
goto fail;
@@ -215,7 +215,7 @@ ZTEST(ieee802154_l2_shell, test_active_scan)
215215
net_buf_add_mem(pkt->buffer, beacon_pkt, sizeof(beacon_pkt));
216216

217217
/* The packet will be placed in the RX queue but not yet handled. */
218-
if (net_recv_data(iface, pkt) < 0) {
218+
if (net_recv_data(net_iface, pkt) < 0) {
219219
NET_ERR("Recv data failed");
220220
net_pkt_unref(pkt);
221221
goto fail;
@@ -236,7 +236,7 @@ ZTEST(ieee802154_l2_shell, test_active_scan)
236236
ZTEST(ieee802154_l2_shell, test_associate)
237237
{
238238
uint8_t coord_addr_le[] = {EXPECTED_COORDINATOR_ADDR_LE};
239-
struct ieee802154_context *ctx = net_if_l2_data(iface);
239+
struct ieee802154_context *ctx = net_if_l2_data(net_iface);
240240
struct ieee802154_frame_params params = {
241241
.dst = {
242242
.len = IEEE802154_EXT_ADDR_LENGTH,
@@ -250,7 +250,8 @@ ZTEST(ieee802154_l2_shell, test_associate)
250250
/* Simulate a packet from the coordinator. */
251251
memcpy(ctx->ext_addr, coord_addr_le, sizeof(ctx->ext_addr));
252252

253-
pkt = ieee802154_create_mac_cmd_frame(iface, IEEE802154_CFI_ASSOCIATION_RESPONSE, &params);
253+
pkt = ieee802154_create_mac_cmd_frame(net_iface, IEEE802154_CFI_ASSOCIATION_RESPONSE,
254+
&params);
254255
if (!pkt) {
255256
NET_ERR("*** Could not create association response\n");
256257
goto fail;
@@ -262,7 +263,7 @@ ZTEST(ieee802154_l2_shell, test_associate)
262263
ieee802154_mac_cmd_finalize(pkt, IEEE802154_CFI_ASSOCIATION_RESPONSE);
263264

264265
/* The packet will be placed in the RX queue but not yet handled. */
265-
if (net_recv_data(iface, pkt) < 0) {
266+
if (net_recv_data(net_iface, pkt) < 0) {
266267
NET_ERR("Recv assoc resp pkt failed");
267268
net_pkt_unref(pkt);
268269
goto fail;
@@ -283,7 +284,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_enddevice)
283284
{
284285
uint8_t expected_coord_addr_le[] = {EXPECTED_COORDINATOR_ADDR_LE};
285286
uint8_t empty_coord_addr[IEEE802154_EXT_ADDR_LENGTH] = {0};
286-
struct ieee802154_context *ctx = net_if_l2_data(iface);
287+
struct ieee802154_context *ctx = net_if_l2_data(net_iface);
287288
uint8_t mock_ext_addr_le[IEEE802154_EXT_ADDR_LENGTH];
288289
struct ieee802154_mpdu mpdu = {0};
289290
int ret;
@@ -328,7 +329,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_coordinator)
328329
{
329330
uint8_t expected_coord_addr_le[] = {EXPECTED_COORDINATOR_ADDR_LE};
330331
uint8_t empty_coord_addr[IEEE802154_EXT_ADDR_LENGTH] = {0};
331-
struct ieee802154_context *ctx = net_if_l2_data(iface);
332+
struct ieee802154_context *ctx = net_if_l2_data(net_iface);
332333
uint8_t mock_ext_addr_le[IEEE802154_EXT_ADDR_LENGTH];
333334
struct ieee802154_frame_params params = {
334335
.dst = {
@@ -349,7 +350,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_coordinator)
349350
memcpy(ctx->ext_addr, expected_coord_addr_le, sizeof(ctx->ext_addr));
350351

351352
/* Create and send an incoming disassociation notification. */
352-
pkt = ieee802154_create_mac_cmd_frame(iface, IEEE802154_CFI_DISASSOCIATION_NOTIFICATION,
353+
pkt = ieee802154_create_mac_cmd_frame(net_iface, IEEE802154_CFI_DISASSOCIATION_NOTIFICATION,
353354
&params);
354355
if (!pkt) {
355356
NET_ERR("*** Could not create association response\n");
@@ -367,7 +368,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_coordinator)
367368
ctx->coord_short_addr = EXPECTED_COORDINATOR_SHORT_ADDR;
368369
memcpy(ctx->coord_ext_addr, expected_coord_addr_le, sizeof(ctx->coord_ext_addr));
369370

370-
if (net_recv_data(iface, pkt) < 0) {
371+
if (net_recv_data(net_iface, pkt) < 0) {
371372
NET_ERR("Recv assoc resp pkt failed");
372373
net_pkt_unref(pkt);
373374
goto fail;
@@ -405,7 +406,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_coordinator)
405406
ZTEST(ieee802154_l2_shell, test_set_ext_addr)
406407
{
407408
uint8_t expected_ext_addr_le[] = {EXPECTED_ENDDEVICE_EXT_ADDR_LE};
408-
struct ieee802154_context *ctx = net_if_l2_data(iface);
409+
struct ieee802154_context *ctx = net_if_l2_data(net_iface);
409410
uint8_t initial_ext_addr_le[sizeof(mock_ext_addr_be)];
410411
int ret;
411412

@@ -433,10 +434,10 @@ static void reset_fake_driver(void *test_fixture)
433434

434435
ARG_UNUSED(test_fixture);
435436

436-
__ASSERT_NO_MSG(iface);
437+
__ASSERT_NO_MSG(net_iface);
437438

438439
/* Set initial conditions. */
439-
ctx = net_if_l2_data(iface);
440+
ctx = net_if_l2_data(net_iface);
440441
ctx->pan_id = IEEE802154_PAN_ID_NOT_ASSOCIATED;
441442
ctx->short_addr = IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED;
442443
ctx->coord_short_addr = IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED;
@@ -454,8 +455,8 @@ static void *test_setup(void)
454455
return NULL;
455456
}
456457

457-
iface = net_if_lookup_by_dev(dev);
458-
if (!iface) {
458+
net_iface = net_if_lookup_by_dev(dev);
459+
if (!net_iface) {
459460
NET_ERR("*** Could not get fake iface\n");
460461
return NULL;
461462
}

0 commit comments

Comments
 (0)