Rewrite file_kill_block
commitf54b332e7308fa9a66959325890bc893214bb6b2
authorPetr Tesarik <petr@tesarici.cz>
Mon, 22 Oct 2012 20:37:54 +0000 (22 22:37 +0200)
committerPetr Tesarik <petr@tesarici.cz>
Mon, 22 Oct 2012 20:37:54 +0000 (22 22:37 +0200)
tree71ba243fcd0ad43b5ac8aff84351ec4fda55313e
parente98bb2830442ecfd26b10539a9fa3aa1d1f20bdd
Rewrite file_kill_block

Reorganize file_kill_block() to improve readability:

1. deal with non-virtual blocks first, because they're easy
2. make sure that flags do not change when merging

With the current set of flags, any difference is an obstacle for
merging. Note that checking for exact match allows me to remove
several checks:

1. I don't have to check HED_BLOCK_TERMINAL, because there is always
   only one block with this flag => if one of the two blocks has this
   flag, the other one cannot have it too, so there is no match.

2. I don't have to check HED_BLOCK_EOF, because two EOF virtual blocks
   can be merged and two non-EOF virtual blocks can also be merged. I
   only cannot merge an EOF block with a non-EOF block.

3. I don't have to check HED_BLOCK_BAD, because two bad blocks can merge.
   OTOH a bad block cannot be merged. Note that there cannot be a bad
   EOF block, because read is never even attempted beyond EOF.

4. I don't have to care about HED_BLOCK_DIRTY and HED_BLOCK_INSERTED,
   because these flags are never set for a virtual block.

5. I don't have to care about HED_BLOCK_EXCACHE, because all virtual
   blocks have this flag.
libhed/file.c