Skip to content

Commit

Permalink
subsys/mgmt/mcumgr: Name struct to avoid violation
Browse files Browse the repository at this point in the history
The mcumgr SMP UDP configs struct was causing a unique tag name
violation (rule 5.7).

The struct name has been changed from configs to smp_udp_configs.

Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
  • Loading branch information
besmarsh authored and fabiobaltieri committed Nov 1, 2023
1 parent f9809a0 commit 18a0952
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions subsys/mgmt/mcumgr/transport/src/smp_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct configs {
#endif
};

static struct configs configs;
static struct configs smp_udp_configs;

static struct net_mgmt_event_callback smp_udp_mgmt_cb;

Expand All @@ -108,7 +108,7 @@ static int smp_udp4_tx(struct net_buf *nb)
int ret;
struct sockaddr *addr = net_buf_user_data(nb);

ret = sendto(configs.ipv4.sock, nb->data, nb->len, 0, addr, sizeof(*addr));
ret = sendto(smp_udp_configs.ipv4.sock, nb->data, nb->len, 0, addr, sizeof(*addr));

if (ret < 0) {
ret = MGMT_ERR_EINVAL;
Expand All @@ -128,7 +128,7 @@ static int smp_udp6_tx(struct net_buf *nb)
int ret;
struct sockaddr *addr = net_buf_user_data(nb);

ret = sendto(configs.ipv6.sock, nb->data, nb->len, 0, addr, sizeof(*addr));
ret = sendto(smp_udp_configs.ipv6.sock, nb->data, nb->len, 0, addr, sizeof(*addr));

if (ret < 0) {
ret = MGMT_ERR_EINVAL;
Expand Down Expand Up @@ -275,14 +275,14 @@ static void smp_udp_net_event_handler(struct net_mgmt_event_callback *cb, uint32
if (mgmt_event == NET_EVENT_L4_CONNECTED) {
LOG_INF("Network connected");
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
if (IS_THREAD_RUNNING(configs.ipv4.thread)) {
k_sem_give(&configs.ipv4.network_ready_sem);
if (IS_THREAD_RUNNING(smp_udp_configs.ipv4.thread)) {
k_sem_give(&smp_udp_configs.ipv4.network_ready_sem);
}
#endif

#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
if (IS_THREAD_RUNNING(configs.ipv6.thread)) {
k_sem_give(&configs.ipv6.network_ready_sem);
if (IS_THREAD_RUNNING(smp_udp_configs.ipv6.thread)) {
k_sem_give(&smp_udp_configs.ipv6.network_ready_sem);
}
#endif
} else if (mgmt_event == NET_EVENT_L4_DISCONNECTED) {
Expand All @@ -306,19 +306,19 @@ int smp_udp_open(void)
bool started = false;

#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
if (!IS_THREAD_RUNNING(configs.ipv4.thread)) {
(void)k_sem_reset(&configs.ipv4.network_ready_sem);
create_thread(&configs.ipv4, "smp_udp4");
if (!IS_THREAD_RUNNING(smp_udp_configs.ipv4.thread)) {
(void)k_sem_reset(&smp_udp_configs.ipv4.network_ready_sem);
create_thread(&smp_udp_configs.ipv4, "smp_udp4");
started = true;
} else {
LOG_ERR("IPv4 UDP MCUmgr thread is already running");
}
#endif

#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
if (!IS_THREAD_RUNNING(configs.ipv6.thread)) {
(void)k_sem_reset(&configs.ipv6.network_ready_sem);
create_thread(&configs.ipv6, "smp_udp6");
if (!IS_THREAD_RUNNING(smp_udp_configs.ipv6.thread)) {
(void)k_sem_reset(&smp_udp_configs.ipv6.network_ready_sem);
create_thread(&smp_udp_configs.ipv6, "smp_udp6");
started = true;
} else {
LOG_ERR("IPv6 UDP MCUmgr thread is already running");
Expand All @@ -336,25 +336,25 @@ int smp_udp_open(void)
int smp_udp_close(void)
{
#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
if (IS_THREAD_RUNNING(configs.ipv4.thread)) {
k_thread_abort(&(configs.ipv4.thread));
if (IS_THREAD_RUNNING(smp_udp_configs.ipv4.thread)) {
k_thread_abort(&(smp_udp_configs.ipv4.thread));

if (configs.ipv4.sock >= 0) {
close(configs.ipv4.sock);
configs.ipv4.sock = -1;
if (smp_udp_configs.ipv4.sock >= 0) {
close(smp_udp_configs.ipv4.sock);
smp_udp_configs.ipv4.sock = -1;
}
} else {
LOG_ERR("IPv4 UDP MCUmgr thread is not running");
}
#endif

#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
if (IS_THREAD_RUNNING(configs.ipv6.thread)) {
k_thread_abort(&(configs.ipv6.thread));
if (IS_THREAD_RUNNING(smp_udp_configs.ipv6.thread)) {
k_thread_abort(&(smp_udp_configs.ipv6.thread));

if (configs.ipv6.sock >= 0) {
close(configs.ipv6.sock);
configs.ipv6.sock = -1;
if (smp_udp_configs.ipv6.sock >= 0) {
close(smp_udp_configs.ipv6.sock);
smp_udp_configs.ipv6.sock = -1;
}
} else {
LOG_ERR("IPv6 UDP MCUmgr thread is not running");
Expand All @@ -369,20 +369,20 @@ static void smp_udp_start(void)
int rc;

#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV4
configs.ipv4.proto = PROTOCOL_IPV4;
configs.ipv4.sock = -1;
smp_udp_configs.ipv4.proto = PROTOCOL_IPV4;
smp_udp_configs.ipv4.sock = -1;

k_sem_init(&configs.ipv4.network_ready_sem, 0, 1);
configs.ipv4.smp_transport.functions.output = smp_udp4_tx;
configs.ipv4.smp_transport.functions.get_mtu = smp_udp_get_mtu;
configs.ipv4.smp_transport.functions.ud_copy = smp_udp_ud_copy;
k_sem_init(&smp_udp_configs.ipv4.network_ready_sem, 0, 1);
smp_udp_configs.ipv4.smp_transport.functions.output = smp_udp4_tx;
smp_udp_configs.ipv4.smp_transport.functions.get_mtu = smp_udp_get_mtu;
smp_udp_configs.ipv4.smp_transport.functions.ud_copy = smp_udp_ud_copy;

rc = smp_transport_init(&configs.ipv4.smp_transport);
rc = smp_transport_init(&smp_udp_configs.ipv4.smp_transport);
#ifdef CONFIG_SMP_CLIENT
if (rc == 0) {
configs.ipv4_transport.smpt = &configs.ipv4.smp_transport;
configs.ipv4_transport.smpt_type = SMP_UDP_IPV4_TRANSPORT;
smp_client_transport_register(&configs.ipv4_transport);
smp_udp_configs.ipv4_transport.smpt = &smp_udp_configs.ipv4.smp_transport;
smp_udp_configs.ipv4_transport.smpt_type = SMP_UDP_IPV4_TRANSPORT;
smp_client_transport_register(&smp_udp_configs.ipv4_transport);
}
#endif
if (rc) {
Expand All @@ -391,20 +391,20 @@ static void smp_udp_start(void)
#endif

#ifdef CONFIG_MCUMGR_TRANSPORT_UDP_IPV6
configs.ipv6.proto = PROTOCOL_IPV6;
configs.ipv6.sock = -1;
smp_udp_configs.ipv6.proto = PROTOCOL_IPV6;
smp_udp_configs.ipv6.sock = -1;

k_sem_init(&configs.ipv6.network_ready_sem, 0, 1);
configs.ipv6.smp_transport.functions.output = smp_udp6_tx;
configs.ipv6.smp_transport.functions.get_mtu = smp_udp_get_mtu;
configs.ipv6.smp_transport.functions.ud_copy = smp_udp_ud_copy;
k_sem_init(&smp_udp_configs.ipv6.network_ready_sem, 0, 1);
smp_udp_configs.ipv6.smp_transport.functions.output = smp_udp6_tx;
smp_udp_configs.ipv6.smp_transport.functions.get_mtu = smp_udp_get_mtu;
smp_udp_configs.ipv6.smp_transport.functions.ud_copy = smp_udp_ud_copy;

rc = smp_transport_init(&configs.ipv6.smp_transport);
rc = smp_transport_init(&smp_udp_configs.ipv6.smp_transport);
#ifdef CONFIG_SMP_CLIENT
if (rc == 0) {
configs.ipv6_transport.smpt = &configs.ipv6.smp_transport;
configs.ipv6_transport.smpt_type = SMP_UDP_IPV6_TRANSPORT;
smp_client_transport_register(&configs.ipv6_transport);
smp_udp_configs.ipv6_transport.smpt = &smp_udp_configs.ipv6.smp_transport;
smp_udp_configs.ipv6_transport.smpt_type = SMP_UDP_IPV6_TRANSPORT;
smp_client_transport_register(&smp_udp_configs.ipv6_transport);
}
#endif

Expand Down

0 comments on commit 18a0952

Please sign in to comment.