]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Mark functions as static and arguments/arrays as const where possible
authorAndrey Mazo <mazo@telum.ru>
Tue, 24 Dec 2013 17:08:13 +0000 (21:08 +0400)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 2 Jan 2014 15:54:03 +0000 (09:54 -0600)
Mark most of functions that are used within only one file as static.
After 95ee490bbdb97ab2b4f1dfa63a0a26e0dd1c2f17 it's easy to prove they
are not in public API.
Several arrays and structs are also marked static.
This prevents them from being exported from liblxc.so

List of removed previously exported symbols:
bdevs
btrfs_ops
check_autodev
create_partial
dir_ops
dump_stacktrace
get_mapped_rootid
get_next_index
lock_mutex
loop_ops
lvm_ops
lxc_abort
lxcapi_clone
lxc_attach_drop_privs
lxc_attach_get_init_uidgi
lxc_attach_getpwshell
lxc_attach_remount_sys_pr
lxc_attach_set_environmen
lxc_attach_to_ns
lxc_clear_saved_nics
lxc_config_readline
lxc_devs
lxc_free_idmap
lxc_global_config_value
lxc_poll
lxc_proc_get_context_info
lxc_set_state
lxc_spawn
mk_devtmpfs
mount_check_fs
ongoing_create
overlayfs_destroy
overlayfs_ops
prepend_lxc_header
remove_partial
save_phys_nics
setup_pivot_root
signames
static_mutex
thread_mutex
unlock_mutex
unpriv_assign_nic
zfs_ops

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
32 files changed:
src/lxc/attach.c
src/lxc/attach.h
src/lxc/bdev.c
src/lxc/bdev.h
src/lxc/commands.c
src/lxc/conf.c
src/lxc/conf.h
src/lxc/confile.c
src/lxc/confile.h
src/lxc/log.h
src/lxc/lxc_autostart.c
src/lxc/lxc_clone.c
src/lxc/lxc_config.c
src/lxc/lxc_create.c
src/lxc/lxc_info.c
src/lxc/lxc_init.c
src/lxc/lxc_snapshot.c
src/lxc/lxc_stop.c
src/lxc/lxc_unshare.c
src/lxc/lxc_user_nic.c
src/lxc/lxc_usernsexec.c
src/lxc/lxccontainer.c
src/lxc/lxclock.c
src/lxc/namespace.c
src/lxc/network.c
src/lxc/parse.c
src/lxc/parse.h
src/lxc/start.c
src/lxc/start.h
src/lxc/state.c
src/lxc/utils.c
src/lxc/utils.h

index 674961731b39f8e58ab7499769b60a2a7bc91c5b..b7551d919afdc8c26f466c84412817a9f411b5c7 100644 (file)
@@ -62,7 +62,7 @@
 
 lxc_log_define(lxc_attach, lxc);
 
-struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid)
+static struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid)
 {
        struct lxc_proc_context_info *info = calloc(1, sizeof(*info));
        FILE *proc_file;
@@ -137,7 +137,7 @@ static void lxc_proc_put_context_info(struct lxc_proc_context_info *ctx)
        free(ctx);
 }
 
-int lxc_attach_to_ns(pid_t pid, int which)
+static int lxc_attach_to_ns(pid_t pid, int which)
 {
        char path[MAXPATHLEN];
        /* according to <http://article.gmane.org/gmane.linux.kernel.containers.lxc.devel/1429>,
@@ -204,7 +204,7 @@ int lxc_attach_to_ns(pid_t pid, int which)
        return 0;
 }
 
-int lxc_attach_remount_sys_proc()
+static int lxc_attach_remount_sys_proc(void)
 {
        int ret;
 
@@ -247,7 +247,7 @@ int lxc_attach_remount_sys_proc()
        return 0;
 }
 
-int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx)
+static int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx)
 {
        int last_cap = lxc_caps_last_cap();
        int cap;
@@ -265,7 +265,7 @@ int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx)
        return 0;
 }
 
-int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra_env, char** extra_keep)
+static int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra_env, char** extra_keep)
 {
        if (policy == LXC_ATTACH_CLEAR_ENV) {
                char **extra_keep_store = NULL;
@@ -373,7 +373,7 @@ int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra
        return 0;
 }
 
-char *lxc_attach_getpwshell(uid_t uid)
+static char *lxc_attach_getpwshell(uid_t uid)
 {
        /* local variables */
        pid_t pid;
@@ -528,7 +528,7 @@ char *lxc_attach_getpwshell(uid_t uid)
        }
 }
 
-void lxc_attach_get_init_uidgid(uid_t* init_uid, gid_t* init_gid)
+static void lxc_attach_get_init_uidgid(uid_t* init_uid, gid_t* init_gid)
 {
        FILE *proc_file;
        char proc_fn[MAXPATHLEN];
@@ -857,7 +857,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
        rexit(0);
 }
 
