From b116fa3e1a3fde7d4957ece11e97b6eec716bdb4 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 15 Oct 2024 21:05:14 +0200 Subject: [PATCH] daemon: fix usage of calloc First argument is the number of elements to allocate. --- src/daemon/interfaces-linux.c | 4 ++-- src/daemon/netlink.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/daemon/interfaces-linux.c b/src/daemon/interfaces-linux.c index 2ee2823f..1bf6003d 100644 --- a/src/daemon/interfaces-linux.c +++ b/src/daemon/interfaces-linux.c @@ -256,7 +256,7 @@ iflinux_get_permanent_mac_ethtool(struct lldpd *cfg, int ret = -1; struct ifreq ifr = {}; struct ethtool_perm_addr *epaddr = - calloc(sizeof(struct ethtool_perm_addr) + ETHER_ADDR_LEN, 1); + calloc(1, sizeof(struct ethtool_perm_addr) + ETHER_ADDR_LEN); if (epaddr == NULL) goto end; strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name)); @@ -390,7 +390,7 @@ iflinux_get_permanent_mac(struct lldpd *cfg, struct interfaces_device_list *inte #ifdef ENABLE_DOT3 # define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX) # define ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ - uint32_t name[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32] + uint32_t name[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32] struct ethtool_link_usettings { struct ethtool_link_settings base; diff --git a/src/daemon/netlink.c b/src/daemon/netlink.c index 36c1cfd4..f8b39f9e 100644 --- a/src/daemon/netlink.c +++ b/src/daemon/netlink.c @@ -352,7 +352,7 @@ netlink_parse_link(struct nlmsghdr *msg, struct interfaces_device *iff) iff->upper_idx = -1; for (attribute = IFLA_RTA(ifi); RTA_OK(attribute, len); - attribute = RTA_NEXT(attribute, len)) { + attribute = RTA_NEXT(attribute, len)) { switch (attribute->rta_type) { case IFLA_IFNAME: /* Interface name */ @@ -470,7 +470,7 @@ netlink_parse_address(struct nlmsghdr *msg, struct interfaces_address *ifa) } for (attribute = IFA_RTA(ifi); RTA_OK(attribute, len); - attribute = RTA_NEXT(attribute, len)) { + attribute = RTA_NEXT(attribute, len)) { switch (attribute->rta_type) { case IFA_ADDRESS: /* Address */ @@ -642,7 +642,7 @@ netlink_recv(struct lldpd *cfg, int s, struct interfaces_device_list *ifs, } for (msg = (struct nlmsghdr *)(void *)(iov.iov_base); - NLMSG_OK(msg, len); msg = NLMSG_NEXT(msg, len)) { + NLMSG_OK(msg, len); msg = NLMSG_NEXT(msg, len)) { if (!(msg->nlmsg_flags & NLM_F_MULTI)) end = 1; switch (msg->nlmsg_type) { case NLMSG_DONE: @@ -890,7 +890,7 @@ netlink_initialize(struct lldpd *cfg) if (cfg->g_netlink) return 0; log_debug("netlink", "initialize netlink subsystem"); - if ((cfg->g_netlink = calloc(sizeof(struct lldpd_netlink), 1)) == NULL) { + if ((cfg->g_netlink = calloc(1, sizeof(struct lldpd_netlink))) == NULL) { log_warn("netlink", "unable to allocate memory for netlink subsystem"); goto end; } -- 2.39.5