From: Thomas Haller Date: Tue, 7 Aug 2018 06:55:07 +0000 (+0200) Subject: link: fix type for link-config's "features" array of tristates X-Git-Tag: v240~851 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cc2ff878fa8c2fd80b0f13c1e4233ad656726296;p=thirdparty%2Fsystemd.git link: fix type for link-config's "features" array of tristates The "features" fields is parsed as a tristate value. The values are thus not of type NetDevFeature enum but int. The NetDevFeature enum is instead the index for the features array. Adjust the type. In practice, this had no impact because NetDevFeature enum commonly has size of int. Also, don't use memset() 0xFF to initilize the int with -1. While it works correctly in practice, it feels ugly. --- diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c index 4bb4216ac87..2051a9966d6 100644 --- a/src/udev/net/ethtool-util.c +++ b/src/udev/net/ethtool-util.c @@ -302,7 +302,7 @@ static int find_feature_index(struct ethtool_gstrings *strings, const char *feat return -1; } -int ethtool_set_features(int *fd, const char *ifname, NetDevFeature *features) { +int ethtool_set_features(int *fd, const char *ifname, int *features) { _cleanup_free_ struct ethtool_gstrings *strings = NULL; struct ethtool_sfeatures *sfeatures; int block, bit, i, r; diff --git a/src/udev/net/ethtool-util.h b/src/udev/net/ethtool-util.h index d57a7565df4..2aa067a32b5 100644 --- a/src/udev/net/ethtool-util.h +++ b/src/udev/net/ethtool-util.h @@ -83,7 +83,7 @@ int ethtool_connect(int *ret); 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); int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol); -int ethtool_set_features(int *fd, const char *ifname, NetDevFeature *features); +int ethtool_set_features(int *fd, const char *ifname, int *features); int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *link); int ethtool_set_channels(int *fd, const char *ifname, netdev_channels *channels); diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index cec4f4f7795..1a397ece8c4 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -125,6 +125,7 @@ int link_config_ctx_new(link_config_ctx **ret) { static int load_link(link_config_ctx *ctx, const char *filename) { _cleanup_(link_config_freep) link_config *link = NULL; _cleanup_fclose_ FILE *file = NULL; + int i; int r; assert(ctx); @@ -153,7 +154,8 @@ static int load_link(link_config_ctx *ctx, const char *filename) { link->port = _NET_DEV_PORT_INVALID; link->autonegotiation = -1; - memset(&link->features, 0xFF, sizeof(link->features)); + for (i = 0; i < (int)ELEMENTSOF(link->features); i++) + link->features[i] = -1; r = config_parse(NULL, filename, file, "Match\0Link\0Ethernet\0", diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h index 713513edad0..c8f4367921d 100644 --- a/src/udev/net/link-config.h +++ b/src/udev/net/link-config.h @@ -56,7 +56,7 @@ struct link_config { int autonegotiation; WakeOnLan wol; NetDevPort port; - NetDevFeature features[_NET_DEV_FEAT_MAX]; + int features[_NET_DEV_FEAT_MAX]; netdev_channels channels; LIST_FIELDS(link_config, links);