chiark / gitweb /
Constify ConfigTableItem tables
[elogind.git] / src / udev / net / link-config.c
index 7be4d24de732c86044186569e89472a890684c39..fe916a4326755e7fc0be49d2c89d77db6e831533 100644 (file)
@@ -92,14 +92,20 @@ static int link_config_ctx_connect(link_config_ctx *ctx) {
 
         if (ctx->ethtool_fd == -1) {
                 r = ethtool_connect(&ctx->ethtool_fd);
-                if (r < 0)
+                if (r < 0) {
+                        log_warning("link_config: could not connect to ethtool: %s",
+                                    strerror(-r));
                         return r;
+                }
         }
 
         if (!ctx->rtnl) {
                 r = sd_rtnl_open(&ctx->rtnl, 0);
-                if (r < 0)
+                if (r < 0) {
+                        log_warning("link_config: could not connect to rtnl: %s",
+                                    strerror(-r));
                         return r;
+                }
         }
 
         return 0;
@@ -118,6 +124,7 @@ static void link_configs_free(link_config_ctx *ctx) {
                 free(link->match_type);
                 free(link->description);
                 free(link->alias);
+                free(link->name_policy);
 
                 free(link);
         }
@@ -140,7 +147,7 @@ void link_config_ctx_free(link_config_ctx *ctx) {
 
 static int load_link(link_config_ctx *ctx, const char *filename) {
         _cleanup_free_ link_config *link = NULL;
-        _cleanup_fclose_ FILE *file;
+        _cleanup_fclose_ FILE *file = NULL;
         int r;
 
         assert(ctx);
@@ -167,8 +174,10 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
         link->wol = _WOL_INVALID;
         link->duplex = _DUP_INVALID;
 
-        r = config_parse(NULL, filename, file, "Match\0Link\0Ethernet\0", config_item_perf_lookup,
-                         (void*) link_config_gperf_lookup, false, false, link);
+        r = config_parse(NULL, filename, file,
+                         "Match\0Link\0Ethernet\0",
+                         config_item_perf_lookup, link_config_gperf_lookup,
+                         false, false, link);
         if (r < 0) {
                 log_warning("Could not parse config file %s: %s", filename, strerror(-r));
                 return r;
@@ -184,7 +193,7 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
 }
 
 static bool enable_name_policy(void) {
-        _cleanup_free_ char *line;
+        _cleanup_free_ char *line = NULL;
         char *w, *state;
         int r;
         size_t l;
@@ -204,7 +213,8 @@ static bool enable_name_policy(void) {
 
 int link_config_load(link_config_ctx *ctx) {
         int r;
-        char **files, **f;
+        _cleanup_strv_free_ char **files;
+        char **f;
 
         link_configs_free(ctx);
 
@@ -375,7 +385,9 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
                 case MACPOLICY_PERSISTENT:
                         if (mac_is_random(device)) {
                                 r = get_mac(device, false, &generated_mac);
-                                if (r < 0)
+                                if (r == -ENOENT)
+                                        break;
+                                else if (r < 0)
                                         return r;
                                 mac = &generated_mac;
                         }
@@ -383,7 +395,9 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
                 case MACPOLICY_RANDOM:
                         if (!mac_is_random(device)) {
                                 r = get_mac(device, true, &generated_mac);
-                                if (r < 0)
+                                if (r == -ENOENT)
+                                        break;
+                                else if (r < 0)
                                         return r;
                                 mac = &generated_mac;
                         }