]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: cleanup get_config_net_nic()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 8 Dec 2020 17:59:45 +0000 (18:59 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 9 Dec 2020 14:01:45 +0000 (15:01 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index 5f6f18d5cd6cd17cfcc439b67f15a49a80b29641..e0848c75bdbc194ecb96d6536d67593e02e4c25b 100644 (file)
@@ -5531,31 +5531,25 @@ static int clr_config_net_veth_ipv6_route(const char *key,
 static int get_config_net_nic(const char *key, char *retv, int inlen,
                              struct lxc_conf *c, void *data)
 {
-       int ret;
+       __do_free char *deindexed_key = NULL;
+       ssize_t idx = -1;
        const char *idxstring;
        struct lxc_config_t *config;
        struct lxc_netdev *netdev;
-       ssize_t idx = -1;
-       char *deindexed_key = NULL;
 
        idxstring = key + 8;
        if (!isdigit(*idxstring))
-               return -1;
+               return ret_errno(EINVAL);
 
        config = get_network_config_ops(key, c, &idx, &deindexed_key);
        if (!config || idx < 0)
-               return -1;
+               return -errno;
 
        netdev = lxc_get_netdev_by_idx(c, (unsigned int)idx, false);
-       if (!netdev) {
-               free(deindexed_key);
-               return -1;
-       }
-
-       ret = config->get(deindexed_key, retv, inlen, c, netdev);
-       free(deindexed_key);
+       if (!netdev)
+               return ret_errno(EINVAL);
 
-       return ret;
+       return config->get(deindexed_key, retv, inlen, c, netdev);
 }
 
 static int get_config_net_type(const char *key, char *retv, int inlen,