From: James Hunt Date: Tue, 10 Dec 2013 10:29:59 +0000 (+0000) Subject: Make public API string method parameters const where possible. X-Git-Tag: lxc-1.0.0.beta1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0ca27269a817ac3b396fc947e350670b31e5487;p=thirdparty%2Flxc.git Make public API string method parameters const where possible. Signed-off-by: James Hunt Acked-by: Stéphane Graber --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 7e09da9a0..be8b74d2b 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -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); } diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h index 4ad3b6616..3e1b492f6 100644 --- a/src/lxc/lxccontainer.h +++ b/src/lxc/lxccontainer.h @@ -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); }; /*!