diff mbox

[v2,09/29] vpc: use DIV_ROUND_UP

Message ID 20170713163219.9024-10-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 13, 2017, 4:31 p.m. UTC
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>
---
 block/vpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Eric Blake July 13, 2017, 8:20 p.m. UTC | #1
On 07/13/2017 11:31 AM, Marc-André Lureau wrote:
> 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>
> ---
>  block/vpc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/vpc.c b/block/vpc.c
> index 9a6f8173a5..c88dc72491 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -760,7 +760,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;
> @@ -813,7 +813,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;
>
Richard Henderson July 14, 2017, 8:34 a.m. UTC | #2
On 07/13/2017 06:31 AM, Marc-André Lureau wrote:
> 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>
> ---
>   block/vpc.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
diff mbox

Patch

diff --git a/block/vpc.c b/block/vpc.c
index 9a6f8173a5..c88dc72491 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -760,7 +760,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;
@@ -813,7 +813,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;