ext4_mkfs: little function name refactoring
[lwext4.git] / src / ext4_journal.c
index c68d5a14d81f9e018cc342475c1c5f691c1d7016..01a8c0860210bdc6f6fe4374c58b9c2bd7b92aed 100644 (file)
@@ -107,7 +107,7 @@ static inline int32_t
 trans_id_diff(uint32_t x, uint32_t y)
 {
        int32_t diff = x - y;
-       return (diff >= 0);
+       return diff;
 }
 
 static int
@@ -1640,9 +1640,11 @@ int jbd_trans_set_block_dirty(struct jbd_trans *trans,
        rec = RB_FIND(jbd_revoke_tree,
                        &trans->revoke_root,
                        &tmp_rec);
-       if (rec)
+       if (rec) {
                RB_REMOVE(jbd_revoke_tree, &trans->revoke_root,
                          rec);
+               free(rec);
+       }
 
        return EOK;
 }
@@ -1654,8 +1656,16 @@ int jbd_trans_set_block_dirty(struct jbd_trans *trans,
 int jbd_trans_revoke_block(struct jbd_trans *trans,
                           ext4_fsblk_t lba)
 {
-       struct jbd_revoke_rec *rec =
-               calloc(1, sizeof(struct jbd_revoke_rec));
+       struct jbd_revoke_rec tmp_rec = {
+               .lba = lba
+       }, *rec;
+       rec = RB_FIND(jbd_revoke_tree,
+                     &trans->revoke_root,
+                     &tmp_rec);
+       if (rec)
+               return EOK;
+
+       rec = calloc(1, sizeof(struct jbd_revoke_rec));
        if (!rec)
                return ENOMEM;