[PATCH v2] qemu-img: Explicit number replaced by a constant

Yi Li posted 1 patch 3 years, 8 months ago
Test docker-quick@centos7 passed
Test docker-mingw@fedora passed
Test checkpatch passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200819013607.32280-1-yili@winhong.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>
qemu-img.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
[PATCH v2] qemu-img: Explicit number replaced by a constant
Posted by Yi Li 3 years, 8 months ago
Signed-off-by: Yi Li <yili@winhong.com>
---
 qemu-img.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 5308773811..aa2e31c8ae 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1200,10 +1200,10 @@ static int is_allocated_sectors(const uint8_t *buf, int n, int *pnum,
         *pnum = 0;
         return 0;
     }
-    is_zero = buffer_is_zero(buf, 512);
+    is_zero = buffer_is_zero(buf, BDRV_SECTOR_SIZE);
     for(i = 1; i < n; i++) {
-        buf += 512;
-        if (is_zero != buffer_is_zero(buf, 512)) {
+        buf += BDRV_SECTOR_SIZE;
+        if (is_zero != buffer_is_zero(buf, BDRV_SECTOR_SIZE)) {
             break;
         }
     }
@@ -2489,8 +2489,8 @@ static int img_convert(int argc, char **argv)
             }
         }
 
-        qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s.total_sectors * 512,
-                            &error_abort);
+        qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
+                            s.total_sectors * BDRV_SECTOR_SIZE, &error_abort);
         ret = add_old_style_options(out_fmt, opts, out_baseimg, NULL);
         if (ret < 0) {
             goto out;
-- 
2.25.3




Re: [PATCH v2] qemu-img: Explicit number replaced by a constant
Posted by Alberto Garcia 3 years, 8 months ago
On Wed 19 Aug 2020 03:36:07 AM CEST, Yi Li wrote:
> Signed-off-by: Yi Li <yili@winhong.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

Re: [PATCH v2] qemu-img: Explicit number replaced by a constant
Posted by Stefano Garzarella 3 years, 8 months ago
On Wed, Aug 19, 2020 at 09:36:07AM +0800, Yi Li wrote:
> Signed-off-by: Yi Li <yili@winhong.com>
> ---
>  qemu-img.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 5308773811..aa2e31c8ae 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1200,10 +1200,10 @@ static int is_allocated_sectors(const uint8_t *buf, int n, int *pnum,
>          *pnum = 0;
>          return 0;
>      }
> -    is_zero = buffer_is_zero(buf, 512);
> +    is_zero = buffer_is_zero(buf, BDRV_SECTOR_SIZE);
>      for(i = 1; i < n; i++) {
> -        buf += 512;
> -        if (is_zero != buffer_is_zero(buf, 512)) {
> +        buf += BDRV_SECTOR_SIZE;
> +        if (is_zero != buffer_is_zero(buf, BDRV_SECTOR_SIZE)) {
>              break;
>          }
>      }
> @@ -2489,8 +2489,8 @@ static int img_convert(int argc, char **argv)
>              }
>          }
>  
> -        qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s.total_sectors * 512,
> -                            &error_abort);
> +        qemu_opt_set_number(opts, BLOCK_OPT_SIZE,
> +                            s.total_sectors * BDRV_SECTOR_SIZE, &error_abort);
>          ret = add_old_style_options(out_fmt, opts, out_baseimg, NULL);
>          if (ret < 0) {
>              goto out;
> -- 
> 2.25.3
> 
> 
> 

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>


Re: [PATCH v2] qemu-img: Explicit number replaced by a constant
Posted by Max Reitz 3 years, 7 months ago
On 19.08.20 03:36, Yi Li wrote:
> Signed-off-by: Yi Li <yili@winhong.com>
> ---
>  qemu-img.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Thanks, applied to my block branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block