summaryrefslogtreecommitdiffstats
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/keychain.c2
-rw-r--r--lib/routemap.c12
-rw-r--r--lib/sockunion.c2
-rw-r--r--lib/table.c4
-rw-r--r--lib/vty.c6
5 files changed, 13 insertions, 13 deletions
diff --git a/lib/keychain.c b/lib/keychain.c
index c29c45a11..5dcb572a3 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -542,7 +542,7 @@ static time_t key_str2time(const char *time_str, const char *day_str,
/* Check year_str. Year must be <1993-2035>. */
GET_LONG_RANGE(year, year_str, 1993, 2035);
- memset(&tm, 0, sizeof(struct tm));
+ memset(&tm, 0, sizeof(tm));
tm.tm_sec = sec;
tm.tm_min = min;
tm.tm_hour = hour;
diff --git a/lib/routemap.c b/lib/routemap.c
index 46161fd81..722693ea2 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -759,7 +759,7 @@ struct route_map *route_map_lookup_by_name(const char *name)
return NULL;
// map.deleted is false via memset
- memset(&tmp_map, 0, sizeof(struct route_map));
+ memset(&tmp_map, 0, sizeof(tmp_map));
tmp_map.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, name);
map = hash_lookup(route_map_master_hash, &tmp_map);
XFREE(MTYPE_ROUTE_MAP_NAME, tmp_map.name);
@@ -797,7 +797,7 @@ int route_map_mark_updated(const char *name)
* with deleted=true
*/
if (!map) {
- memset(&tmp_map, 0, sizeof(struct route_map));
+ memset(&tmp_map, 0, sizeof(tmp_map));
tmp_map.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, name);
tmp_map.deleted = true;
map = hash_lookup(route_map_master_hash, &tmp_map);
@@ -2481,7 +2481,7 @@ void route_map_notify_pentry_dependencies(const char *affected_name,
if (!dep->this_hash)
dep->this_hash = upd8_hash;
- memset(&pentry_dep, 0, sizeof(struct route_map_pentry_dep));
+ memset(&pentry_dep, 0, sizeof(pentry_dep));
pentry_dep.pentry = pentry;
pentry_dep.plist_name = affected_name;
pentry_dep.event = event;
@@ -2760,7 +2760,7 @@ static void route_map_clear_reference(struct hash_bucket *bucket, void *arg)
struct route_map_dep *dep = bucket->data;
struct route_map_dep_data *dep_data = NULL, tmp_dep_data;
- memset(&tmp_dep_data, 0, sizeof(struct route_map_dep_data));
+ memset(&tmp_dep_data, 0, sizeof(tmp_dep_data));
tmp_dep_data.rname = arg;
dep_data = hash_release(dep->dep_rmap_hash, &tmp_dep_data);
if (dep_data) {
@@ -2873,7 +2873,7 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name,
if (!dep->this_hash)
dep->this_hash = dephash;
- memset(&tmp_dep_data, 0, sizeof(struct route_map_dep_data));
+ memset(&tmp_dep_data, 0, sizeof(tmp_dep_data));
tmp_dep_data.rname = rname;
dep_data = hash_lookup(dep->dep_rmap_hash, &tmp_dep_data);
if (!dep_data)
@@ -2897,7 +2897,7 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name,
goto out;
}
- memset(&tmp_dep_data, 0, sizeof(struct route_map_dep_data));
+ memset(&tmp_dep_data, 0, sizeof(tmp_dep_data));
tmp_dep_data.rname = rname;
dep_data = hash_lookup(dep->dep_rmap_hash, &tmp_dep_data);
/*
diff --git a/lib/sockunion.c b/lib/sockunion.c
index 9763b38e2..97b198c01 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -107,7 +107,7 @@ static void sockunion_normalise_mapped(union sockunion *su)
if (su->sa.sa_family == AF_INET6
&& IN6_IS_ADDR_V4MAPPED(&su->sin6.sin6_addr)) {
- memset(&sin, 0, sizeof(struct sockaddr_in));
+ memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = su->sin6.sin6_port;
memcpy(&sin.sin_addr, ((char *)&su->sin6.sin6_addr) + 12, 4);
diff --git a/lib/table.c b/lib/table.c
index 523183bef..6c4c6c7d3 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -228,7 +228,7 @@ struct route_node *route_node_match_ipv4(struct route_table *table,
{
struct prefix_ipv4 p;
- memset(&p, 0, sizeof(struct prefix_ipv4));
+ memset(&p, 0, sizeof(p));
p.family = AF_INET;
p.prefixlen = IPV4_MAX_BITLEN;
p.prefix = *addr;
@@ -241,7 +241,7 @@ struct route_node *route_node_match_ipv6(struct route_table *table,
{
struct prefix_ipv6 p;
- memset(&p, 0, sizeof(struct prefix_ipv6));
+ memset(&p, 0, sizeof(p));
p.family = AF_INET6;
p.prefixlen = IPV6_MAX_BITLEN;
p.prefix = *addr;
diff --git a/lib/vty.c b/lib/vty.c
index 619d51e1c..e0e2f3922 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1827,7 +1827,7 @@ static void vty_serv_sock_addrinfo(const char *hostname, unsigned short port)
int sock;
char port_str[BUFSIZ];
- memset(&req, 0, sizeof(struct addrinfo));
+ memset(&req, 0, sizeof(req));
req.ai_flags = AI_PASSIVE;
req.ai_family = AF_UNSPEC;
req.ai_socktype = SOCK_STREAM;
@@ -1912,7 +1912,7 @@ static void vty_serv_un(const char *path)
}
/* Make server socket. */
- memset(&serv, 0, sizeof(struct sockaddr_un));
+ memset(&serv, 0, sizeof(serv));
serv.sun_family = AF_UNIX;
strlcpy(serv.sun_path, path, sizeof(serv.sun_path));
#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
@@ -1976,7 +1976,7 @@ static void vtysh_accept(struct thread *thread)
vty_event_serv(VTYSH_SERV, vtyserv);
- memset(&client, 0, sizeof(struct sockaddr_un));
+ memset(&client, 0, sizeof(client));
client_len = sizeof(struct sockaddr_un);
sock = accept(accept_sock, (struct sockaddr *)&client,