]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/confile_utils.c
Merge pull request #2712 from jsoref/spelling
[mirror_lxc.git] / src / lxc / confile_utils.c
index 2bb46d17bcce9efa1d93613d6fcb0fbde578141a..04926854d1134c11168e8dab2a2f694e030c17fb 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "config.h"
-
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#include <arpa/inet.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <arpa/inet.h>
 
 #include "conf.h"
+#include "config.h"
 #include "confile.h"
 #include "confile_utils.h"
 #include "error.h"
 #include "list.h"
 #include "log.h"
 #include "lxccontainer.h"
+#include "macro.h"
 #include "network.h"
 #include "parse.h"
 #include "utils.h"
@@ -288,13 +291,12 @@ void lxc_log_configured_netdevs(const struct lxc_conf *conf)
                        TRACE("type: macvlan");
 
                        if (netdev->priv.macvlan_attr.mode > 0) {
-                               char *macvlan_mode;
+                               char *mode;
 
-                               macvlan_mode = lxc_macvlan_flag_to_mode(
+                               mode = lxc_macvlan_flag_to_mode(
                                    netdev->priv.macvlan_attr.mode);
                                TRACE("macvlan mode: %s",
-                                     macvlan_mode ? macvlan_mode
-                                                  : "(invalid mode)");
+                                     mode ? mode : "(invalid mode)");
                        }
                        break;
                case LXC_NET_VLAN:
@@ -442,7 +444,7 @@ void lxc_free_networks(struct lxc_list *networks)
        lxc_list_init(networks);
 }
 
-static struct macvlan_mode {
+static struct lxc_macvlan_mode {
        char *name;
        int mode;
 } macvlan_mode[] = {
@@ -540,7 +542,7 @@ int network_ifname(char *valuep, const char *value, size_t size)
 
        retlen = strlcpy(valuep, value, size);
        if (retlen >= size)
-               ERROR("Network devie name \"%s\" is too long (>= %zu)", value,
+               ERROR("Network device name \"%s\" is too long (>= %zu)", value,
                      size);
 
        return 0;
@@ -672,6 +674,21 @@ int lxc_get_conf_str(char *retv, int inlen, const char *value)
        return value_len;
 }
 
+int lxc_get_conf_bool(struct lxc_conf *c, char *retv, int inlen, bool v)
+{
+       int len;
+       int fulllen = 0;
+
+       if (!retv)
+               inlen = 0;
+       else
+               memset(retv, 0, inlen);
+
+       strprint(retv, inlen, "%d", v);
+
+       return fulllen;
+}
+
 int lxc_get_conf_int(struct lxc_conf *c, char *retv, int inlen, int v)
 {
        int len;
@@ -721,9 +738,9 @@ bool parse_limit_value(const char **value, rlim_t *res)
 {
        char *endptr = NULL;
 
-       if (strncmp(*value, "unlimited", sizeof("unlimited") - 1) == 0) {
+       if (strncmp(*value, "unlimited", STRLITERALLEN("unlimited")) == 0) {
                *res = RLIM_INFINITY;
-               *value += sizeof("unlimited") - 1;
+               *value += STRLITERALLEN("unlimited");
                return true;
        }