Skip to content

Commit 4407742

Browse files
this is better
1 parent 262b5bf commit 4407742

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/fs/block_cache.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,7 @@ void block_cache_destroy(block_cache_t **pcache) {
318318
* @return Number of sectors covering @p bytes (at least 1).
319319
*/
320320
static uint32_t sectors_for_len(uint32_t sector_size, uint32_t bytes) {
321-
uint32_t n = bytes / sector_size;
322-
while (n * sector_size < bytes) {
323-
n++;
324-
}
325-
if (n < 1) {
326-
n++;
327-
}
328-
return n;
321+
return (bytes + sector_size - 1) / sector_size + (bytes == 0);
329322
}
330323

331324
int block_cache_read(block_cache_t *c, uint64_t lba, uint32_t bytes, unsigned char *out)

0 commit comments

Comments
 (0)