Skip to content

Commit 5bc08ae

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

File tree

17 files changed

+112
-116
lines changed

17 files changed

+112
-116
lines changed

drivers/net/slip.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,20 +314,20 @@ static uint8_t *recv_cb(uint8_t *buf, size_t *off)
314314
if (slip_input_byte(slip, buf[i])) {
315315

316316
if (LOG_LEVEL >= LOG_LEVEL_DBG) {
317-
struct net_buf *buf = slip->rx->buffer;
318-
int bytes = net_buf_frags_len(buf);
317+
struct net_buf *rx_buf = slip->rx->buffer;
318+
int bytes = net_buf_frags_len(rx_buf);
319319
int count = 0;
320320

321-
while (bytes && buf) {
321+
while (bytes && rx_buf) {
322322
char msg[6 + 10 + 1];
323323

324324
snprintk(msg, sizeof(msg),
325325
">slip %2d", count);
326326

327-
LOG_HEXDUMP_DBG(buf->data, buf->len,
327+
LOG_HEXDUMP_DBG(rx_buf->data, rx_buf->len,
328328
msg);
329329

330-
buf = buf->frags;
330+
rx_buf = rx_buf->frags;
331331
count++;
332332
}
333333

subsys/net/ip/net_if.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,8 +3256,8 @@ bool net_if_ipv4_is_addr_bcast(struct net_if *iface,
32563256
goto out;
32573257
}
32583258

3259-
STRUCT_SECTION_FOREACH(net_if, iface) {
3260-
ret = ipv4_is_broadcast_address(iface, addr);
3259+
STRUCT_SECTION_FOREACH(net_if, one_iface) {
3260+
ret = ipv4_is_broadcast_address(one_iface, addr);
32613261
if (ret) {
32623262
goto out;
32633263
}

subsys/net/ip/net_shell.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,14 +2974,14 @@ static void gptp_print_port_info(const struct shell *sh, int port)
29742974
struct gptp_port_bmca_data *port_bmca_data;
29752975
struct gptp_port_param_ds *port_param_ds;
29762976
struct gptp_port_states *port_state;
2977-
struct gptp_domain *gptp_domain;
2977+
struct gptp_domain *domain;
29782978
struct gptp_port_ds *port_ds;
29792979
struct net_if *iface;
29802980
int ret, i;
29812981

2982-
gptp_domain = gptp_get_domain();
2982+
domain = gptp_get_domain();
29832983

2984-
ret = gptp_get_port_data(gptp_domain,
2984+
ret = gptp_get_port_data(domain,
29852985
port,
29862986
&port_ds,
29872987
&port_param_ds,
@@ -3080,10 +3080,10 @@ static void gptp_print_port_info(const struct shell *sh, int port)
30803080
(NSEC_PER_USEC * USEC_PER_MSEC));
30813081
PR("BMCA %s %s%d%s: %d\n", "default", "priority", 1,
30823082
" ",
3083-
gptp_domain->default_ds.priority1);
3083+
domain->default_ds.priority1);
30843084
PR("BMCA %s %s%d%s: %d\n", "default", "priority", 2,
30853085
" ",
3086-
gptp_domain->default_ds.priority2);
3086+
domain->default_ds.priority2);
30873087

30883088
PR("\nRuntime status:\n");
30893089
PR("Current global port state "

subsys/net/ip/route.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,18 @@ struct net_route_entry *net_route_add(struct net_if *iface,
411411
node);
412412

413413
if (CONFIG_NET_ROUTE_LOG_LEVEL >= LOG_LEVEL_DBG) {
414-
struct in6_addr *tmp;
414+
struct in6_addr *in6_addr_tmp;
415415
struct net_linkaddr_storage *llstorage;
416416

417-
tmp = net_route_get_nexthop(route);
418-
nbr = net_ipv6_nbr_lookup(iface, tmp);
417+
in6_addr_tmp = net_route_get_nexthop(route);
418+
nbr = net_ipv6_nbr_lookup(iface, in6_addr_tmp);
419419
if (nbr) {
420420
llstorage = net_nbr_get_lladdr(nbr->idx);
421421

422422
NET_DBG("Removing the oldest route %s "
423423
"via %s [%s]",
424424
net_sprint_ipv6_addr(&route->addr),
425-
net_sprint_ipv6_addr(tmp),
425+
net_sprint_ipv6_addr(in6_addr_tmp),
426426
net_sprint_ll_addr(llstorage->addr,
427427
llstorage->len));
428428
}

subsys/net/l2/bluetooth/bluetooth.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -445,44 +445,44 @@ static bool eir_found(uint8_t type, const uint8_t *data, uint8_t data_len,
445445
return false;
446446
}
447447

448-
static bool ad_parse(struct net_buf_simple *ad,
448+
static bool ad_parse(struct net_buf_simple *ad_buf,
449449
bool (*func)(uint8_t type, const uint8_t *data,
450450
uint8_t data_len, void *user_data),
451451
void *user_data)
452452
{
453-
while (ad->len > 1) {
454-
uint8_t len = net_buf_simple_pull_u8(ad);
453+
while (ad_buf->len > 1) {
454+
uint8_t len = net_buf_simple_pull_u8(ad_buf);
455455
uint8_t type;
456456

457457
/* Check for early termination */
458458
if (len == 0U) {
459459
return false;
460460
}
461461

462-
if (len > ad->len) {
462+
if (len > ad_buf->len) {
463463
NET_ERR("AD malformed\n");
464464
return false;
465465
}
466466

467-
type = net_buf_simple_pull_u8(ad);
467+
type = net_buf_simple_pull_u8(ad_buf);
468468

469-
if (func(type, ad->data, len - 1, user_data)) {
469+
if (func(type, ad_buf->data, len - 1, user_data)) {
470470
return true;
471471
}
472472

473-
net_buf_simple_pull(ad, len - 1);
473+
net_buf_simple_pull(ad_buf, len - 1);
474474
}
475475

476476
return false;
477477
}
478478

479479
static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
480-
struct net_buf_simple *ad)
480+
struct net_buf_simple *ad_buf)
481481
{
482482
/* We're only interested in connectable events */
483483
if (type == BT_GAP_ADV_TYPE_ADV_IND ||
484484
type == BT_GAP_ADV_TYPE_ADV_DIRECT_IND) {
485-
ad_parse(ad, eir_found, (void *)addr);
485+
ad_parse(ad_buf, eir_found, (void *)addr);
486486
}
487487
}
488488

subsys/net/l2/ethernet/arp.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -478,28 +478,28 @@ static void arp_update(struct net_if *iface,
478478

479479
if (force) {
480480
sys_snode_t *prev = NULL;
481-
struct arp_entry *entry;
481+
struct arp_entry *arp_ent;
482482

483-
entry = arp_entry_find(&arp_table, iface, src, &prev);
484-
if (entry) {
485-
memcpy(&entry->eth, hwaddr,
483+
arp_ent = arp_entry_find(&arp_table, iface, src, &prev);
484+
if (arp_ent) {
485+
memcpy(&arp_ent->eth, hwaddr,
486486
sizeof(struct net_eth_addr));
487487
} else {
488488
/* Add new entry as it was not found and force
489489
* was set.
490490
*/
491-
entry = arp_entry_get_free();
492-
if (!entry) {
491+
arp_ent = arp_entry_get_free();
492+
if (!arp_ent) {
493493
/* Then let's take one from table? */
494-
entry = arp_entry_get_last_from_table();
494+
arp_ent = arp_entry_get_last_from_table();
495495
}
496496

497-
if (entry) {
498-
entry->req_start = k_uptime_get_32();
499-
entry->iface = iface;
500-
net_ipaddr_copy(&entry->ip, src);
501-
memcpy(&entry->eth, hwaddr, sizeof(entry->eth));
502-
sys_slist_prepend(&arp_table, &entry->node);
497+
if (arp_ent) {
498+
arp_ent->req_start = k_uptime_get_32();
499+
arp_ent->iface = iface;
500+
net_ipaddr_copy(&arp_ent->ip, src);
501+
memcpy(&arp_ent->eth, hwaddr, sizeof(arp_ent->eth));
502+
sys_slist_prepend(&arp_table, &arp_ent->node);
503503
}
504504
}
505505
}

subsys/net/l2/ethernet/gptp/gptp.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -941,15 +941,15 @@ static void disable_port(int port)
941941

942942
static void vlan_enabled(struct k_work *work)
943943
{
944-
struct vlan_work *vlan = CONTAINER_OF(work,
945-
struct vlan_work,
946-
work);
944+
struct vlan_work *one_vlan = CONTAINER_OF(work,
945+
struct vlan_work,
946+
work);
947947
if (tid) {
948948
int port;
949949

950-
port = gptp_get_port_number(vlan->iface);
950+
port = gptp_get_port_number(one_vlan->iface);
951951
if (port < 0) {
952-
NET_DBG("No port found for iface %p", vlan->iface);
952+
NET_DBG("No port found for iface %p", one_vlan->iface);
953953
return;
954954
}
955955

@@ -963,14 +963,14 @@ static void vlan_enabled(struct k_work *work)
963963

964964
static void vlan_disabled(struct k_work *work)
965965
{
966-
struct vlan_work *vlan = CONTAINER_OF(work,
967-
struct vlan_work,
968-
work);
966+
struct vlan_work *one_vlan = CONTAINER_OF(work,
967+
struct vlan_work,
968+
work);
969969
int port;
970970

971-
port = gptp_get_port_number(vlan->iface);
971+
port = gptp_get_port_number(one_vlan->iface);
972972
if (port < 0) {
973-
NET_DBG("No port found for iface %p", vlan->iface);
973+
NET_DBG("No port found for iface %p", one_vlan->iface);
974974
return;
975975
}
976976

subsys/net/l2/ethernet/gptp/gptp_messages.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ static const struct net_eth_addr gptp_multicast_eth_addr = {
2626

2727
#define NET_GPTP_INFO(msg, pkt) \
2828
if (CONFIG_NET_GPTP_LOG_LEVEL >= LOG_LEVEL_DBG) { \
29-
struct gptp_hdr *hdr = GPTP_HDR(pkt); \
29+
struct gptp_hdr *one_hdr = GPTP_HDR(pkt); \
3030
\
31-
if (hdr->message_type == GPTP_ANNOUNCE_MESSAGE) { \
31+
if (one_hdr->message_type == GPTP_ANNOUNCE_MESSAGE) { \
3232
struct gptp_announce *ann = GPTP_ANNOUNCE(pkt); \
3333
char output[sizeof("xx:xx:xx:xx:xx:xx:xx:xx")]; \
3434
\
@@ -39,7 +39,7 @@ static const struct net_eth_addr gptp_multicast_eth_addr = {
3939
\
4040
NET_DBG("Sending %s seq %d pkt %p", \
4141
msg, \
42-
ntohs(hdr->sequence_id), pkt); \
42+
ntohs(one_hdr->sequence_id), pkt); \
4343
\
4444
NET_DBG(" GM %d/%d/0x%x/%d/%s",\
4545
ann->root_system_id.grand_master_prio1, \
@@ -50,7 +50,7 @@ static const struct net_eth_addr gptp_multicast_eth_addr = {
5050
} else { \
5151
NET_DBG("Sending %s seq %d pkt %p", \
5252
msg, \
53-
ntohs(hdr->sequence_id), pkt); \
53+
ntohs(one_hdr->sequence_id), pkt); \
5454
} \
5555
}
5656

subsys/net/l2/ethernet/lldp/lldp.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static int lldp_start(struct net_if *iface, uint32_t mgmt_event)
267267
enum net_verdict net_lldp_recv(struct net_if *iface, struct net_pkt *pkt)
268268
{
269269
struct ethernet_context *ctx;
270-
net_lldp_recv_cb_t cb;
270+
net_lldp_recv_cb_t recv_cb;
271271
int ret;
272272

273273
ret = lldp_check_iface(iface);
@@ -282,15 +282,15 @@ enum net_verdict net_lldp_recv(struct net_if *iface, struct net_pkt *pkt)
282282
return NET_DROP;
283283
}
284284

285-
cb = ctx->lldp[ret].cb;
286-
if (cb) {
287-
return cb(iface, pkt);
285+
recv_cb = ctx->lldp[ret].cb;
286+
if (recv_cb) {
287+
return recv_cb(iface, pkt);
288288
}
289289

290290
return NET_DROP;
291291
}
292292

293-
int net_lldp_register_callback(struct net_if *iface, net_lldp_recv_cb_t cb)
293+
int net_lldp_register_callback(struct net_if *iface, net_lldp_recv_cb_t recv_cb)
294294
{
295295
struct ethernet_context *ctx;
296296
int ret;
@@ -307,12 +307,12 @@ int net_lldp_register_callback(struct net_if *iface, net_lldp_recv_cb_t cb)
307307
return ret;
308308
}
309309

310-
ctx->lldp[ret].cb = cb;
310+
ctx->lldp[ret].cb = recv_cb;
311311

312312
return 0;
313313
}
314314

315-
static void iface_event_handler(struct net_mgmt_event_callback *cb,
315+
static void iface_event_handler(struct net_mgmt_event_callback *evt_cb,
316316
uint32_t mgmt_event, struct net_if *iface)
317317
{
318318
lldp_start(iface, mgmt_event);

subsys/net/l2/ieee802154/ieee802154_6lo_fragment.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,16 @@ static inline void clear_reass_cache(uint16_t size, uint16_t tag)
284284
static void reass_timeout(struct k_work *work)
285285
{
286286
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
287-
struct frag_cache *cache = CONTAINER_OF(dwork, struct frag_cache, timer);
287+
struct frag_cache *fcache = CONTAINER_OF(dwork, struct frag_cache, timer);
288288

289-
if (cache->pkt) {
290-
net_pkt_unref(cache->pkt);
289+
if (fcache->pkt) {
290+
net_pkt_unref(fcache->pkt);
291291
}
292292

293-
cache->pkt = NULL;
294-
cache->size = 0U;
295-
cache->tag = 0U;
296-
cache->used = false;
293+
fcache->pkt = NULL;
294+
fcache->size = 0U;
295+
fcache->tag = 0U;
296+
fcache->used = false;
297297
}
298298

299299
/**
@@ -481,7 +481,7 @@ static inline bool fragment_packet_valid(struct net_pkt *pkt)
481481
static inline enum net_verdict fragment_add_to_cache(struct net_pkt *pkt)
482482
{
483483
bool first_frag = false;
484-
struct frag_cache *cache;
484+
struct frag_cache *fcache;
485485
struct net_buf *frag;
486486
uint16_t size;
487487
uint16_t tag;
@@ -506,10 +506,10 @@ static inline enum net_verdict fragment_add_to_cache(struct net_pkt *pkt)
506506
*/
507507
pkt->buffer = NULL;
508508

509-
cache = get_reass_cache(size, tag);
510-
if (!cache) {
511-
cache = set_reass_cache(pkt, size, tag);
512-
if (!cache) {
509+
fcache = get_reass_cache(size, tag);
510+
if (!fcache) {
511+
fcache = set_reass_cache(pkt, size, tag);
512+
if (!fcache) {
513513
NET_ERR("Could not get a cache entry");
514514
pkt->buffer = frag;
515515
return NET_DROP;
@@ -518,18 +518,18 @@ static inline enum net_verdict fragment_add_to_cache(struct net_pkt *pkt)
518518
first_frag = true;
519519
}
520520

521-
fragment_append(cache->pkt, frag);
521+
fragment_append(fcache->pkt, frag);
522522

523-
if (fragment_cached_pkt_len(cache->pkt) == cache->size) {
523+
if (fragment_cached_pkt_len(fcache->pkt) == fcache->size) {
524524
if (!first_frag) {
525525
/* Assign buffer back to input packet. */
526-
pkt->buffer = cache->pkt->buffer;
527-
cache->pkt->buffer = NULL;
526+
pkt->buffer = fcache->pkt->buffer;
527+
fcache->pkt->buffer = NULL;
528528
} else {
529-
/* in case pkt == cache->pkt, we don't want
529+
/* in case pkt == fcache->pkt, we don't want
530530
* to unref it while clearing the cach.
531531
*/
532-
cache->pkt = NULL;
532+
fcache->pkt = NULL;
533533
}
534534

535535
clear_reass_cache(size, tag);

0 commit comments

Comments
 (0)