Unverified Commit 84b31b36 by Christian Brauner Committed by GitHub

Merge pull request #2889 from tomponline/tp-2019-03-02/bugfixes

gcc -Wall flag compat
parents 9fc7a50f ea83b296
...@@ -159,7 +159,6 @@ static int in_same_namespace(pid_t pid1, pid_t pid2, const char *ns) ...@@ -159,7 +159,6 @@ static int in_same_namespace(pid_t pid1, pid_t pid2, const char *ns)
{ {
__do_close_prot_errno int ns_fd1 = -1, ns_fd2 = -1; __do_close_prot_errno int ns_fd1 = -1, ns_fd2 = -1;
int ret = -1; int ret = -1;
int saved_errno;
struct stat ns_st1, ns_st2; struct stat ns_st1, ns_st2;
ns_fd1 = lxc_preserve_ns(pid1, ns); ns_fd1 = lxc_preserve_ns(pid1, ns);
...@@ -670,7 +669,7 @@ static bool no_new_privs(struct lxc_container *c, lxc_attach_options_t *options) ...@@ -670,7 +669,7 @@ static bool no_new_privs(struct lxc_container *c, lxc_attach_options_t *options)
static signed long get_personality(const char *name, const char *lxcpath) static signed long get_personality(const char *name, const char *lxcpath)
{ {
__do_free char *p; __do_free char *p = NULL;
p = lxc_cmd_get_config_item(name, "lxc.arch", lxcpath); p = lxc_cmd_get_config_item(name, "lxc.arch", lxcpath);
if (!p) if (!p)
......
...@@ -381,12 +381,12 @@ static ssize_t get_max_cpus(char *cpulist) ...@@ -381,12 +381,12 @@ static ssize_t get_max_cpus(char *cpulist)
static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized) static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
{ {
__do_free char *cpulist = NULL, *fpath = NULL, *isolcpus = NULL, __do_free char *cpulist = NULL, *fpath = NULL, *isolcpus = NULL,
*posscpus; *posscpus = NULL;
__do_free uint32_t *isolmask = NULL, *possmask = NULL; __do_free uint32_t *isolmask = NULL, *possmask = NULL;
int ret; int ret;
ssize_t i; ssize_t i;
char oldv; char oldv;
char *lastslash, *posscpus_tmp; char *lastslash;
ssize_t maxisol = 0, maxposs = 0; ssize_t maxisol = 0, maxposs = 0;
bool bret = false, flipped_bit = false; bool bret = false, flipped_bit = false;
...@@ -727,7 +727,7 @@ static char **cg_hybrid_get_controllers(char **klist, char **nlist, char *line, ...@@ -727,7 +727,7 @@ static char **cg_hybrid_get_controllers(char **klist, char **nlist, char *line,
*p2 = '\0'; *p2 = '\0';
if (type == CGROUP_SUPER_MAGIC) { if (type == CGROUP_SUPER_MAGIC) {
__do_free char *dup; __do_free char *dup = NULL;
/* strdup() here for v1 hierarchies. Otherwise /* strdup() here for v1 hierarchies. Otherwise
* lxc_iterate_parts() will destroy mountpoints such as * lxc_iterate_parts() will destroy mountpoints such as
...@@ -1216,7 +1216,7 @@ static bool cg_unified_create_cgroup(struct hierarchy *h, char *cgname) ...@@ -1216,7 +1216,7 @@ static bool cg_unified_create_cgroup(struct hierarchy *h, char *cgname)
cgroup = must_make_path(h->mountpoint, h->container_base_path, NULL); cgroup = must_make_path(h->mountpoint, h->container_base_path, NULL);
for (i = 0; i < parts_len; i++) { for (i = 0; i < parts_len; i++) {
int ret; int ret;
__do_free char *target; __do_free char *target = NULL;
cgroup = must_append_path(cgroup, parts[i], NULL); cgroup = must_append_path(cgroup, parts[i], NULL);
target = must_make_path(cgroup, "cgroup.subtree_control", NULL); target = must_make_path(cgroup, "cgroup.subtree_control", NULL);
...@@ -1470,7 +1470,7 @@ __cgfsng_ops static bool __do_cgroup_enter(struct cgroup_ops *ops, pid_t pid, ...@@ -1470,7 +1470,7 @@ __cgfsng_ops static bool __do_cgroup_enter(struct cgroup_ops *ops, pid_t pid,
for (int i = 0; ops->hierarchies[i]; i++) { for (int i = 0; ops->hierarchies[i]; i++) {
int ret; int ret;
__do_free char *path; __do_free char *path = NULL;
if (monitor) if (monitor)
path = must_make_path(ops->hierarchies[i]->monitor_full_path, path = must_make_path(ops->hierarchies[i]->monitor_full_path,
...@@ -1842,7 +1842,7 @@ on_error: ...@@ -1842,7 +1842,7 @@ on_error:
static int recursive_count_nrtasks(char *dirname) static int recursive_count_nrtasks(char *dirname)
{ {
__do_free char *path = NULL; __do_free char *path = NULL;
__do_closedir DIR *dir; __do_closedir DIR *dir = NULL;
struct dirent *direntp; struct dirent *direntp;
int count = 0, ret; int count = 0, ret;
...@@ -1900,7 +1900,7 @@ __cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops, ...@@ -1900,7 +1900,7 @@ __cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops,
for (i = 0; ops->hierarchies[i]; i++) { for (i = 0; ops->hierarchies[i]; i++) {
int ret; int ret;
__do_free char *fullpath; __do_free char *fullpath = NULL;
fullpath = must_make_path(ops->hierarchies[i]->mountpoint, fullpath = must_make_path(ops->hierarchies[i]->mountpoint,
ops->hierarchies[i]->container_base_path, ops->hierarchies[i]->container_base_path,
...@@ -2116,7 +2116,7 @@ __cgfsng_ops static int cgfsng_get(struct cgroup_ops *ops, const char *filename, ...@@ -2116,7 +2116,7 @@ __cgfsng_ops static int cgfsng_get(struct cgroup_ops *ops, const char *filename,
const char *lxcpath) const char *lxcpath)
{ {
__do_free char *path = NULL; __do_free char *path = NULL;
__do_free char *controller; __do_free char *controller = NULL;
char *p; char *p;
struct hierarchy *h; struct hierarchy *h;
int ret = -1; int ret = -1;
...@@ -2133,7 +2133,7 @@ __cgfsng_ops static int cgfsng_get(struct cgroup_ops *ops, const char *filename, ...@@ -2133,7 +2133,7 @@ __cgfsng_ops static int cgfsng_get(struct cgroup_ops *ops, const char *filename,
h = get_hierarchy(ops, controller); h = get_hierarchy(ops, controller);
if (h) { if (h) {
__do_free char *fullpath; __do_free char *fullpath = NULL;
fullpath = build_full_cgpath_from_monitorpath(h, path, filename); fullpath = build_full_cgpath_from_monitorpath(h, path, filename);
ret = lxc_read_from_file(fullpath, value, len); ret = lxc_read_from_file(fullpath, value, len);
...@@ -2151,7 +2151,7 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops, ...@@ -2151,7 +2151,7 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops,
const char *name, const char *lxcpath) const char *name, const char *lxcpath)
{ {
__do_free char *path = NULL; __do_free char *path = NULL;
__do_free char *controller; __do_free char *controller = NULL;
char *p; char *p;
struct hierarchy *h; struct hierarchy *h;
int ret = -1; int ret = -1;
...@@ -2168,7 +2168,7 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops, ...@@ -2168,7 +2168,7 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops,
h = get_hierarchy(ops, controller); h = get_hierarchy(ops, controller);
if (h) { if (h) {
__do_free char *fullpath; __do_free char *fullpath = NULL;
fullpath = build_full_cgpath_from_monitorpath(h, path, filename); fullpath = build_full_cgpath_from_monitorpath(h, path, filename);
ret = lxc_write_to_file(fullpath, value, strlen(value), false, 0666); ret = lxc_write_to_file(fullpath, value, strlen(value), false, 0666);
...@@ -2186,7 +2186,7 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops, ...@@ -2186,7 +2186,7 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops,
*/ */
static int convert_devpath(const char *invalue, char *dest) static int convert_devpath(const char *invalue, char *dest)
{ {
__do_free char *path; __do_free char *path = NULL;
int n_parts; int n_parts;
char *p, type; char *p, type;
unsigned long minor, major; unsigned long minor, major;
...@@ -2261,7 +2261,7 @@ out: ...@@ -2261,7 +2261,7 @@ out:
static int cg_legacy_set_data(struct cgroup_ops *ops, const char *filename, static int cg_legacy_set_data(struct cgroup_ops *ops, const char *filename,
const char *value) const char *value)
{ {
__do_free char *controller; __do_free char *controller = NULL;
__do_free char *fullpath = NULL; __do_free char *fullpath = NULL;
char *p; char *p;
/* "b|c <2^64-1>:<2^64-1> r|w|m" = 47 chars max */ /* "b|c <2^64-1>:<2^64-1> r|w|m" = 47 chars max */
...@@ -2358,7 +2358,7 @@ static bool __cg_unified_setup_limits(struct cgroup_ops *ops, ...@@ -2358,7 +2358,7 @@ static bool __cg_unified_setup_limits(struct cgroup_ops *ops,
return false; return false;
lxc_list_for_each(iterator, cgroup_settings) { lxc_list_for_each(iterator, cgroup_settings) {
__do_free char *fullpath; __do_free char *fullpath = NULL;
int ret; int ret;
struct lxc_cgroup *cg = iterator->elem; struct lxc_cgroup *cg = iterator->elem;
...@@ -2419,7 +2419,7 @@ static bool cgroup_use_wants_controllers(const struct cgroup_ops *ops, ...@@ -2419,7 +2419,7 @@ static bool cgroup_use_wants_controllers(const struct cgroup_ops *ops,
static void cg_unified_delegate(char ***delegate) static void cg_unified_delegate(char ***delegate)
{ {
__do_free char *tmp; __do_free char *tmp = NULL;
int idx; int idx;
char *standard[] = {"cgroup.subtree_control", "cgroup.threads", NULL}; char *standard[] = {"cgroup.subtree_control", "cgroup.threads", NULL};
...@@ -2451,7 +2451,7 @@ static void cg_unified_delegate(char ***delegate) ...@@ -2451,7 +2451,7 @@ static void cg_unified_delegate(char ***delegate)
static bool cg_hybrid_init(struct cgroup_ops *ops, bool relative, static bool cg_hybrid_init(struct cgroup_ops *ops, bool relative,
bool unprivileged) bool unprivileged)
{ {
__do_free char *basecginfo; __do_free char *basecginfo = NULL;
__do_free char *line = NULL; __do_free char *line = NULL;
__do_fclose FILE *f = NULL; __do_fclose FILE *f = NULL;
int ret; int ret;
...@@ -2610,7 +2610,7 @@ static int cg_is_pure_unified(void) ...@@ -2610,7 +2610,7 @@ static int cg_is_pure_unified(void)
/* Get current cgroup from /proc/self/cgroup for the cgroupfs v2 hierarchy. */ /* Get current cgroup from /proc/self/cgroup for the cgroupfs v2 hierarchy. */
static char *cg_unified_get_current_cgroup(bool relative) static char *cg_unified_get_current_cgroup(bool relative)
{ {
__do_free char *basecginfo; __do_free char *basecginfo = NULL;
char *base_cgroup; char *base_cgroup;
char *copy = NULL; char *copy = NULL;
...@@ -2642,7 +2642,7 @@ static int cg_unified_init(struct cgroup_ops *ops, bool relative, ...@@ -2642,7 +2642,7 @@ static int cg_unified_init(struct cgroup_ops *ops, bool relative,
{ {
__do_free char *subtree_path = NULL; __do_free char *subtree_path = NULL;
int ret; int ret;
char *mountpoint, *tmp; char *mountpoint;
char **delegatable; char **delegatable;
struct hierarchy *new; struct hierarchy *new;
char *base_cgroup = NULL; char *base_cgroup = NULL;
...@@ -2695,7 +2695,7 @@ static bool cg_init(struct cgroup_ops *ops, struct lxc_conf *conf) ...@@ -2695,7 +2695,7 @@ static bool cg_init(struct cgroup_ops *ops, struct lxc_conf *conf)
tmp = lxc_global_config_value("lxc.cgroup.use"); tmp = lxc_global_config_value("lxc.cgroup.use");
if (tmp) { if (tmp) {
__do_free char *pin; __do_free char *pin = NULL;
char *chop, *cur; char *chop, *cur;
pin = must_copy_string(tmp); pin = must_copy_string(tmp);
......
...@@ -817,7 +817,7 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid, ...@@ -817,7 +817,7 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid,
static bool create_db_dir(char *fnam) static bool create_db_dir(char *fnam)
{ {
__do_free char *copy; __do_free char *copy = NULL;
char *p; char *p;
int ret; int ret;
......
...@@ -121,7 +121,7 @@ static bool do_lxcapi_save_config(struct lxc_container *c, const char *alt_file) ...@@ -121,7 +121,7 @@ static bool do_lxcapi_save_config(struct lxc_container *c, const char *alt_file)
static bool config_file_exists(const char *lxcpath, const char *cname) static bool config_file_exists(const char *lxcpath, const char *cname)
{ {
__do_free char *fname; __do_free char *fname = NULL;
int ret; int ret;
size_t len; size_t len;
...@@ -145,7 +145,7 @@ static bool config_file_exists(const char *lxcpath, const char *cname) ...@@ -145,7 +145,7 @@ static bool config_file_exists(const char *lxcpath, const char *cname)
*/ */
static int ongoing_create(struct lxc_container *c) static int ongoing_create(struct lxc_container *c)
{ {
__do_free char *path; __do_free char *path = NULL;
int fd, ret; int fd, ret;
size_t len; size_t len;
struct flock lk = {0}; struct flock lk = {0};
...@@ -191,7 +191,7 @@ static int ongoing_create(struct lxc_container *c) ...@@ -191,7 +191,7 @@ static int ongoing_create(struct lxc_container *c)
static int create_partial(struct lxc_container *c) static int create_partial(struct lxc_container *c)
{ {
__do_free char *path; __do_free char *path = NULL;
int fd, ret; int fd, ret;
size_t len; size_t len;
struct flock lk = {0}; struct flock lk = {0};
...@@ -228,7 +228,7 @@ static int create_partial(struct lxc_container *c) ...@@ -228,7 +228,7 @@ static int create_partial(struct lxc_container *c)
static void remove_partial(struct lxc_container *c, int fd) static void remove_partial(struct lxc_container *c, int fd)
{ {
__do_free char *path; __do_free char *path = NULL;
int ret; int ret;
size_t len; size_t len;
...@@ -525,7 +525,6 @@ WRAP_API(bool, lxcapi_is_running) ...@@ -525,7 +525,6 @@ WRAP_API(bool, lxcapi_is_running)
static bool do_lxcapi_freeze(struct lxc_container *c) static bool do_lxcapi_freeze(struct lxc_container *c)
{ {
int ret;
lxc_state_t s; lxc_state_t s;
if (!c || !c->lxc_conf) if (!c || !c->lxc_conf)
...@@ -542,7 +541,6 @@ WRAP_API(bool, lxcapi_freeze) ...@@ -542,7 +541,6 @@ WRAP_API(bool, lxcapi_freeze)
static bool do_lxcapi_unfreeze(struct lxc_container *c) static bool do_lxcapi_unfreeze(struct lxc_container *c)
{ {
int ret;
lxc_state_t s; lxc_state_t s;
if (!c || !c->lxc_conf) if (!c || !c->lxc_conf)
...@@ -1208,7 +1206,6 @@ static int do_create_container_dir(const char *path, struct lxc_conf *conf) ...@@ -1208,7 +1206,6 @@ static int do_create_container_dir(const char *path, struct lxc_conf *conf)
{ {
__do_free char *p = NULL; __do_free char *p = NULL;
int lasterr; int lasterr;
size_t len;
int ret = -1; int ret = -1;
mode_t mask = umask(0002); mode_t mask = umask(0002);
...@@ -1265,7 +1262,7 @@ static struct lxc_storage *do_storage_create(struct lxc_container *c, ...@@ -1265,7 +1262,7 @@ static struct lxc_storage *do_storage_create(struct lxc_container *c,
const char *type, const char *type,
struct bdev_specs *specs) struct bdev_specs *specs)
{ {
__do_free char *dest; __do_free char *dest = NULL;
int ret; int ret;
size_t len; size_t len;
struct lxc_storage *bdev; struct lxc_storage *bdev;
...@@ -3402,7 +3399,7 @@ err: ...@@ -3402,7 +3399,7 @@ err:
static int copyhooks(struct lxc_container *oldc, struct lxc_container *c) static int copyhooks(struct lxc_container *oldc, struct lxc_container *c)
{ {
__do_free char *cpath; __do_free char *cpath = NULL;
int i, len, ret; int i, len, ret;
struct lxc_list *it; struct lxc_list *it;
...@@ -3565,7 +3562,7 @@ static bool add_rdepends(struct lxc_container *c, struct lxc_container *c0) ...@@ -3565,7 +3562,7 @@ static bool add_rdepends(struct lxc_container *c, struct lxc_container *c0)
bool should_default_to_snapshot(struct lxc_container *c0, bool should_default_to_snapshot(struct lxc_container *c0,
struct lxc_container *c1) struct lxc_container *c1)
{ {
__do_free char *p0, *p1; __do_free char *p0 = NULL, *p1 = NULL;
int ret; int ret;
size_t l0 = strlen(c0->config_path) + strlen(c0->name) + 2; size_t l0 = strlen(c0->config_path) + strlen(c0->name) + 2;
size_t l1 = strlen(c1->config_path) + strlen(c1->name) + 2; size_t l1 = strlen(c1->config_path) + strlen(c1->name) + 2;
...@@ -4094,7 +4091,7 @@ static int lxcapi_attach_run_wait(struct lxc_container *c, lxc_attach_options_t ...@@ -4094,7 +4091,7 @@ static int lxcapi_attach_run_wait(struct lxc_container *c, lxc_attach_options_t
static int get_next_index(const char *lxcpath, char *cname) static int get_next_index(const char *lxcpath, char *cname)
{ {
__do_free char *fname; __do_free char *fname = NULL;
struct stat sb; struct stat sb;
int i = 0, ret; int i = 0, ret;
...@@ -4229,7 +4226,7 @@ static int do_lxcapi_snapshot(struct lxc_container *c, const char *commentfile) ...@@ -4229,7 +4226,7 @@ static int do_lxcapi_snapshot(struct lxc_container *c, const char *commentfile)
} }
if (commentfile) { if (commentfile) {
__do_free char *path; __do_free char *path = NULL;
/* $p / $name / comment \0 */ /* $p / $name / comment \0 */
int len = strlen(snappath) + strlen(newname) + 10; int len = strlen(snappath) + strlen(newname) + 10;
......
...@@ -171,7 +171,7 @@ int lxc_monitor_close(int fd) ...@@ -171,7 +171,7 @@ int lxc_monitor_close(int fd)
*/ */
int lxc_monitor_sock_name(const char *lxcpath, struct sockaddr_un *addr) int lxc_monitor_sock_name(const char *lxcpath, struct sockaddr_un *addr)
{ {
__do_free char *path; __do_free char *path = NULL;
size_t len; size_t len;
int ret; int ret;
uint64_t hash; uint64_t hash;
......
...@@ -550,7 +550,7 @@ out: ...@@ -550,7 +550,7 @@ out:
#define PHYSNAME "/sys/class/net/%s/phy80211/name" #define PHYSNAME "/sys/class/net/%s/phy80211/name"
static char *is_wlan(const char *ifname) static char *is_wlan(const char *ifname)
{ {
__do_free char *path; __do_free char *path = NULL;
int i, ret; int i, ret;
long physlen; long physlen;
size_t len; size_t len;
......
...@@ -97,7 +97,7 @@ static void lxc_destroy_container_on_signal(struct lxc_handler *handler, ...@@ -97,7 +97,7 @@ static void lxc_destroy_container_on_signal(struct lxc_handler *handler,
static void print_top_failing_dir(const char *path) static void print_top_failing_dir(const char *path)
{ {
__do_free char *copy; __do_free char *copy = NULL;
int ret; int ret;
char *e, *p, saved; char *e, *p, saved;
......
...@@ -137,7 +137,7 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, ...@@ -137,7 +137,7 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
int loop_create(struct lxc_storage *bdev, const char *dest, const char *n, int loop_create(struct lxc_storage *bdev, const char *dest, const char *n,
struct bdev_specs *specs) struct bdev_specs *specs)
{ {
__do_free char *srcdev; __do_free char *srcdev = NULL;
const char *fstype; const char *fstype;
uint64_t sz; uint64_t sz;
int ret, len; int ret, len;
......
...@@ -114,7 +114,7 @@ static int do_lvm_create(const char *path, uint64_t size, const char *thinpool) ...@@ -114,7 +114,7 @@ static int do_lvm_create(const char *path, uint64_t size, const char *thinpool)
char *pathdup, *vg, *lv; char *pathdup, *vg, *lv;
char cmd_output[PATH_MAX]; char cmd_output[PATH_MAX];
char sz[24]; char sz[24];
__do_free char *tp; __do_free char *tp = NULL;
struct lvcreate_args cmd_args = {0}; struct lvcreate_args cmd_args = {0};
ret = snprintf(sz, 24, "%" PRIu64 "b", size); ret = snprintf(sz, 24, "%" PRIu64 "b", size);
...@@ -268,7 +268,7 @@ int lvm_umount(struct lxc_storage *bdev) ...@@ -268,7 +268,7 @@ int lvm_umount(struct lxc_storage *bdev)
#define __LVSCMD "lvs --unbuffered --noheadings -o lv_attr %s 2>/dev/null" #define __LVSCMD "lvs --unbuffered --noheadings -o lv_attr %s 2>/dev/null"
int lvm_compare_lv_attr(const char *path, int pos, const char expected) int lvm_compare_lv_attr(const char *path, int pos, const char expected)
{ {
__do_free char *cmd; __do_free char *cmd = NULL;
struct lxc_popen_FILE *f; struct lxc_popen_FILE *f;
int ret, status; int ret, status;
size_t len; size_t len;
......
...@@ -62,7 +62,7 @@ static bool wait_for_partition(const char *path); ...@@ -62,7 +62,7 @@ static bool wait_for_partition(const char *path);
bool attach_nbd(char *src, struct lxc_conf *conf) bool attach_nbd(char *src, struct lxc_conf *conf)
{ {
__do_free char *orig; __do_free char *orig = NULL;
char *p, path[50]; char *p, path[50];
int i = 0; int i = 0;
......
...@@ -568,9 +568,8 @@ struct lxc_storage *storage_create(const char *dest, const char *type, ...@@ -568,9 +568,8 @@ struct lxc_storage *storage_create(const char *dest, const char *type,
/* -B lvm,dir */ /* -B lvm,dir */
if (strchr(type, ',')) { if (strchr(type, ',')) {
__do_free char *dup; __do_free char *dup = NULL;
char *token; char *token;
size_t len;
dup = must_copy_string(type); dup = must_copy_string(type);
lxc_iterate_parts(token, dup, ",") { lxc_iterate_parts(token, dup, ",") {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment