ethtool-util: don't pass fds as pointers if we don't have to

Passing them as pointers is just weird, hence don't do it
This commit is contained in:
Lennart Poettering 2018-01-05 13:36:38 +01:00
parent 20d4e99524
commit 2b44daaa20
1 changed files with 18 additions and 17 deletions

View File

@ -83,6 +83,7 @@ int ethtool_connect(int *ret) {
fd = socket_ioctl_fd();
if (fd < 0)
return fd;
*ret = fd;
return 0;
@ -265,7 +266,7 @@ int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol) {
return 0;
}
static int ethtool_get_stringset(int *fd, struct ifreq *ifr, int stringset_id, struct ethtool_gstrings **gstrings) {
static int get_stringset(int fd, struct ifreq *ifr, int stringset_id, struct ethtool_gstrings **gstrings) {
_cleanup_free_ struct ethtool_gstrings *strings = NULL;
struct {
struct ethtool_sset_info info;
@ -281,7 +282,7 @@ static int ethtool_get_stringset(int *fd, struct ifreq *ifr, int stringset_id, s
ifr->ifr_data = (void *) &buffer.info;
r = ioctl(*fd, SIOCETHTOOL, ifr);
r = ioctl(fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
@ -300,7 +301,7 @@ static int ethtool_get_stringset(int *fd, struct ifreq *ifr, int stringset_id, s
ifr->ifr_data = (void *) strings;
r = ioctl(*fd, SIOCETHTOOL, ifr);
r = ioctl(fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
@ -335,7 +336,7 @@ int ethtool_set_features(int *fd, const char *ifname, NetDevFeature *features) {
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
r = ethtool_get_stringset(fd, &ifr, ETH_SS_FEATURES, &strings);
r = get_stringset(*fd, &ifr, ETH_SS_FEATURES, &strings);
if (r < 0)
return log_warning_errno(r, "link_config: could not get ethtool features for %s", ifname);
@ -374,7 +375,7 @@ int ethtool_set_features(int *fd, const char *ifname, NetDevFeature *features) {
return 0;
}
static int get_glinksettings(int *fd, struct ifreq *ifr, struct ethtool_link_usettings **g) {
static int get_glinksettings(int fd, struct ifreq *ifr, struct ethtool_link_usettings **g) {
struct ecmd {
struct ethtool_link_settings req;
__u32 link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
@ -395,7 +396,7 @@ static int get_glinksettings(int *fd, struct ifreq *ifr, struct ethtool_link_use
ifr->ifr_data = (void *) &ecmd;
r = ioctl(*fd, SIOCETHTOOL, ifr);
r = ioctl(fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
@ -406,7 +407,7 @@ static int get_glinksettings(int *fd, struct ifreq *ifr, struct ethtool_link_use
ifr->ifr_data = (void *) &ecmd;
r = ioctl(*fd, SIOCETHTOOL, ifr);
r = ioctl(fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
@ -433,7 +434,7 @@ static int get_glinksettings(int *fd, struct ifreq *ifr, struct ethtool_link_use
return 0;
}
static int get_gset(int *fd, struct ifreq *ifr, struct ethtool_link_usettings **u) {
static int get_gset(int fd, struct ifreq *ifr, struct ethtool_link_usettings **u) {
struct ethtool_link_usettings *e;
struct ethtool_cmd ecmd = {
.cmd = ETHTOOL_GSET,
@ -442,7 +443,7 @@ static int get_gset(int *fd, struct ifreq *ifr, struct ethtool_link_usettings **
ifr->ifr_data = (void *) &ecmd;
r = ioctl(*fd, SIOCETHTOOL, ifr);
r = ioctl(fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
@ -469,7 +470,7 @@ static int get_gset(int *fd, struct ifreq *ifr, struct ethtool_link_usettings **
return 0;
}
static int set_slinksettings(int *fd, struct ifreq *ifr, const struct ethtool_link_usettings *u) {
static int set_slinksettings(int fd, struct ifreq *ifr, const struct ethtool_link_usettings *u) {
struct {
struct ethtool_link_settings req;
__u32 link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
@ -493,14 +494,14 @@ static int set_slinksettings(int *fd, struct ifreq *ifr, const struct ethtool_li
ifr->ifr_data = (void *) &ecmd;
r = ioctl(*fd, SIOCETHTOOL, ifr);
r = ioctl(fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
return 0;
}
static int set_sset(int *fd, struct ifreq *ifr, const struct ethtool_link_usettings *u) {
static int set_sset(int fd, struct ifreq *ifr, const struct ethtool_link_usettings *u) {
struct ethtool_cmd ecmd = {
.cmd = ETHTOOL_SSET,
};
@ -523,7 +524,7 @@ static int set_sset(int *fd, struct ifreq *ifr, const struct ethtool_link_usetti
ifr->ifr_data = (void *) &ecmd;
r = ioctl(*fd, SIOCETHTOOL, ifr);
r = ioctl(fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
@ -555,9 +556,9 @@ int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *l
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
r = get_glinksettings(fd, &ifr, &u);
r = get_glinksettings(*fd, &ifr, &u);
if (r < 0) {
r = get_gset(fd, &ifr, &u);
r = get_gset(*fd, &ifr, &u);
if (r < 0)
return log_warning_errno(r, "link_config: Cannot get device settings for %s : %m", ifname);
}
@ -574,9 +575,9 @@ int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *l
u->base.autoneg = link->autonegotiation;
if (u->base.cmd == ETHTOOL_GLINKSETTINGS)
r = set_slinksettings(fd, &ifr, u);
r = set_slinksettings(*fd, &ifr, u);
else
r = set_sset(fd, &ifr, u);
r = set_sset(*fd, &ifr, u);
if (r < 0)
return log_warning_errno(r, "link_config: Cannot set device settings for %s : %m", ifname);