]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
link: fix type for link-config's "features" array of tristates
authorThomas Haller <thaller@redhat.com>
Tue, 7 Aug 2018 06:55:07 +0000 (08:55 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 7 Aug 2018 13:40:39 +0000 (15:40 +0200)
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.

src/udev/net/ethtool-util.c
src/udev/net/ethtool-util.h
src/udev/net/link-config.c
src/udev/net/link-config.h

index 4bb4216ac87d275f420c07f875d028262c81066e..2051a9966d670cdbd8cba77d51f99b857a6033ee 100644 (file)
@@ -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;
index d57a7565df497b993a1047ac17e8a7ed36c1bbf1..2aa067a32b54ac76eb3cdd099602ed2f95ea9ad3 100644 (file)
@@ -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);
 
index cec4f4f779533550f767717f61140eece16f9030..1a397ece8c4754c2c57476d2a753fc760bdab07f 100644 (file)
@@ -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",
index 713513edad055c61f43c01004d8287dcf3ccfef4..c8f4367921db580c5b93d77af268cd846ad025d1 100644 (file)
@@ -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);