]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: simplify error handling
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 14 May 2023 12:16:44 +0000 (14:16 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 14 May 2023 17:32:07 +0000 (19:32 +0200)
src/nspawn/nspawn.c

index 9e5b7772ac27264c7e6213f96f6d86b3ad7a29a7..49802d6fdfb18f01c09d6e5e54b0da2808957afc 100644 (file)
@@ -877,17 +877,15 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case ARG_NETWORK_ZONE: {
-                        char *j;
+                        _cleanup_free_ char *j = NULL;
 
                         j = strjoin("vz-", optarg);
                         if (!j)
                                 return log_oom();
 
-                        if (!ifname_valid(j)) {
-                                log_error("Network zone name not valid: %s", j);
-                                free(j);
-                                return -EINVAL;
-                        }
+                        if (!ifname_valid(j))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Network zone name not valid: %s", j);
 
                         free_and_replace(arg_network_zone, j);