]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: use correct lxc_namespace_t type
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 18 Mar 2021 09:40:43 +0000 (10:40 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 21 Apr 2021 08:07:34 +0000 (10:07 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index f2f68f5c345c00f8935cf4c5f1dbfbd508b0cf5f..e4cf17b5a639cebfa4e0b2509c8071dddb1a4eb0 100644 (file)
@@ -194,7 +194,7 @@ static struct attach_context *alloc_attach_context(void)
        ctx->target_host_uid    = LXC_INVALID_UID;
        ctx->target_host_gid    = LXC_INVALID_GID;
 
-       for (int i = 0; i < LXC_NS_MAX; i++)
+       for (lxc_namespace_t i = 0; i < LXC_NS_MAX; i++)
                ctx->ns_fd[i] = -EBADF;
 
        return ctx;
@@ -438,7 +438,7 @@ static int get_attach_context(struct attach_context *ctx,
                if (options->namespaces == -1)
                        return log_error_errno(-EINVAL, EINVAL, "Failed to automatically determine the namespaces which the container uses");
 
-               for (int i = 0; i < LXC_NS_MAX; i++) {
+               for (lxc_namespace_t i = 0; i < LXC_NS_MAX; i++) {
                        if (ns_info[i].clone_flag & CLONE_NEWCGROUP)
                                if (!(options->attach_flags & LXC_ATTACH_MOVE_TO_CGROUP) ||
                                    !cgns_supported())
@@ -533,7 +533,7 @@ static int same_ns(int dfd_pid1, int dfd_pid2, const char *ns_path)
 
 static int __prepare_namespaces_pidfd(struct attach_context *ctx)
 {
-       for (int i = 0; i < LXC_NS_MAX; i++) {
+       for (lxc_namespace_t i = 0; i < LXC_NS_MAX; i++) {
                int ret;
 
                ret = same_nsfd(ctx->dfd_self_pid,
@@ -561,8 +561,8 @@ static int __prepare_namespaces_pidfd(struct attach_context *ctx)
 static int __prepare_namespaces_nsfd(struct attach_context *ctx,
                                     lxc_attach_options_t *options)
 {
-       for (int i = 0; i < LXC_NS_MAX; i++) {
-               int j;
+       for (lxc_namespace_t i = 0; i < LXC_NS_MAX; i++) {
+               lxc_namespace_t j;
 
                if (options->namespaces & ns_info[i].clone_flag)
                        ctx->ns_fd[i] = open_at(ctx->dfd_init_pid,
@@ -644,7 +644,7 @@ static int __attach_namespaces_nsfd(struct attach_context *ctx,
 {
        int fret = 0;
 
-       for (int i = 0; i < LXC_NS_MAX; i++) {
+       for (lxc_namespace_t i = 0; i < LXC_NS_MAX; i++) {
                int ret;
 
                if (ctx->ns_fd[i] < 0)
@@ -672,7 +672,7 @@ static int attach_namespaces(struct attach_context *ctx,
                             lxc_attach_options_t *options)
 {
        if (lxc_log_trace()) {
-               for (int i = 0; i < LXC_NS_MAX; i++) {
+               for (lxc_namespace_t i = 0; i < LXC_NS_MAX; i++) {
                        if (ns_info[i].clone_flag & options->namespaces) {
                                TRACE("Attaching to %s namespace", ns_info[i].proc_name);
                                continue;