Skip to content

Commit b06fe85

Browse files
committed
btrfs-progs: check: convert int to bool in a few helpers
Signed-off-by: David Sterba <[email protected]>
1 parent 6a3c7aa commit b06fe85

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

check/main.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -814,12 +814,12 @@ static void free_inode_rec(struct inode_record *rec)
814814
free(rec);
815815
}
816816

817-
static int can_free_inode_rec(struct inode_record *rec)
817+
static bool can_free_inode_rec(struct inode_record *rec)
818818
{
819819
if (!rec->errors && rec->checked && rec->found_inode_item &&
820820
rec->nlink == rec->found_link && list_empty(&rec->backrefs))
821-
return 1;
822-
return 0;
821+
return true;
822+
return false;
823823
}
824824

825825
static void maybe_free_inode_rec(struct cache_tree *inode_cache,
@@ -905,7 +905,7 @@ static int check_orphan_item(struct btrfs_root *root, u64 ino)
905905
return ret;
906906
}
907907

908-
static int process_inode_item(struct extent_buffer *eb,
908+
static bool process_inode_item(struct extent_buffer *eb,
909909
int slot, struct btrfs_key *key,
910910
struct shared_node *active_node)
911911
{
@@ -918,7 +918,7 @@ static int process_inode_item(struct extent_buffer *eb,
918918
BUG_ON(rec->ino != key->objectid || rec->refs > 1);
919919
if (rec->found_inode_item) {
920920
rec->errors |= I_ERR_DUP_INODE_ITEM;
921-
return 1;
921+
return true;
922922
}
923923
item = btrfs_item_ptr(eb, slot, struct btrfs_inode_item);
924924
rec->nlink = btrfs_inode_nlink(eb, item);
@@ -947,7 +947,7 @@ static int process_inode_item(struct extent_buffer *eb,
947947
btrfs_inode_transid(eb, item) > gen_uplimit)
948948
rec->errors |= I_ERR_INVALID_GEN;
949949
maybe_free_inode_rec(&active_node->inode_cache, rec);
950-
return 0;
950+
return false;
951951
}
952952

953953
static struct inode_backref *get_inode_backref(struct inode_record *rec,
@@ -1249,7 +1249,7 @@ static int enter_shared_node(struct btrfs_root *root, u64 bytenr, u32 refs,
12491249
int ret;
12501250

12511251
if (level == wc->active_node)
1252-
return 0;
1252+
return false;
12531253

12541254
BUG_ON(wc->active_node <= level);
12551255
node = find_shared_node(&wc->shared, bytenr);
@@ -1259,7 +1259,7 @@ static int enter_shared_node(struct btrfs_root *root, u64 bytenr, u32 refs,
12591259
node = find_shared_node(&wc->shared, bytenr);
12601260
wc->nodes[level] = node;
12611261
wc->active_node = level;
1262-
return 0;
1262+
return false;
12631263
}
12641264

12651265
if (wc->root_level == wc->active_node &&
@@ -1270,7 +1270,7 @@ static int enter_shared_node(struct btrfs_root *root, u64 bytenr, u32 refs,
12701270
remove_cache_extent(&wc->shared, &node->cache);
12711271
free(node);
12721272
}
1273-
return 1;
1273+
return true;
12741274
}
12751275

12761276
dest = wc->nodes[wc->active_node];
@@ -1279,7 +1279,7 @@ static int enter_shared_node(struct btrfs_root *root, u64 bytenr, u32 refs,
12791279
remove_cache_extent(&wc->shared, &node->cache);
12801280
free(node);
12811281
}
1282-
return 1;
1282+
return true;
12831283
}
12841284

12851285
static int leave_shared_node(struct btrfs_root *root,
@@ -4204,7 +4204,7 @@ static int maybe_free_extent_rec(struct cache_tree *extent_cache,
42044204
return 0;
42054205
}
42064206

4207-
static int check_owner_ref(struct btrfs_root *root,
4207+
static bool check_owner_ref(struct btrfs_root *root,
42084208
struct extent_record *rec,
42094209
struct extent_buffer *buf)
42104210
{
@@ -4215,7 +4215,7 @@ static int check_owner_ref(struct btrfs_root *root,
42154215
struct btrfs_path path;
42164216
struct extent_buffer *parent;
42174217
int level;
4218-
int found = 0;
4218+
bool found = false;
42194219
int ret;
42204220

42214221
rbtree_postorder_for_each_entry_safe(node, tmp,
@@ -4228,14 +4228,14 @@ static int check_owner_ref(struct btrfs_root *root,
42284228
continue;
42294229
back = to_tree_backref(node);
42304230
if (btrfs_header_owner(buf) == back->root)
4231-
return 0;
4231+
return false;
42324232
}
42334233
/*
42344234
* Some unexpected root item referring to this one, return 1 to
42354235
* indicate owner not found
42364236
*/
42374237
if (rec->is_root)
4238-
return 1;
4238+
return true;
42394239

42404240
/* try to find the block by search corresponding fs tree */
42414241
key.objectid = btrfs_header_owner(buf);
@@ -4244,7 +4244,7 @@ static int check_owner_ref(struct btrfs_root *root,
42444244

42454245
ref_root = btrfs_read_fs_root(gfs_info, &key);
42464246
if (IS_ERR(ref_root))
4247-
return 1;
4247+
return true;
42484248

42494249
level = btrfs_header_level(buf);
42504250
if (level == 0)
@@ -4256,15 +4256,15 @@ static int check_owner_ref(struct btrfs_root *root,
42564256
path.lowest_level = level + 1;
42574257
ret = btrfs_search_slot(NULL, ref_root, &key, &path, 0, 0);
42584258
if (ret < 0)
4259-
return 0;
4259+
return false;
42604260

42614261
parent = path.nodes[level + 1];
42624262
if (parent && buf->start == btrfs_node_blockptr(parent,
42634263
path.slots[level + 1]))
4264-
found = 1;
4264+
found = true;
42654265

42664266
btrfs_release_path(&path);
4267-
return found ? 0 : 1;
4267+
return !found;
42684268
}
42694269

42704270
static int is_extent_tree_record(struct extent_record *rec)
@@ -6050,20 +6050,20 @@ static int check_csums(void)
60506050
return ret;
60516051
}
60526052

6053-
static int is_dropped_key(struct btrfs_key *key,
6053+
static bool is_dropped_key(struct btrfs_key *key,
60546054
struct btrfs_key *drop_key)
60556055
{
60566056
if (key->objectid < drop_key->objectid)
6057-
return 1;
6057+
return true;
60586058
else if (key->objectid == drop_key->objectid) {
60596059
if (key->type < drop_key->type)
6060-
return 1;
6060+
return true;
60616061
else if (key->type == drop_key->type) {
60626062
if (key->offset < drop_key->offset)
6063-
return 1;
6063+
return true;
60646064
}
60656065
}
6066-
return 0;
6066+
return false;
60676067
}
60686068

60696069
/*

check/mode-common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ static inline u8 imode_to_type(u32 imode)
101101
#undef S_SHIFT
102102
}
103103

104-
static inline int fs_root_objectid(u64 objectid)
104+
static inline bool fs_root_objectid(u64 objectid)
105105
{
106106
if (objectid == BTRFS_TREE_RELOC_OBJECTID ||
107107
objectid == BTRFS_DATA_RELOC_TREE_OBJECTID)
108-
return 1;
108+
return true;
109109
return is_fstree(objectid);
110110
}
111111

check/mode-lowmem.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int calc_extent_flag(struct btrfs_root *root, struct extent_buffer *eb,
153153
* in every fs or file tree check. Here we find its all root ids, and only check
154154
* it in the fs or file tree which has the smallest root id.
155155
*/
156-
static int need_check(struct btrfs_root *root, struct ulist *roots)
156+
static bool need_check(struct btrfs_root *root, struct ulist *roots)
157157
{
158158
struct rb_node *node;
159159
struct ulist_node *u;
@@ -164,7 +164,7 @@ static int need_check(struct btrfs_root *root, struct ulist *roots)
164164
* the tree owner to ensure some other root will check it.
165165
*/
166166
if (roots->nnodes == 1 || roots->nnodes == 0)
167-
return 1;
167+
return true;
168168

169169
node = rb_first(&roots->root);
170170
u = rb_entry(node, struct ulist_node, rb_node);
@@ -173,9 +173,9 @@ static int need_check(struct btrfs_root *root, struct ulist *roots)
173173
* in the fs or file tree who hash the smallest root id.
174174
*/
175175
if (root->objectid != u->val)
176-
return 0;
176+
return false;
177177

178-
return 1;
178+
return true;
179179
}
180180

181181
/*
@@ -2958,24 +2958,24 @@ static int process_one_leaf(struct btrfs_root *root, struct btrfs_path *path,
29582958
* @level if @level == -1 means extent data item
29592959
* else normal treeblock.
29602960
*/
2961-
static int should_check_extent_strictly(struct btrfs_root *root,
2961+
static bool should_check_extent_strictly(struct btrfs_root *root,
29622962
struct node_refs *nrefs, int level)
29632963
{
29642964
int root_level = btrfs_header_level(root->node);
29652965

29662966
if (level > root_level || level < -1)
2967-
return 1;
2967+
return true;
29682968
if (level == root_level)
2969-
return 1;
2969+
return true;
29702970
/*
29712971
* if the upper node is marked full backref, it should contain shared
29722972
* backref of the parent (except owner == root->objectid).
29732973
*/
29742974
while (++level <= root_level)
29752975
if (nrefs->refs[level] > 1)
2976-
return 0;
2976+
return false;
29772977

2978-
return 1;
2978+
return true;
29792979
}
29802980

29812981
static int check_extent_inline_ref(struct extent_buffer *eb,

0 commit comments

Comments
 (0)