-int attach_child_main(void* data)
+static int attach_child_main(void* data)
 {
        struct attach_clone_payload* payload = (struct attach_clone_payload*)data;
        int ipc_socket = payload->ipc_socket;
index 22e6932b4b243451831eaaef6436b893aa5964c4..3d10777e75d45ea2b2bf3c5b856c3325541319fe 100644 (file)
@@ -33,17 +33,6 @@ struct lxc_proc_context_info {
        unsigned long long capability_mask;
 };
 
-extern struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid);
-
-extern int lxc_attach_to_ns(pid_t other_pid, int which);
-extern int lxc_attach_remount_sys_proc();
-extern int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx);
-extern int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra_env, char** extra_keep);
-
-extern char *lxc_attach_getpwshell(uid_t uid);
-
-extern void lxc_attach_get_init_uidgid(uid_t* init_uid, gid_t* init_gid);
-
 extern int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_function, void* exec_payload, lxc_attach_options_t* options, pid_t* attached_process);
 
 #endif
index 29e2ad57f77b4d9c594df2380ed3efdc7fd89e99..477011734026d720a86f77e673cf74df4a73bdd8 100644 (file)
@@ -324,8 +324,8 @@ static int detect_fs(struct bdev *bdev, char *type, int len)
 }
 
 struct bdev_type {
-       char *name;
-       struct bdev_ops *ops;
+       const char *name;
+       const struct bdev_ops *ops;
 };
 
 static int is_dir(const char *path)
@@ -469,7 +469,7 @@ static int dir_create(struct bdev *bdev, const char *dest, const char *n,
        return 0;
 }
 
