summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-06-17 14:57:54 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-06-19 23:15:13 +0900
commitb9bc7d42e3e79fcfd44145d2984017ca66aebde1 (patch)
treefe344e188ee7ebf6fbce85a6124635cd101df19d
parent5c2316c605b44beb066d6c44db533b124667e725 (diff)
downloadsystemd-b9bc7d42e3e79fcfd44145d2984017ca66aebde1.tar.gz
ethtool-util: use structured initializers
-rw-r--r--src/shared/ethtool-util.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c
index 0b0fb47212..d95363955b 100644
--- a/src/shared/ethtool-util.c
+++ b/src/shared/ethtool-util.c
@@ -453,11 +453,13 @@ static int get_glinksettings(int fd, struct ifreq *ifr, struct ethtool_link_uset
if (ecmd.req.link_mode_masks_nwords <= 0 || ecmd.req.cmd != ETHTOOL_GLINKSETTINGS)
return -EOPNOTSUPP;
- u = new0(struct ethtool_link_usettings , 1);
+ u = new(struct ethtool_link_usettings, 1);
if (!u)
return -ENOMEM;
- u->base = ecmd.req;
+ *u = (struct ethtool_link_usettings) {
+ .base = ecmd.req,
+ };
offset = 0;
memcpy(u->link_modes.supported, &ecmd.link_mode_data[offset], 4 * ecmd.req.link_mode_masks_nwords);
@@ -486,23 +488,24 @@ static int get_gset(int fd, struct ifreq *ifr, struct ethtool_link_usettings **u
if (r < 0)
return -errno;
- e = new0(struct ethtool_link_usettings, 1);
+ e = new(struct ethtool_link_usettings, 1);
if (!e)
return -ENOMEM;
- e->base.cmd = ETHTOOL_GSET;
-
- e->base.link_mode_masks_nwords = 1;
- e->base.speed = ethtool_cmd_speed(&ecmd);
- e->base.duplex = ecmd.duplex;
- e->base.port = ecmd.port;
- e->base.phy_address = ecmd.phy_address;
- e->base.autoneg = ecmd.autoneg;
- e->base.mdio_support = ecmd.mdio_support;
-
- e->link_modes.supported[0] = ecmd.supported;
- e->link_modes.advertising[0] = ecmd.advertising;
- e->link_modes.lp_advertising[0] = ecmd.lp_advertising;
+ *e = (struct ethtool_link_usettings) {
+ .base.cmd = ETHTOOL_GSET,
+ .base.link_mode_masks_nwords = 1,
+ .base.speed = ethtool_cmd_speed(&ecmd),
+ .base.duplex = ecmd.duplex,
+ .base.port = ecmd.port,
+ .base.phy_address = ecmd.phy_address,
+ .base.autoneg = ecmd.autoneg,
+ .base.mdio_support = ecmd.mdio_support,
+
+ .link_modes.supported[0] = ecmd.supported,
+ .link_modes.advertising[0] = ecmd.advertising,
+ .link_modes.lp_advertising[0] = ecmd.lp_advertising,
+ };
*u = e;