[f2fs] code refactoring: recovery.cc
Change struct xxx to xxx (recovery.cc)
(comment: #312 https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/520881/2)
Change C style cast to static_cast (recovery.cc)
(comment: #571 https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/520880)
Change unsigned int style to uint32_t (recovery.cc)
(comment: #142 https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/511840)
Change-Id: I621c17d438cc13e9356f7c4091e9241907231145
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/530803
Reviewed-by: Brett Wilson <brettw@google.com>
diff --git a/recovery.cc b/recovery.cc
index d8f7c6d..57cabc7 100644
--- a/recovery.cc
+++ b/recovery.cc
@@ -14,12 +14,12 @@
return true;
}
-struct fsync_inode_entry *F2fs::GetFsyncInode(list_node_t *head, nid_t ino) {
+fsync_inode_entry *F2fs::GetFsyncInode(list_node_t *head, nid_t ino) {
list_node_t *this_node;
- struct fsync_inode_entry *entry;
+ fsync_inode_entry *entry;
list_for_every(head, this_node) {
- entry = containerof(this_node, struct fsync_inode_entry, list);
+ entry = containerof(this_node, fsync_inode_entry, list);
if (entry->vnode->Ino() == ino)
return entry;
}
@@ -27,11 +27,11 @@
}
zx_status_t F2fs::RecoverDentry(Page *ipage, VnodeF2fs *vnode) {
- struct f2fs_node *raw_node = (struct f2fs_node *)PageAddress(ipage);
- struct f2fs_inode *raw_inode = &(raw_node->i);
+ f2fs_node *raw_node = static_cast<f2fs_node *>(PageAddress(ipage));
+ f2fs_inode *raw_inode = &(raw_node->i);
fbl::RefPtr<VnodeF2fs> dir_refptr;
Dir *dir;
- struct f2fs_dir_entry *de;
+ f2fs_dir_entry *de;
Page *page;
zx_status_t err = ZX_OK;
@@ -43,7 +43,7 @@
goto out;
}
- dir = (Dir *)dir_refptr.get();
+ dir = static_cast<Dir *>(dir_refptr.get());
#if 0 // porting needed
// parent.d_inode = dir;
@@ -71,7 +71,7 @@
zx_status_t F2fs::RecoverInode(VnodeF2fs *vnode, Page *node_page) {
void *kaddr = PageAddress(node_page);
- struct f2fs_node *raw_node = static_cast<struct f2fs_node *>(kaddr);
+ struct f2fs_node *raw_node = static_cast<f2fs_node *>(kaddr);
struct f2fs_inode *raw_inode = &(raw_node->i);
vnode->i_mode_ = LeToCpu(raw_inode->i_mode);
@@ -88,8 +88,8 @@
zx_status_t F2fs::FindFsyncDnodes(list_node_t *head) {
f2fs_sb_info &sbi = SbInfo();
- unsigned long long cp_ver = LeToCpu(sbi.ckpt->checkpoint_ver);
- struct curseg_info *curseg;
+ uint64_t cp_ver = LeToCpu(sbi.ckpt->checkpoint_ver);
+ curseg_info *curseg;
fbl::RefPtr<VnodeF2fs> vnode_refptr;
Page *page;
block_t blkaddr;
@@ -110,9 +110,9 @@
#endif
while (true) {
- struct fsync_inode_entry *entry;
+ fsync_inode_entry *entry;
void *kaddr = PageAddress(page);
- rn = (struct f2fs_node *)kaddr;
+ rn = static_cast<f2fs_node *>(kaddr);
if (VnodeF2fs::Readpage(this, page, blkaddr, kReadSync)) {
goto out;
@@ -158,7 +158,7 @@
list_add_tail(&entry->list, head);
// vnode_refptr.reset(entry->vnode);
// err = VnodeF2fs::Vget(this, Nodemgr().InoOfNode(page), &vnode_refptr);
- rn = (struct f2fs_node *)PageAddress(page);
+ rn = static_cast<f2fs_node *>(PageAddress(page));
ri = &(rn->i);
entry->vnode = vnode_refptr.get();
@@ -190,9 +190,9 @@
void F2fs::DestroyFsyncDnodes(list_node_t *head) {
list_node_t *this_node;
- struct fsync_inode_entry *entry;
+ fsync_inode_entry *entry;
list_for_every(head, this_node) {
- entry = containerof(this_node, struct fsync_inode_entry, list);
+ entry = containerof(this_node, fsync_inode_entry, list);
Iput(entry->vnode);
list_delete(&entry->list);
#if 0 // porting needed
@@ -204,10 +204,10 @@
void F2fs::CheckIndexInPrevNodes(block_t blkaddr) {
f2fs_sb_info &sbi = SbInfo();
- struct seg_entry *sentry;
- unsigned int segno = GET_SEGNO(&sbi, blkaddr);
- unsigned short blkoff = GET_SEGOFF_FROM_SEG0(&sbi, blkaddr) & (sbi.blocks_per_seg - 1);
- struct f2fs_summary sum;
+ seg_entry *sentry;
+ uint32_t segno = GET_SEGNO(&sbi, blkaddr);
+ uint16_t blkoff = GET_SEGOFF_FROM_SEG0(&sbi, blkaddr) & (sbi.blocks_per_seg - 1);
+ f2fs_summary sum;
nid_t ino;
void *kaddr;
fbl::RefPtr<VnodeF2fs> vnode_refptr;
@@ -223,7 +223,7 @@
/* Get the previous summary */
for (i = CURSEG_WARM_DATA; i <= CURSEG_COLD_DATA; i++) {
- struct curseg_info *curseg = Segmgr().CURSEG_I(&sbi, i);
+ curseg_info *curseg = Segmgr().CURSEG_I(&sbi, i);
if (curseg->segno == segno) {
sum = curseg->sum_blk->entries[blkoff];
break;
@@ -231,9 +231,9 @@
}
if (i > CURSEG_COLD_DATA) {
Page *sum_page = Segmgr().GetSumPage(segno);
- struct f2fs_summary_block *sum_node;
+ f2fs_summary_block *sum_node;
kaddr = PageAddress(sum_page);
- sum_node = static_cast<struct f2fs_summary_block *>(kaddr);
+ sum_node = static_cast<f2fs_summary_block *>(kaddr);
sum = sum_node->entries[blkoff];
F2fsPutPage(sum_page, 1);
}
@@ -262,10 +262,10 @@
}
void F2fs::DoRecoverData(VnodeF2fs *vnode, Page *page, block_t blkaddr) {
- unsigned int start, end;
- struct dnode_of_data dn;
- struct f2fs_summary sum;
- struct node_info ni;
+ uint32_t start, end;
+ dnode_of_data dn;
+ f2fs_summary sum;
+ node_info ni;
start = StartBidxOfNode(Nodemgr().OfsOfNode(page));
if (IS_INODE(page)) {
@@ -329,7 +329,7 @@
void F2fs::RecoverData(list_node_t *head, int type) {
f2fs_sb_info &sbi = SbInfo();
uint64_t cp_ver = LeToCpu(sbi.ckpt->checkpoint_ver);
- struct curseg_info *curseg;
+ curseg_info *curseg;
Page *page;
block_t blkaddr;
@@ -346,7 +346,7 @@
#endif
while (true) {
- struct fsync_inode_entry *entry;
+ fsync_inode_entry *entry;
if (VnodeF2fs::Readpage(this, page, blkaddr, kReadSync))
goto out;
@@ -389,7 +389,7 @@
#if 0 // porting needed
// fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry",
- // sizeof(struct fsync_inode_entry), NULL);
+ // sizeof(fsync_inode_entry), NULL);
// if (unlikely(!fsync_entry_slab))
// return;
#endif