summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2022-05-11 12:16:44 +0200
committerDonatas Abraitis <donatas@opensourcerouting.org>2022-05-11 13:08:47 +0200
commit6006b807b1a84d31611173b837fafcd96ba9d692 (patch)
tree08f25453328d8c408f1a8c658e4e6ef91005d4a7 /ripd
parentripd: Use correct usage of memcpy() when zeroing struct (diff)
downloadfrr-6006b807b1a84d31611173b837fafcd96ba9d692.tar.xz
frr-6006b807b1a84d31611173b837fafcd96ba9d692.zip
*: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_interface.c2
-rw-r--r--ripd/rip_nb_config.c2
-rw-r--r--ripd/rip_snmp.c6
-rw-r--r--ripd/ripd.c10
4 files changed, 10 insertions, 10 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 042c9713b..7ac37b7ee 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -929,7 +929,7 @@ int rip_neighbor_lookup(struct rip *rip, struct sockaddr_in *from)
struct prefix_ipv4 p;
struct route_node *node;
- memset(&p, 0, sizeof(struct prefix_ipv4));
+ memset(&p, 0, sizeof(p));
p.family = AF_INET;
p.prefix = from->sin_addr;
p.prefixlen = IPV4_MAX_BITLEN;
diff --git a/ripd/rip_nb_config.c b/ripd/rip_nb_config.c
index c640ca27a..5b1917e17 100644
--- a/ripd/rip_nb_config.c
+++ b/ripd/rip_nb_config.c
@@ -132,7 +132,7 @@ int ripd_instance_default_information_originate_modify(
rip = nb_running_get_entry(args->dnode, NULL, true);
default_information = yang_dnode_get_bool(args->dnode, NULL);
- memset(&p, 0, sizeof(struct prefix_ipv4));
+ memset(&p, 0, sizeof(p));
p.family = AF_INET;
if (default_information) {
struct nexthop nh;
diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c
index 436dc4de0..0ce380406 100644
--- a/ripd/rip_snmp.c
+++ b/ripd/rip_snmp.c
@@ -356,7 +356,7 @@ static uint8_t *rip2IfStatEntry(struct variable *v, oid name[], size_t *length,
== MATCH_FAILED)
return NULL;
- memset(&addr, 0, sizeof(struct in_addr));
+ memset(&addr, 0, sizeof(addr));
/* Lookup interface. */
ifp = rip2IfLookup(v, name, length, &addr, exact);
@@ -457,7 +457,7 @@ static uint8_t *rip2IfConfAddress(struct variable *v, oid name[],
== MATCH_FAILED)
return NULL;
- memset(&addr, 0, sizeof(struct in_addr));
+ memset(&addr, 0, sizeof(addr));
/* Lookup interface. */
ifp = rip2IfLookup(v, name, length, &addr, exact);
@@ -529,7 +529,7 @@ static uint8_t *rip2PeerTable(struct variable *v, oid name[], size_t *length,
== MATCH_FAILED)
return NULL;
- memset(&addr, 0, sizeof(struct in_addr));
+ memset(&addr, 0, sizeof(addr));
/* Lookup interface. */
peer = rip2PeerLookup(v, name, length, &addr, exact);
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 74a06b689..cc21c0bd6 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -1475,7 +1475,7 @@ static int rip_send_packet(uint8_t *buf, int size, struct sockaddr_in *to,
}
/* Make destination address. */
- memset(&sin, 0, sizeof(struct sockaddr_in));
+ memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
sin.sin_len = sizeof(struct sockaddr_in);
@@ -1543,7 +1543,7 @@ void rip_redistribute_add(struct rip *rip, int type, int sub_type,
rp = route_node_get(rip->table, (struct prefix *)p);
- memset(&newinfo, 0, sizeof(struct rip_info));
+ memset(&newinfo, 0, sizeof(newinfo));
newinfo.type = type;
newinfo.sub_type = sub_type;
newinfo.metric = 1;
@@ -1737,7 +1737,7 @@ static void rip_read(struct thread *t)
rip_event(rip, RIP_READ, sock);
/* RIPd manages only IPv4. */
- memset(&from, 0, sizeof(struct sockaddr_in));
+ memset(&from, 0, sizeof(from));
fromlen = sizeof(struct sockaddr_in);
len = recvfrom(sock, (char *)&rip_buf.buf, sizeof(rip_buf.buf), 0,
@@ -2384,7 +2384,7 @@ static void rip_update_interface(struct connected *ifc, uint8_t version,
if (if_is_broadcast(ifp) || if_is_pointopoint(ifp)) {
if (ifc->address->family == AF_INET) {
/* Destination address and port setting. */
- memset(&to, 0, sizeof(struct sockaddr_in));
+ memset(&to, 0, sizeof(to));
if (ifc->destination)
/* use specified broadcast or peer destination
* addr */
@@ -2833,7 +2833,7 @@ uint8_t rip_distance_apply(struct rip *rip, struct rip_info *rinfo)
struct rip_distance *rdistance;
struct access_list *alist;
- memset(&p, 0, sizeof(struct prefix_ipv4));
+ memset(&p, 0, sizeof(p));
p.family = AF_INET;
p.prefix = rinfo->from;
p.prefixlen = IPV4_MAX_BITLEN;