chiark / gitweb /
Fix a few return codes in error paths
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Apr 2014 18:05:01 +0000 (14:05 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 5 Apr 2014 04:55:19 +0000 (00:55 -0400)
src/network/networkd-netdev.c
src/network/networkd-network.c
src/udev/net/link-config.c

index 762eff2f6287625f52652e5450a0a7eaf2662661..92548d96f086320eec4be69ce9639f7714dda97f 100644 (file)
@@ -461,7 +461,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
                 if (errno == ENOENT)
                         return 0;
                 else
-                        return errno;
+                        return -errno;
         }
 
         netdev = new0(NetDev, 1);
index 47fab4ecb043defad9745664413f6c5573ac8c5d..bdf71e854e2484b6ed5ffa859880d972683ae97f 100644 (file)
@@ -41,7 +41,7 @@ static int network_load_one(Manager *manager, const char *filename) {
                 if (errno == ENOENT)
                         return 0;
                 else
-                        return errno;
+                        return -errno;
         }
 
         network = new0(Network, 1);
index 5bb6b02c1bb7b326e823651045cfb08b1aca8f2c..0c563b2db5432ff241eb6bf2203f87094bb1365d 100644 (file)
@@ -139,7 +139,7 @@ void link_config_ctx_free(link_config_ctx *ctx) {
 }
 
 static int load_link(link_config_ctx *ctx, const char *filename) {
-        link_config *link;
+        _cleanup_free_ link_config *link = NULL;
         _cleanup_fclose_ FILE *file;
         int r;
 
@@ -151,14 +151,12 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
                 if (errno == ENOENT)
                         return 0;
                 else
-                        return errno;
+                        return -errno;
         }
 
         link = new0(link_config, 1);
-        if (!link) {
-                r = log_oom();
-                goto failure;
-        }
+        if (!link)
+                return log_oom();
 
         link->mac_policy = _MACPOLICY_INVALID;
         link->wol = _WOL_INVALID;
@@ -168,19 +166,16 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
                          (void*) link_config_gperf_lookup, false, false, link);
         if (r < 0) {
                 log_warning("Could not parse config file %s: %s", filename, strerror(-r));
-                goto failure;
+                return r;
         } else
                 log_debug("Parsed configuration file %s", filename);
 
         link->filename = strdup(filename);
 
         LIST_PREPEND(links, ctx->links, link);
+        link = NULL;
 
         return 0;
-
-failure:
-        free(link);
-        return r;
 }
 
 static bool enable_name_policy(void) {