]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Make public API string method parameters const where possible.
authorJames Hunt <james.hunt@ubuntu.com>
Tue, 10 Dec 2013 10:29:59 +0000 (10:29 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 10 Dec 2013 15:41:38 +0000 (10:41 -0500)
Signed-off-by: James Hunt <james.hunt@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/lxccontainer.c
src/lxc/lxccontainer.h

index 7e09da9a010f32d759961b4bc2e071aac00da23e..be8b74d2bd96a656e737dcb77b6f6dd3b2e375a5 100644 (file)
@@ -68,7 +68,7 @@
 
 lxc_log_define(lxc_container, lxc);
 
-static bool file_exists(char *f)
+static bool file_exists(const char *f)
 {
        struct stat statbuf;
 
@@ -1565,7 +1565,7 @@ err:
        goto out;
 }
 
-static char** lxcapi_get_ips(struct lxc_container *c, char* interface, char* family, int scope)
+static char** lxcapi_get_ips(struct lxc_container *c, const char* interface, const char* family, int scope)
 {
        int i, count = 0;
        struct ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
@@ -2112,7 +2112,7 @@ const char *lxc_get_version(void)
        return LXC_VERSION;
 }
 
-static int copy_file(char *old, char *new)
+static int copy_file(const char *old, const char *new)
 {
        int in, out;
        ssize_t len, ret;
@@ -2640,7 +2640,7 @@ int get_next_index(const char *lxcpath, char *cname)
        }
 }
 
-static int lxcapi_snapshot(struct lxc_container *c, char *commentfile)
+static int lxcapi_snapshot(struct lxc_container *c, const char *commentfile)
 {
        int i, flags, ret;
        struct lxc_container *c2;
@@ -2859,7 +2859,7 @@ out_free:
        return -1;
 }
 
-static bool lxcapi_snapshot_restore(struct lxc_container *c, char *snapname, char *newname)
+static bool lxcapi_snapshot_restore(struct lxc_container *c, const char *snapname, const char *newname)
 {
        char clonelxcpath[MAXPATHLEN];
        int ret;
@@ -2910,7 +2910,7 @@ static bool lxcapi_snapshot_restore(struct lxc_container *c, char *snapname, cha
        return b;
 }
 
-static bool lxcapi_snapshot_destroy(struct lxc_container *c, char *snapname)
+static bool lxcapi_snapshot_destroy(struct lxc_container *c, const char *snapname)
 {
        int ret;
        char clonelxcpath[MAXPATHLEN];
@@ -2947,13 +2947,14 @@ static bool lxcapi_may_control(struct lxc_container *c)
        return lxc_try_cmd(c->name, c->config_path) == 0;
 }
 
-static bool add_remove_device_node(struct lxc_container *c, char *src_path, char *dest_path, bool add)
+static bool add_remove_device_node(struct lxc_container *c, const char *src_path, const char *dest_path, bool add)
 {
        int ret;
        struct stat st;
        char path[MAXPATHLEN];
        char value[MAX_BUFFER];
-       char *directory_path = NULL, *p;
+       char *directory_path = NULL;
+       const char *p;
 
        /* make sure container is running */
        if (!c->is_running(c)) {
@@ -3032,12 +3033,12 @@ out:
        return false;
 }
 
-static bool lxcapi_add_device_node(struct lxc_container *c, char *src_path, char *dest_path)
+static bool lxcapi_add_device_node(struct lxc_container *c, const char *src_path, const char *dest_path)
 {
        return add_remove_device_node(c, src_path, dest_path, true);
 }
 
-static bool lxcapi_remove_device_node(struct lxc_container *c, char *src_path, char *dest_path)
+static bool lxcapi_remove_device_node(struct lxc_container *c, const char *src_path, const char *dest_path)
 {
        return add_remove_device_node(c, src_path, dest_path, false);
 }
index 4ad3b6616f4ad6b61d22548ffdb636b89dc86d66..3e1b492f6de1885f9e46561b1007a022c92eaaa0 100644 (file)
@@ -436,7 +436,7 @@ struct lxc_container {
         * \note The returned array is allocated, so the caller must free it.
         * \note The returned array is terminated with a \c NULL entry.
         */
-       char** (*get_ips)(struct lxc_container *c, char* interface, char* family, int scope);
+       char** (*get_ips)(struct lxc_container *c, const char* interface, const char* family, int scope);
 
        /*!
         * \brief Retrieve the specified cgroup subsystem value for the container.
@@ -628,7 +628,7 @@ struct lxc_container {
         *
         * \note \p commentfile may be \c NULL but this is discouraged.
         */
-       int (*snapshot)(struct lxc_container *c, char *commentfile);
+       int (*snapshot)(struct lxc_container *c, const char *commentfile);
 
        /*!
         * \brief Obtain a list of container snapshots.
@@ -661,7 +661,7 @@ struct lxc_container {
         *  (representing \c /var/lib/lxcsnaps/c1/snap0). If \p newname is \p c2,
         *  then \c snap0 will be copied to \c /var/lib/lxc/c2.
         */
-       bool (*snapshot_restore)(struct lxc_container *c, char *snapname, char *newname);
+       bool (*snapshot_restore)(struct lxc_container *c, const char *snapname, const char *newname);
 
        /*!
         * \brief Destroy the specified snapshot.
@@ -671,7 +671,7 @@ struct lxc_container {
         *
         * \return \c true on success, else \c false.
         */
-       bool (*snapshot_destroy)(struct lxc_container *c, char *snapname);
+       bool (*snapshot_destroy)(struct lxc_container *c, const char *snapname);
 
        /*!
         * \brief Determine if the caller may control the container.
@@ -694,7 +694,7 @@ struct lxc_container {
         *
         * \return \c true on success, else \c false.
         */
-       bool (*add_device_node)(struct lxc_container *c, char *src_path, char *dest_path);
+       bool (*add_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path);
 
        /*!
         * \brief Remove specified device from the container.
@@ -706,7 +706,7 @@ struct lxc_container {
         *
         * \return \c true on success, else \c false.
         */
-       bool (*remove_device_node)(struct lxc_container *c, char *src_path, char *dest_path);
+       bool (*remove_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path);
 };
 
 /*!