Skip to content

Commit

Permalink
vpc: use DIV_ROUND_UP
Browse files Browse the repository at this point in the history
I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
  • Loading branch information
elmarco committed Aug 31, 2017
1 parent 21cf3e1 commit 13f1493
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/vpc.c
Expand Up @@ -783,7 +783,7 @@ static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
} else {
*secs_per_cyl = 17;
cyls_times_heads = total_sectors / *secs_per_cyl;
*heads = (cyls_times_heads + 1023) / 1024;
*heads = DIV_ROUND_UP(cyls_times_heads, 1024);

if (*heads < 4) {
*heads = 4;
Expand Down Expand Up @@ -836,7 +836,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
offset = 3 * 512;

memset(buf, 0xFF, 512);
for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) {
for (i = 0; i < DIV_ROUND_UP(num_bat_entries * 4, 512); i++) {
ret = blk_pwrite(blk, offset, buf, 512, 0);
if (ret < 0) {
goto fail;
Expand Down

0 comments on commit 13f1493

Please sign in to comment.