sources: Fully initialize structs
Some of our declarations only initialize part of a struct or value, use
an empty initializer statement to fully initialize them. For some with
non-default values, make sure the other values in the struct are
populated.
Change-Id: Ieee9126267ad318fde071a231aa33bb52501b15f
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 2de60e4..ce424ff 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -357,13 +357,13 @@
*/
InterfaceInfo EthernetInterface::getInterfaceInfo() const
{
- ifreq ifr{0};
- ethtool_cmd edata{0};
- LinkSpeed speed{0};
- Autoneg autoneg{0};
- DuplexMode duplex{0};
- LinkUp linkState{false};
- NICEnabled enabled{false};
+ ifreq ifr = {};
+ ethtool_cmd edata = {};
+ LinkSpeed speed = {};
+ Autoneg autoneg = {};
+ DuplexMode duplex = {};
+ LinkUp linkState = {};
+ NICEnabled enabled = {};
EthernetIntfSocket eifSocket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
if (eifSocket.sock < 0)
@@ -404,7 +404,7 @@
return activeMACAddr;
}
- ifreq ifr{0};
+ ifreq ifr = {};
std::strncpy(ifr.ifr_name, interfaceName.c_str(), IFNAMSIZ - 1);
if (ioctl(eifSocket.sock, SIOCGIFHWADDR, &ifr) != 0)
{
@@ -579,7 +579,7 @@
return value;
}
- ifreq ifr{0};
+ ifreq ifr = {};
std::strncpy(ifr.ifr_name, interfaceName().c_str(), IF_NAMESIZE - 1);
if (ioctl(eifSocket.sock, SIOCGIFFLAGS, &ifr) == 0)
{
@@ -603,7 +603,7 @@
return value;
}
- ifreq ifr{0};
+ ifreq ifr = {};
std::strncpy(ifr.ifr_name, interfaceName().c_str(), IF_NAMESIZE - 1);
if (ioctl(eifSocket.sock, SIOCGIFFLAGS, &ifr) == 0)
{
@@ -630,7 +630,7 @@
return EthernetInterfaceIntf::nicEnabled();
}
- ifreq ifr{0};
+ ifreq ifr = {};
std::strncpy(ifr.ifr_name, interfaceName().c_str(), IF_NAMESIZE - 1);
if (ioctl(eifSocket.sock, SIOCGIFFLAGS, &ifr) != 0)
{
diff --git a/ncsi_util.cpp b/ncsi_util.cpp
index 4c5d6ac..902911d 100644
--- a/ncsi_util.cpp
+++ b/ncsi_util.cpp
@@ -34,20 +34,20 @@
struct nlattr* tb[NCSI_ATTR_MAX + 1] = {nullptr};
struct nla_policy ncsiPolicy[NCSI_ATTR_MAX + 1] = {
- {type : NLA_UNSPEC}, {type : NLA_U32}, {type : NLA_NESTED},
- {type : NLA_U32}, {type : NLA_U32},
+ {NLA_UNSPEC, 0, 0}, {NLA_U32, 0, 0}, {NLA_NESTED, 0, 0},
+ {NLA_U32, 0, 0}, {NLA_U32, 0, 0},
};
struct nlattr* packagetb[NCSI_PKG_ATTR_MAX + 1] = {nullptr};
struct nla_policy packagePolicy[NCSI_PKG_ATTR_MAX + 1] = {
- {type : NLA_UNSPEC}, {type : NLA_NESTED}, {type : NLA_U32},
- {type : NLA_FLAG}, {type : NLA_NESTED},
+ {NLA_UNSPEC, 0, 0}, {NLA_NESTED, 0, 0}, {NLA_U32, 0, 0},
+ {NLA_FLAG, 0, 0}, {NLA_NESTED, 0, 0},
};
struct nlattr* channeltb[NCSI_CHANNEL_ATTR_MAX + 1] = {nullptr};
struct nla_policy channelPolicy[NCSI_CHANNEL_ATTR_MAX + 1] = {
- {type : NLA_UNSPEC}, {type : NLA_NESTED}, {type : NLA_U32},
- {type : NLA_FLAG}, {type : NLA_NESTED}, {type : NLA_UNSPEC},
+ {NLA_UNSPEC, 0, 0}, {NLA_NESTED, 0, 0}, {NLA_U32, 0, 0},
+ {NLA_FLAG, 0, 0}, {NLA_NESTED, 0, 0}, {NLA_UNSPEC, 0, 0},
};
auto ret = genlmsg_parse(nlh, 0, tb, NCSI_ATTR_MAX, ncsiPolicy);