summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-21 21:23:40 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-21 21:23:40 +0100
commit61f3af4fed2f0d2686bd7ae4cd22bc3e973ddeca (patch)
treebaa9e5a691e40fd54c1f6c610a36c37c353b4b82 /src/udev
parented4ba7e4f652150310d062ffbdfefb4521ce1054 (diff)
net: initialize structs when declaring them/do not clobber caller variables
Just two minor style fixes...
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/net/ethtool-util.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c
index aaba94c2fb..18d44fc968 100644
--- a/src/udev/net/ethtool-util.c
+++ b/src/udev/net/ethtool-util.c
@@ -64,25 +64,26 @@ int ethtool_connect(int *ret) {
}
int ethtool_get_driver(int fd, const char *ifname, char **ret) {
- struct ifreq ifr;
- struct ethtool_drvinfo ecmd;
+ struct ethtool_drvinfo ecmd = {
+ .cmd = ETHTOOL_GDRVINFO
+ };
+ struct ifreq ifr = {
+ .ifr_data = (void*) &ecmd
+ };
+ char *d;
int r;
- zero(ecmd);
- ecmd.cmd = ETHTOOL_GDRVINFO;
-
- zero(ifr);
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- ifr.ifr_data = (void *)&ecmd;
r = ioctl(fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
- *ret = strdup(ecmd.driver);
- if (!*ret)
+ d = strdup(ecmd.driver);
+ if (!d)
return -ENOMEM;
+ *ret = d;
return 0;
}