From: Yang Xu <xuyang2018.jy@fujitsu.com>
To: <fstests@vger.kernel.org>
Cc: Yang Xu <xuyang2018.jy@fujitsu.com>
Subject: [PATCH v1 1/4] src/idmapped-mounts: Fix an error for the loop initialization declaration
Date: Wed, 1 Sep 2021 20:43:23 +0800 [thread overview]
Message-ID: <1630500206-15545-1-git-send-email-xuyang2018.jy@fujitsu.com> (raw)
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
src/idmapped-mounts/idmapped-mounts.c | 30 +++++++++++++--------------
src/idmapped-mounts/utils.c | 3 ++-
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
index 40eb2cc6..e83f8b04 100644
--- a/src/idmapped-mounts/idmapped-mounts.c
+++ b/src/idmapped-mounts/idmapped-mounts.c
@@ -8838,6 +8838,7 @@ static int nested_userns(void)
int fret = -1;
int ret;
pid_t pid;
+ unsigned int id;
struct list *it, *next;
struct userns_hierarchy hierarchy[] = {
{ .level = 1, .fd_userns = -EBADF, },
@@ -8979,7 +8980,7 @@ static int nested_userns(void)
goto out;
}
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
char file[256];
snprintf(file, sizeof(file), DIR1 "/" FILE1 "_%u", id);
@@ -9067,7 +9068,7 @@ static int nested_userns(void)
}
/* Verify that ownership looks correct for callers in the init userns. */
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
bool bret;
unsigned int id_level1, id_level2, id_level3;
char file[256];
@@ -9117,7 +9118,7 @@ static int nested_userns(void)
if (!switch_userns(attr_level1.userns_fd, 0, 0, false))
die("failure: switch_userns");
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
bool bret;
unsigned int id_level1, id_level2, id_level3;
char file[256];
@@ -9164,7 +9165,7 @@ static int nested_userns(void)
if (!switch_userns(attr_level2.userns_fd, 0, 0, false))
die("failure: switch_userns");
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
bool bret;
unsigned int id_level2, id_level3;
char file[256];
@@ -9210,7 +9211,7 @@ static int nested_userns(void)
if (!switch_userns(attr_level3.userns_fd, 0, 0, false))
die("failure: switch_userns");
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
bool bret;
unsigned int id_level2, id_level3;
char file[256];
@@ -9267,7 +9268,7 @@ static int nested_userns(void)
if (setns(attr_level4.userns_fd, CLONE_NEWUSER))
die("failure: switch_userns");
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
char file[256];
snprintf(file, sizeof(file), FILE1 "_%u", id);
@@ -9300,7 +9301,7 @@ static int nested_userns(void)
if (!switch_userns(attr_level1.userns_fd, 0, 0, false))
die("failure: switch_userns");
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
bool bret;
unsigned int id_level1, id_level2, id_level3, id_new;
char file[256];
@@ -9355,7 +9356,7 @@ static int nested_userns(void)
if (!switch_userns(attr_level2.userns_fd, 0, 0, false))
die("failure: switch_userns");
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
bool bret;
unsigned int id_level2, id_level3, id_new;
char file[256];
@@ -9409,7 +9410,7 @@ static int nested_userns(void)
if (!switch_userns(attr_level3.userns_fd, 0, 0, false))
die("failure: switch_userns");
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
unsigned int id_new;
char file[256];
@@ -9479,7 +9480,7 @@ static int nested_userns(void)
if (setns(attr_level4.userns_fd, CLONE_NEWUSER))
die("failure: switch_userns");
- for (unsigned int id = 0; id <= id_file_range; id++) {
+ for (id = 0; id <= id_file_range; id++) {
char file[256];
unsigned long id_new;
@@ -9909,7 +9910,6 @@ static int append_stack(struct btrfs_iter *iter, uint64_t tree_id, size_t path_l
if (iter->stack_len >= iter->stack_capacity) {
size_t new_capacity = iter->stack_capacity * 2;
struct btrfs_stack *new_search_stack;
-
new_search_stack = reallocarray(iter->search_stack, new_capacity,
sizeof(*iter->search_stack));
if (!new_search_stack)
@@ -12932,7 +12932,7 @@ out:
*/
static int btrfs_subvolume_lookup_user(void)
{
- int fret = -1;
+ int fret = -1, i;
int dir1_fd = -EBADF, dir2_fd = -EBADF, mnt_fd = -EBADF,
open_tree_fd = -EBADF, tree_fd = -EBADF, userns_fd = -EBADF;
int subvolume_fds[BTRFS_SUBVOLUME_SUBVOL4_ID + 1];
@@ -12947,10 +12947,10 @@ static int btrfs_subvolume_lookup_user(void)
if (!caps_supported())
return 0;
- for (int i = 0; i < ARRAY_SIZE(subvolume_fds); i++)
+ for (i = 0; i < ARRAY_SIZE(subvolume_fds); i++)
subvolume_fds[i] = -EBADF;
- for (int i = 0; i < ARRAY_SIZE(subvolume_ids); i++)
+ for (i = 0; i < ARRAY_SIZE(subvolume_ids); i++)
subvolume_ids[i] = -EINVAL;
if (btrfs_create_subvolume(t_mnt_scratch_fd, BTRFS_SUBVOLUME_SUBVOL1)) {
@@ -13312,7 +13312,7 @@ out:
safe_close(open_tree_fd);
safe_close(tree_fd);
safe_close(userns_fd);
- for (int i = 0; i < ARRAY_SIZE(subvolume_fds); i++)
+ for (i = 0; i < ARRAY_SIZE(subvolume_fds); i++)
safe_close(subvolume_fds[i]);
snprintf(t_buf, sizeof(t_buf), "%s/%s", t_mountpoint, BTRFS_SUBVOLUME_MNT);
sys_umount2(t_buf, MNT_DETACH);
diff --git a/src/idmapped-mounts/utils.c b/src/idmapped-mounts/utils.c
index 6ffd6a23..c2afa8dc 100644
--- a/src/idmapped-mounts/utils.c
+++ b/src/idmapped-mounts/utils.c
@@ -140,11 +140,12 @@ static int map_ids_from_idmap(struct list *idmap, pid_t pid)
int fill, left;
char mapbuf[4096] = {};
bool had_entry = false;
+ idmap_type_t map_type, u_or_g;
if (list_empty(idmap))
return 0;
- for (idmap_type_t map_type = ID_TYPE_UID, u_or_g = 'u';
+ for (map_type = ID_TYPE_UID, u_or_g = 'u';
map_type <= ID_TYPE_GID; map_type++, u_or_g = 'g') {
char *pos = mapbuf;
int ret;
--
2.23.0
next reply other threads:[~2021-09-01 12:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-01 12:43 Yang Xu [this message]
2021-09-01 12:43 ` [PATCH v1 2/4] configure.ac: Fix uncorrect detection because of linux/btrfs.h Yang Xu
2021-09-01 12:43 ` [PATCH v1 3/4] src/idmapped-mounts/idmapped-mounts.c: Use renameat instead of renameat2 Yang Xu
2021-09-01 12:43 ` [PATCH v1 4/4] src/idmapped-mounts/idmapped-mounts.c: Fix build error because of undefined reallocarray Yang Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1630500206-15545-1-git-send-email-xuyang2018.jy@fujitsu.com \
--to=xuyang2018.jy@fujitsu.com \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).