-struct bdev_ops dir_ops = {
+static const struct bdev_ops dir_ops = {
        .detect = &dir_detect,
        .mount = &dir_mount,
        .umount = &dir_umount,
@@ -726,7 +726,7 @@ static int zfs_create(struct bdev *bdev, const char *dest, const char *n,
        exit(1);
 }
 
-struct bdev_ops zfs_ops = {
+static const struct bdev_ops zfs_ops = {
        .detect = &zfs_detect,
        .mount = &zfs_mount,
        .umount = &zfs_umount,
@@ -1125,7 +1125,7 @@ static int lvm_create(struct bdev *bdev, const char *dest, const char *n,
        return 0;
 }
 
-struct bdev_ops lvm_ops = {
+static const struct bdev_ops lvm_ops = {
        .detect = &lvm_detect,
        .mount = &lvm_mount,
        .umount = &lvm_umount,
@@ -1422,7 +1422,7 @@ static int btrfs_create(struct bdev *bdev, const char *dest, const char *n,
        return btrfs_subvolume_create(bdev->dest);
 }
 
-struct bdev_ops btrfs_ops = {
+static const struct bdev_ops btrfs_ops = {
        .detect = &btrfs_detect,
        .mount = &btrfs_mount,
        .umount = &btrfs_umount,
@@ -1692,7 +1692,7 @@ static int loop_destroy(struct bdev *orig)
        return unlink(orig->src + 5);
 }
 
-struct bdev_ops loop_ops = {
+static const struct bdev_ops loop_ops = {
        .detect = &loop_detect,
        .mount = &loop_mount,
        .umount = &loop_umount,
@@ -1864,7 +1864,7 @@ static int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char
        return 0;
 }
 
-int overlayfs_destroy(struct bdev *orig)
+static int overlayfs_destroy(struct bdev *orig)
 {
        char *upper;
 
@@ -1925,7 +1925,7 @@ static int overlayfs_create(struct bdev *bdev, const char *dest, const char *n,
        return 0;
 }
 
-struct bdev_ops overlayfs_ops = {
+static const struct bdev_ops overlayfs_ops = {
        .detect = &overlayfs_detect,
        .mount = &overlayfs_mount,
        .umount = &overlayfs_umount,
@@ -1934,7 +1934,7 @@ struct bdev_ops overlayfs_ops = {
        .create = &overlayfs_create,
 };
 
-struct bdev_type bdevs[] = {
+static const struct bdev_type bdevs[] = {
        {.name = "zfs", .ops = &zfs_ops,},
        {.name = "lvm", .ops = &lvm_ops,},
        {.name = "btrfs", .ops = &btrfs_ops,},
index 8c17117b4788d0cd4eb6ac877ab5240cf32ec39e..f4b3d29c4eacfc27d3fe79784d4bd3ba32d4bcd2 100644 (file)
@@ -72,8 +72,8 @@ struct bdev_ops {
  * data is so far unused.
  */
 struct bdev {
-       struct bdev_ops *ops;
-       char *type;
+       const struct bdev_ops *ops;
+       const char *type;
        char *src;
        char *dest;
        char *data;
index 73933cab532628ec45f3d8cdf8205f89fe8b3ca9..07e64b646e846f45d50a6ebc39fabb477d0f0c9f 100644 (file)
@@ -97,7 +97,7 @@ static int fill_sock_name(char *path, int len, const char *name,
 
 static const char *lxc_cmd_str(lxc_cmd_t cmd)
 {
-       static const char *cmdname[LXC_CMD_MAX] = {
+       static const char * const cmdname[LXC_CMD_MAX] = {
                [LXC_CMD_CONSOLE]         = "console",
                [LXC_CMD_STOP]            = "stop",
                [LXC_CMD_GET_STATE]       = "get_state",
index ed1056daa2244b53466e1601d69305882ad285a1..b7a6ae33b668721da8854f192b72720edd0ffd25 100644 (file)
@@ -1111,7 +1111,7 @@ static uint64_t fnv_64a_buf(void *buf, size_t len, uint64_t hval)
 
 #define LINELEN 4096
 #define MAX_FSTYPE_LEN 128
-int mount_check_fs( const char *dir, char *fstype )
+static int mount_check_fs( const char *dir, char *fstype )
 {
        char buf[LINELEN], *p;
        struct stat s;
@@ -1175,7 +1175,7 @@ int mount_check_fs( const char *dir, char *fstype )
  * the devtmpfs subdirectory.
  */
 
-char *mk_devtmpfs(const char *name, char *path, const char *lxcpath)
+static char *mk_devtmpfs(const char *name, char *path, const char *lxcpath)
 {
        int ret;
        struct stat s;
@@ -1353,13 +1353,13 @@ static int mount_autodev(const char *name, char *root, const char *lxcpath)
 }
 
 struct lxc_devs {
-       char *name;
+       const char *name;
        mode_t mode;
        int maj;
        int min;
 };
 
-struct lxc_devs lxc_devs[] = {
+static const struct lxc_devs lxc_devs[] = {
        { "null",       S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 3     },
        { "zero",       S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 5     },
        { "full",       S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, 1, 7     },
@@ -1369,10 +1369,9 @@ struct lxc_devs lxc_devs[] = {
        { "console",    S_IFCHR | S_IRUSR | S_IWUSR,           5, 1     },
 };
 
-static int setup_autodev(char *root)
+static int setup_autodev(const char *root)
 {
        int ret;
-       struct lxc_devs *d;
        char path[MAXPATHLEN];
        int i;
        mode_t cmask;
@@ -1388,7 +1387,7 @@ static int setup_autodev(char *root)
        INFO("Populating /dev under %s\n", root);
        cmask = umask(S_IXUSR | S_IXGRP | S_IXOTH);
        for (i = 0; i < sizeof(lxc_devs) / sizeof(lxc_devs[0]); i++) {
-               d = &lxc_devs[i];
+               const struct lxc_devs *d = &lxc_devs[i];
                ret = snprintf(path, MAXPATHLEN, "%s/dev/%s", root, d->name);
                if (ret < 0 || ret >= MAXPATHLEN)
                        return -1;
@@ -1550,7 +1549,7 @@ static int setup_rootfs(struct lxc_conf *conf)
        return 0;
 }
 
-int setup_pivot_root(const struct lxc_rootfs *rootfs)
+static int setup_pivot_root(const struct lxc_rootfs *rootfs)
 {
        if (!rootfs->path)
                return 0;
@@ -2980,7 +2979,7 @@ void lxc_delete_network(struct lxc_handler *handler)
        }
 }
 
-int unpriv_assign_nic(struct lxc_netdev *netdev, pid_t pid)
+static int unpriv_assign_nic(struct lxc_netdev *netdev, pid_t pid)
 {
        pid_t child;
 
@@ -3132,7 +3131,7 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
  * return the host uid to which the container root is mapped, or -1 on
  * error
  */
-uid_t get_mapped_rootid(struct lxc_conf *conf)
+static uid_t get_mapped_rootid(struct lxc_conf *conf)
 {
        struct lxc_list *it;
        struct id_map *map;
@@ -3398,7 +3397,7 @@ struct start_args {
 
 #define MAX_SYMLINK_DEPTH 32
 
-int check_autodev( const char *rootfs, void *data )
+static int check_autodev( const char *rootfs, void *data )
 {
        struct start_args *arg = data;
        int ret;
@@ -3772,7 +3771,7 @@ int lxc_clear_config_caps(struct lxc_conf *c)
        return 0;
 }
 
-int lxc_free_idmap(struct lxc_list *id_map) {
+static int lxc_free_idmap(struct lxc_list *id_map) {
        struct lxc_list *it, *next;
 
        lxc_list_for_each_safe(it, id_map, next) {
@@ -3874,7 +3873,7 @@ int lxc_clear_hooks(struct lxc_conf *c, const char *key)
        return 0;
 }
 
-void lxc_clear_saved_nics(struct lxc_conf *conf)
+static void lxc_clear_saved_nics(struct lxc_conf *conf)
 {
        int i;
 
index 9becc6399b1fdd105c5730958640eae02b6e8554..e88163545bdb5881f17992ca97b7ed854ceaa4b2 100644 (file)
@@ -164,8 +164,6 @@ struct id_map {
        unsigned long hostid, nsid, range;
 };
 
-extern int lxc_free_idmap(struct lxc_list *idmap);
-
 /*
  * Defines a structure containing a pty information for
  * virtualizing a tty
@@ -374,7 +372,6 @@ extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf,
 
 extern void lxc_rename_phys_nics_on_shutdown(struct lxc_conf *conf);
 
-extern uid_t get_mapped_rootid(struct lxc_conf *conf);
 extern int find_unmapped_nsuid(struct lxc_conf *conf);
 extern int mapped_hostid(int id, struct lxc_conf *conf);
 extern int chown_mapped_root(char *path, struct lxc_conf *conf);
index ad694e8673d3db30c59682d906546434e0bc7b10..0982b3e0aad55f865adb2d9f3c5cfe3520f70df9 100644 (file)
@@ -151,10 +151,10 @@ static struct lxc_config_t config[] = {
 
 struct signame {
        int num;
-       char *name;
+       const char *name;
 };
 
-struct signame signames[] = {
+static const struct signame signames[] = {
        { SIGHUP,    "HUP" },
        { SIGINT,    "INT" },
        { SIGQUIT,   "QUIT" },
@@ -1586,7 +1586,7 @@ out:
        return ret;
 }
 
-int lxc_config_readline(char *buffer, struct lxc_conf *conf)
+static int lxc_config_readline(char *buffer, struct lxc_conf *conf)
 {
        return parse_line(buffer, conf);
 }
index a16c9fd5bb0cfc7e4c1aea27a19f4ea35eb9481e..38f04f660467b7ef6ecf7b3c336faa78adb125bf 100644 (file)
@@ -40,7 +40,6 @@ extern struct lxc_config_t *lxc_getconfig(const char *key);
 extern int lxc_list_nicconfigs(struct lxc_conf *c, const char *key, char *retv, int inlen);
 extern int lxc_listconfigs(char *retv, int inlen);
 extern int lxc_config_read(const char *file, struct lxc_conf *conf);
-extern int lxc_config_readline(char *buffer, struct lxc_conf *conf);
 
 extern int lxc_config_define_add(struct lxc_list *defines, char* arg);
 extern int lxc_config_define_load(struct lxc_list *defines,
index d3c40fb17273c6b6df0738ce88d34c36b6991596..4a426656d18b4a8ce88c2f51e112720c4f24d225 100644 (file)
@@ -233,8 +233,6 @@ static inline void LXC_##PRIORITY(struct lxc_log_locinfo* locinfo,  \
 /*
  * top categories
  */
-extern struct lxc_log_category lxc_log_category_lxc;
-
 #define TRACE(format, ...) do {                                                \
        struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;          \
        LXC_TRACE(&locinfo, format, ##__VA_ARGS__);                     \
index 1407a417421285d784411d4dec0040ba8e52fea6..f6e6bfc7f342fc895e7503b4a1913aa4e38e8968 100644 (file)
@@ -97,7 +97,7 @@ int lists_contain_common_entry(struct lxc_list *p1, struct lxc_list *p2) {
        return 0;
 }
 
-struct lxc_list *get_list(char *input, char *delimiter) {
+static struct lxc_list *get_list(char *input, char *delimiter) {
        char *workstr = NULL;
        char *workptr = NULL;
        char *sptr = NULL;
@@ -138,7 +138,7 @@ struct lxc_list *get_list(char *input, char *delimiter) {
        return workstr_list;
 }
 
-struct lxc_list *get_config_list(struct lxc_container *c, char *key) {
+static struct lxc_list *get_config_list(struct lxc_container *c, char *key) {
        int len = 0;
        char* value = NULL;
        struct lxc_list *config_list = NULL;
@@ -167,7 +167,7 @@ struct lxc_list *get_config_list(struct lxc_container *c, char *key) {
        return config_list;
 }
 
-int get_config_integer(struct lxc_container *c, char *key) {
+static int get_config_integer(struct lxc_container *c, char *key) {
        int len = 0;
        int ret = 0;
        char* value = NULL;
index 3354809ea04a932b1c532808fa53ec1e00039984..8e8cd46407f35b5a65d61c14e7fa6af2b0ed5a40 100644 (file)
@@ -58,7 +58,7 @@ static unsigned long get_fssize(char *s)
        return ret;
 }
 
-void usage(const char *me)
+static void usage(const char *me)
 {
        printf("Usage: %s [-s] [-B backingstore] [-L size] [-K] [-M] [-H]\n", me);
        printf("          [-p lxcpath] [-P newlxcpath] orig new\n");
index f137498901f6710f564571b346a5c65007a1cc87..659501cbc28489ee63d1e1ddc4629c14aaaeb22f 100644 (file)
@@ -30,7 +30,7 @@ struct lxc_config_items {
        const char *(*fn)(void);
 };
 
-struct lxc_config_items items[] =
+static struct lxc_config_items items[] =
 {
        { .name = "lxcpath", .fn = &lxc_get_default_config_path, },
        { .name = "lvm_vg", .fn = &lxc_get_default_lvm_vg, },
@@ -39,14 +39,14 @@ struct lxc_config_items items[] =
        { .name = NULL, },
 };
 
-void usage(char *me)
+static void usage(char *me)
 {
        printf("Usage: %s -l: list all available configuration items\n", me);
        printf("       %s item: print configuration item\n", me);
        exit(1);
 }
 
-void list_config_items(void)
+static void list_config_items(void)
 {
        struct lxc_config_items *i;
 
index 5ec7fc33bbfdb6f5a74f1715b265c4627c17db72..af10c59a010b3693473ccd3081610574970ec447 100644 (file)
@@ -145,7 +145,7 @@ Options :\n\
        .checker  = NULL,
 };
 
-bool validate_bdev_args(struct lxc_arguments *a)
+static bool validate_bdev_args(struct lxc_arguments *a)
 {
        if (strcmp(a->bdevtype, "best") != 0) {
                if (a->fstype || a->fssize) {
index 98698818d9091bb9a85a40391cf619b1dd3ec9cc..b515087686e955209f3d6a0a5c073968d72c301d 100644 (file)
@@ -244,7 +244,7 @@ static void print_stats(struct lxc_container *c)
        }
 }
 
-void print_info_msg_int(const char *key, int value)
+static void print_info_msg_int(const char *key, int value)
 {
        if (humanize)
                printf("%-15s %d\n", key, value);
@@ -256,7 +256,7 @@ void print_info_msg_int(const char *key, int value)
        }
 }
 
-void print_info_msg_str(const char *key, const char *value)
+static void print_info_msg_str(const char *key, const char *value)
 {
        if (humanize)
                printf("%-15s %s\n", key, value);
index 968c25d6c25a4240c8374b511d49999429a39061..d88a935f557c8872a27befdd5985f23c86ae4f37 100644 (file)
@@ -42,7 +42,7 @@ lxc_log_define(lxc_init, lxc);
 
 static int quiet;
 
-static struct option options[] = {
+static const struct option options[] = {
        { "name",        required_argument, NULL, 'n' },
        { "logpriority", required_argument, NULL, 'l' },
        { "quiet",       no_argument,       NULL, 'q' },
index e83f1b2b9358514bba9717f2ec838317c8540c52..9a8f6a443fae145e557d0a2589ecb76274c265cc 100644 (file)
 
 lxc_log_define(lxc_snapshot, lxc);
 
-char *newname;
-char *snapshot;
+static char *newname;
+static char *snapshot;
 
 #define DO_SNAP 0
 #define DO_LIST 1
 #define DO_RESTORE 2
 #define DO_DESTROY 3
-int action;
-int print_comments;
-char *commentfile;
+static int action;
+static int print_comments;
+static char *commentfile;
 
-int do_snapshot(struct lxc_container *c)
+static int do_snapshot(struct lxc_container *c)
 {
        int ret;
 
@@ -59,7 +59,7 @@ int do_snapshot(struct lxc_container *c)
        return 0;
 }
 
-void print_file(char *path)
+static void print_file(char *path)
 {
        if (!path)
                return;
@@ -76,7 +76,7 @@ void print_file(char *path)
        fclose(f);
 }
 
-int do_list_snapshots(struct lxc_container *c)
+static int do_list_snapshots(struct lxc_container *c)
 {
        struct lxc_snapshot *s;
        int i, n;
@@ -100,7 +100,7 @@ int do_list_snapshots(struct lxc_container *c)
        return 0;
 }
 
-int do_restore_snapshots(struct lxc_container *c)
+static int do_restore_snapshots(struct lxc_container *c)
 {
        if (c->snapshot_restore(c, snapshot, newname))
                return 0;
@@ -109,7 +109,7 @@ int do_restore_snapshots(struct lxc_container *c)
        return -1;
 }
 
-int do_destroy_snapshots(struct lxc_container *c)
+static int do_destroy_snapshots(struct lxc_container *c)
 {
        if (c->snapshot_destroy(c, snapshot))
                return 0;
index a7f2907dd714987ae1c5989e71dd980c6fb2230e..d0cf798f246ff367fc4769bba17bda4d7ce178e5 100644 (file)
@@ -80,7 +80,7 @@ Options :\n\
 };
 
 /* returns -1 on failure, 0 on success */
-int do_reboot_and_check(struct lxc_arguments *a, struct lxc_container *c)
+static int do_reboot_and_check(struct lxc_arguments *a, struct lxc_container *c)
 {
        int ret;
        pid_t pid;
index 8ffdd212ab83a06fa7dc320ee0f83a0476ab3a50..827aa913178d491e3b1936ff1d7adb18668adf24 100644 (file)
@@ -42,7 +42,7 @@
 
 lxc_log_define(lxc_unshare_ui, lxc);
 
-void usage(char *cmd)
+static void usage(char *cmd)
 {
        fprintf(stderr, "%s <options> command [command_arguments]\n", basename(cmd));
        fprintf(stderr, "Options are:\n");
index 67b1fa854e27bbefc9b1b7ef635e5f92217e52b4..60176b1749aace0c327a89077a18093df32ce3ef 100644 (file)
@@ -50,7 +50,7 @@
 #include "utils.h"
 #include "network.h"
 
-void usage(char *me, bool fail)
+static void usage(char *me, bool fail)
 {
        fprintf(stderr, "Usage: %s pid type bridge nicname\n", me);
        fprintf(stderr, " nicname is the name to use inside the container\n");
index f152f91bff32c6102b0f5b8c332c6a50a060a8f3..2351070fa8306adcad477f820a7346d5d949730f 100644 (file)
@@ -127,7 +127,7 @@ struct id_map {
        struct id_map *next;
 };
 
-struct id_map default_map = {
+static struct id_map default_map = {
        .which = 'b',
        .host_id = 100000,
        .ns_id = 0,
index b62f7ba6eb861a180758a4453a994f63a5fb7e77..e991e59da4f6ffa67da07698059aa0ce056b1754 100644 (file)
@@ -99,7 +99,7 @@ static bool config_file_exists(const char *lxcpath, const char *cname)
  * we remove that file.  When we load or try to start a container, if
  * we find that file, without a flock, we remove the container.
  */
-int ongoing_create(struct lxc_container *c)
+static int ongoing_create(struct lxc_container *c)
 {
        int len = strlen(c->config_path) + strlen(c->name) + 10;
        char *path = alloca(len);
@@ -135,7 +135,7 @@ int ongoing_create(struct lxc_container *c)
        return 2;
 }
 
-int create_partial(struct lxc_container *c)
+static int create_partial(struct lxc_container *c)
 {
        // $lxcpath + '/' + $name + '/partial' + \0
        int len = strlen(c->config_path) + strlen(c->name) + 10;
@@ -165,7 +165,7 @@ int create_partial(struct lxc_container *c)
        return fd;
 }
 
-void remove_partial(struct lxc_container *c, int fd)
+static void remove_partial(struct lxc_container *c, int fd)
 {
        // $lxcpath + '/' + $name + '/partial' + \0
        int len = strlen(c->config_path) + strlen(c->name) + 10;
@@ -1037,7 +1037,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool quiet
        return true;
 }
 
-bool prepend_lxc_header(char *path, const char *t, char *const argv[])
+static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
 {
        long flen;
        char *contents;
@@ -2414,7 +2414,7 @@ static int create_file_dirname(char *path)
        return ret;
 }
 
-struct lxc_container *lxcapi_clone(struct lxc_container *c, const char *newname,
+static struct lxc_container *lxcapi_clone(struct lxc_container *c, const char *newname,
                const char *lxcpath, int flags,
                const char *bdevtype, const char *bdevdata, unsigned long newsize,
                char **hookargs)
@@ -2587,7 +2587,7 @@ static int lxcapi_attach_run_wait(struct lxc_container *c, lxc_attach_options_t
        return lxc_wait_for_pid_status(pid);
 }
 
-int get_next_index(const char *lxcpath, char *cname)
+static int get_next_index(const char *lxcpath, char *cname)
 {
        char *fname;
        struct stat sb;
index b30f4c3421079b0305fba0de76973abde233fc4a..74b169a62afe0fb676f6795cff08191949c5dd0d 100644 (file)
 lxc_log_define(lxc_lock, lxc);
 
 #ifdef MUTEX_DEBUGGING
-pthread_mutex_t thread_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
-pthread_mutex_t static_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t thread_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t static_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
 
-inline void dump_stacktrace(void)
+static inline void dump_stacktrace(void)
 {
        void *array[MAX_STACKDEPTH];
        size_t size;
@@ -67,13 +67,13 @@ inline void dump_stacktrace(void)
        free (strings);
 }
 #else
-pthread_mutex_t thread_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t thread_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-inline void dump_stacktrace(void) {;}
+static inline void dump_stacktrace(void) {;}
 #endif
 
-void lock_mutex(pthread_mutex_t *l)
+static void lock_mutex(pthread_mutex_t *l)
 {
        int ret;
 
@@ -84,7 +84,7 @@ void lock_mutex(pthread_mutex_t *l)
        }
 }
 
-void unlock_mutex(pthread_mutex_t *l)
+static void unlock_mutex(pthread_mutex_t *l)
 {
        int ret;
 
index a152c6b128c0917f174da508d70776d0028ed4a0..31d4e7204b293cf9390b6f6a7b642d4927c88c68 100644 (file)
@@ -69,11 +69,11 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
        return ret;
 }
 
-static char *namespaces_list[] = {
+static const char * const namespaces_list[] = {
        "MOUNT", "PID", "UTSNAME", "IPC",
        "USER", "NETWORK"
 };
-static int cloneflags_list[] = {
+static const int cloneflags_list[] = {
        CLONE_NEWNS, CLONE_NEWPID, CLONE_NEWUTS, CLONE_NEWIPC,
        CLONE_NEWUSER, CLONE_NEWNET
 };
index 361bb994578f5af2a7e4a873a31d10ccb97e2a90..bd2a37c4b1e61ab6d8a909882c1ea0d405a2b4e6 100644 (file)
@@ -1092,7 +1092,7 @@ int lxc_bridge_attach(const char *bridge, const char *ifname)
        return err;
 }
 
-static char* lxc_network_types[LXC_NET_MAXCONFTYPE + 1] = {
+static const char* const lxc_network_types[LXC_NET_MAXCONFTYPE + 1] = {
        [LXC_NET_VETH]    = "veth",
        [LXC_NET_MACVLAN] = "macvlan",
        [LXC_NET_VLAN]    = "vlan",
@@ -1107,7 +1107,7 @@ const char *lxc_net_type_to_str(int type)
        return lxc_network_types[type];
 }
 
-static char padchar[] =
+static const char padchar[] =
 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
 char *lxc_mkifname(char *template)
index ea13d0645b4854ff07516a85e2333a6a78aaad1d..604c47b7083a275cc33b5a550f1433eaa064bec6 100644 (file)
@@ -65,7 +65,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data)
        return err;
 }
 
-int lxc_char_left_gc(char *buffer, size_t len)
+int lxc_char_left_gc(const char *buffer, size_t len)
 {
        int i;
        for (i = 0; i < len; i++) {
@@ -77,7 +77,7 @@ int lxc_char_left_gc(char *buffer, size_t len)
        return 0;
 }
 
-int lxc_char_right_gc(char *buffer, size_t len)
+int lxc_char_right_gc(const char *buffer, size_t len)
 {
        int i;
        for (i = len - 1; i >= 0; i--) {
@@ -91,7 +91,7 @@ int lxc_char_right_gc(char *buffer, size_t len)
        return 0;
 }
 
-int lxc_is_line_empty(char *line)
+int lxc_is_line_empty(const char *line)
 {
        int i;
        size_t len = strlen(line);
index 55c90c46956c381424d7e5eb898556feaa364cc8..ba7d639dff34f7938e760b03977513d022d1af9e 100644 (file)
@@ -31,10 +31,10 @@ typedef int (*lxc_file_cb)(char *buffer, void *data);
 extern int lxc_file_for_each_line(const char *file, lxc_file_cb callback,
                                  void* data);
 
-extern int lxc_char_left_gc(char *buffer, size_t len);
+extern int lxc_char_left_gc(const char *buffer, size_t len);
 
-extern int lxc_char_right_gc(char *buffer, size_t len);
+extern int lxc_char_right_gc(const char *buffer, size_t len);
 
-extern int lxc_is_line_empty(char *line);
+extern int lxc_is_line_empty(const char *line);
 
 #endif
index 7395aeac6cdaba5dc59471bdc32b9313717b9362..a5d6e56188b25c9ba7d53d4c99d64c0d02875b7f 100644 (file)
@@ -277,14 +277,14 @@ static int signal_handler(int fd, uint32_t events, void *data,
        return 1;
 }
 
-int lxc_set_state(const char *name, struct lxc_handler *handler, lxc_state_t state)
+static int lxc_set_state(const char *name, struct lxc_handler *handler, lxc_state_t state)
 {
        handler->state = state;
        lxc_monitor_send_state(name, state, handler->lxcpath);
        return 0;
 }
 
-int lxc_poll(const char *name, struct lxc_handler *handler)
+static int lxc_poll(const char *name, struct lxc_handler *handler)
 {
        int sigfd = handler->sigfd;
        int pid = handler->pid;
@@ -464,7 +464,7 @@ static void lxc_fini(const char *name, struct lxc_handler *handler)
        free(handler);
 }
 
-void lxc_abort(const char *name, struct lxc_handler *handler)
+static void lxc_abort(const char *name, struct lxc_handler *handler)
 {
        int ret, status;
 
@@ -656,7 +656,7 @@ out_warn_father:
        return -1;
 }
 
-int save_phys_nics(struct lxc_conf *conf)
+static int save_phys_nics(struct lxc_conf *conf)
 {
        struct lxc_list *iterator;
 
@@ -686,7 +686,7 @@ int save_phys_nics(struct lxc_conf *conf)
        return 0;
 }
 
-int lxc_spawn(struct lxc_handler *handler)
+static int lxc_spawn(struct lxc_handler *handler)
 {
        int failed_before_rename = 0;
        const char *name = handler->name;
index ec7f3f6bb28fbbd5406a6ca1b03da3686a56bf6c..7d4ae59069f89c947a0008af3c9d7617826c1e46 100644 (file)
@@ -55,7 +55,7 @@ struct ns_info {
        int clone_flag;
 };
 
-const struct ns_info ns_info[LXC_NS_MAX];
+extern const struct ns_info ns_info[LXC_NS_MAX];
 
 struct lxc_handler {
        pid_t pid;
@@ -74,11 +74,7 @@ struct lxc_handler {
 };
 
 extern struct lxc_handler *lxc_init(const char *name, struct lxc_conf *, const char *);
-extern int lxc_spawn(struct lxc_handler *);
 
-extern int lxc_poll(const char *name, struct lxc_handler *handler);
-extern void lxc_abort(const char *name, struct lxc_handler *handler);
-extern int lxc_set_state(const char *, struct lxc_handler *, lxc_state_t);
 extern int lxc_check_inherited(struct lxc_conf *conf, int fd_to_ignore);
 int __lxc_start(const char *, struct lxc_conf *, struct lxc_operations *,
                void *, const char *);
index 411be853c97953a80a2622417e95daa42d8f8613..a47341ff08158e453bc5dbff9cc7aed60f3a440c 100644 (file)
@@ -42,7 +42,7 @@
 
 lxc_log_define(lxc_state, lxc);
 
-static char *strstate[] = {
+static const char * const strstate[] = {
        "STOPPED", "STARTING", "RUNNING", "STOPPING",
        "ABORTING", "FREEZING", "FROZEN", "THAWED",
 };
index 3d5381c86acc44361993cf0c02430c7b5f3483af..1f9ceea6ccc4baaa06c3c55673a38df0058acc77 100644 (file)
@@ -238,9 +238,9 @@ static char *copy_global_config_value(char *p)
 #define DEFAULT_THIN_POOL "lxc"
 #define DEFAULT_ZFSROOT "lxc"
 
-const char *lxc_global_config_value(const char *option_name)
+static const char *lxc_global_config_value(const char *option_name)
 {
-       static const char *options[][2] = {
+       static const char * const options[][2] = {
                { "lvm_vg",          DEFAULT_VG      },
                { "lvm_thin_pool",   DEFAULT_THIN_POOL },
                { "zfsroot",         DEFAULT_ZFSROOT },
@@ -272,7 +272,7 @@ const char *lxc_global_config_value(const char *option_name)
                user_lxc_path = strdup(LXCPATH);
        }
 
-       const char *(*ptr)[2];
+       const char * const (*ptr)[2];
        const char *value;
        size_t i;
        char buf[1024], *p, *p2;
index 253756257b05fd866a905a8026c91ac13cca66b4..847a613d79a28d99ea3024d2ec3416fe0c82aba7 100644 (file)
@@ -45,7 +45,6 @@ extern const char *get_rundir(void);
  * Return a buffer containing the default container path.
  * Caller must NOT free this buffer, since it may be static.
  */
-extern const char *lxc_global_config_value(const char *option_name);
 extern const char *default_lxc_path(void);
 extern const char *default_zfs_root(void);
 extern const char *default_lvm_vg(void);
@@ -267,5 +266,4 @@ extern size_t lxc_array_len(void **array);
 
 extern void **lxc_append_null_to_array(void **array, size_t count);
 
-extern void dump_stacktrace(void);
 #endif