summaryrefslogtreecommitdiff
path: root/src/udev/net/ethtool-util.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-02-21 21:32:38 +0100
committerTom Gundersen <teg@jklm.no>2014-02-21 21:32:38 +0100
commit6c0519c01288d0d97bece15da3dbb9934f018949 (patch)
treeb723c6c589f6306c4114765edc05d12ef974ec61 /src/udev/net/ethtool-util.c
parent61f3af4fed2f0d2686bd7ae4cd22bc3e973ddeca (diff)
net: initialize structs when declaring
Diffstat (limited to 'src/udev/net/ethtool-util.c')
-rw-r--r--src/udev/net/ethtool-util.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c
index 18d44fc968..6346530323 100644
--- a/src/udev/net/ethtool-util.c
+++ b/src/udev/net/ethtool-util.c
@@ -89,20 +89,19 @@ int ethtool_get_driver(int fd, const char *ifname, char **ret) {
int ethtool_set_speed(int fd, const char *ifname, unsigned int speed, Duplex duplex)
{
- struct ifreq ifr;
- struct ethtool_cmd ecmd;
+ struct ethtool_cmd ecmd = {
+ .cmd = ETHTOOL_GSET
+ };
+ struct ifreq ifr = {
+ .ifr_data = (void*) &ecmd
+ };
bool need_update = false;
int r;
if (speed == 0 && duplex == _DUP_INVALID)
return 0;
- zero(ecmd);
- ecmd.cmd = ETHTOOL_GSET;
-
- zero(ifr);
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- ifr.ifr_data = (void *)&ecmd;
r = ioctl(fd, SIOCETHTOOL, &ifr);
if (r < 0)
@@ -142,20 +141,19 @@ int ethtool_set_speed(int fd, const char *ifname, unsigned int speed, Duplex dup
}
int ethtool_set_wol(int fd, const char *ifname, WakeOnLan wol) {
- struct ifreq ifr;
- struct ethtool_wolinfo ecmd;
+ struct ethtool_wolinfo ecmd = {
+ .cmd = ETHTOOL_GWOL
+ };
+ struct ifreq ifr = {
+ .ifr_data = (void*) &ecmd
+ };
bool need_update = false;
int r;
if (wol == _WOL_INVALID)
return 0;
- zero(ecmd);
- ecmd.cmd = ETHTOOL_GWOL;
-
- zero(ifr);
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- ifr.ifr_data = (void *)&ecmd;
r = ioctl(fd, SIOCETHTOOL, &ifr);
if (r < 0)