* [PATCH] qemu-img: Explicit number replaced by a constant
@ 2020-08-17 11:01 Yi Li
2020-08-18 7:19 ` Stefano Garzarella
0 siblings, 1 reply; 7+ messages in thread
From: Yi Li @ 2020-08-17 11:01 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, yilikernel, qemu-devel, yili, mreitz
Signed-off-by: Yi Li <yili@winhong.com>
---
qemu-img.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 5308773811..a0fbc2757c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1181,7 +1181,7 @@ static int64_t find_nonzero(const uint8_t *buf, int64_t n)
}
/*
- * Returns true iff the first sector pointed to by 'buf' contains at least
+ * Returns true if the first sector pointed to by 'buf' contains at least
* a non-NUL byte.
*
* 'pnum' is set to the number of sectors (including and immediately following
@@ -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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] qemu-img: Explicit number replaced by a constant
2020-08-17 11:01 [PATCH] qemu-img: Explicit number replaced by a constant Yi Li
@ 2020-08-18 7:19 ` Stefano Garzarella
2020-08-18 11:51 ` Max Reitz
0 siblings, 1 reply; 7+ messages in thread
From: Stefano Garzarella @ 2020-08-18 7:19 UTC (permalink / raw)
To: Yi Li; +Cc: kwolf, yilikernel, qemu-devel, qemu-block, mreitz
Hi Yi Li,
thanks for this patch! Just a comment below:
On Mon, Aug 17, 2020 at 07:01:13PM +0800, Yi Li wrote:
> Signed-off-by: Yi Li <yili@winhong.com>
> ---
> qemu-img.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/qemu-img.c b/qemu-img.c
> index 5308773811..a0fbc2757c 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1181,7 +1181,7 @@ static int64_t find_nonzero(const uint8_t *buf, int64_t n)
> }
>
> /*
> - * Returns true iff the first sector pointed to by 'buf' contains at least
> + * Returns true if the first sector pointed to by 'buf' contains at least
This change seems unrelated, please can you put this in a separate patch?
Thanks,
Stefano
> * a non-NUL byte.
> *
> * 'pnum' is set to the number of sectors (including and immediately following
> @@ -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
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] qemu-img: Explicit number replaced by a constant
2020-08-18 7:19 ` Stefano Garzarella
@ 2020-08-18 11:51 ` Max Reitz
2020-08-19 1:36 ` [PATCH v2] " Yi Li
0 siblings, 1 reply; 7+ messages in thread
From: Max Reitz @ 2020-08-18 11:51 UTC (permalink / raw)
To: Stefano Garzarella, Yi Li; +Cc: kwolf, yilikernel, qemu-devel, qemu-block
[-- Attachment #1.1: Type: text/plain, Size: 873 bytes --]
On 18.08.20 09:19, Stefano Garzarella wrote:
> Hi Yi Li,
> thanks for this patch! Just a comment below:
>
> On Mon, Aug 17, 2020 at 07:01:13PM +0800, Yi Li wrote:
>> Signed-off-by: Yi Li <yili@winhong.com>
>> ---
>> qemu-img.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/qemu-img.c b/qemu-img.c
>> index 5308773811..a0fbc2757c 100644
>> --- a/qemu-img.c
>> +++ b/qemu-img.c
>> @@ -1181,7 +1181,7 @@ static int64_t find_nonzero(const uint8_t *buf, int64_t n)
>> }
>>
>> /*
>> - * Returns true iff the first sector pointed to by 'buf' contains at least
>> + * Returns true if the first sector pointed to by 'buf' contains at least
>
> This change seems unrelated, please can you put this in a separate patch?
It’s also just not a correct change, as “iff” means “if and only if”.
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] qemu-img: Explicit number replaced by a constant
2020-08-18 11:51 ` Max Reitz
@ 2020-08-19 1:36 ` Yi Li
2020-08-19 8:48 ` Alberto Garcia
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Yi Li @ 2020-08-19 1:36 UTC (permalink / raw)
To: qemu-block, mreitz, sgarzare; +Cc: kwolf, yilikernel, qemu-devel, yili
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] qemu-img: Explicit number replaced by a constant
2020-08-19 1:36 ` [PATCH v2] " Yi Li
@ 2020-08-19 8:48 ` Alberto Garcia
2020-08-19 8:57 ` Stefano Garzarella
2020-09-07 9:08 ` Max Reitz
2 siblings, 0 replies; 7+ messages in thread
From: Alberto Garcia @ 2020-08-19 8:48 UTC (permalink / raw)
To: Yi Li, qemu-block, mreitz, sgarzare; +Cc: kwolf, yilikernel, qemu-devel, yili
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] qemu-img: Explicit number replaced by a constant
2020-08-19 1:36 ` [PATCH v2] " Yi Li
2020-08-19 8:48 ` Alberto Garcia
@ 2020-08-19 8:57 ` Stefano Garzarella
2020-09-07 9:08 ` Max Reitz
2 siblings, 0 replies; 7+ messages in thread
From: Stefano Garzarella @ 2020-08-19 8:57 UTC (permalink / raw)
To: Yi Li; +Cc: kwolf, yilikernel, qemu-devel, qemu-block, mreitz
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] qemu-img: Explicit number replaced by a constant
2020-08-19 1:36 ` [PATCH v2] " Yi Li
2020-08-19 8:48 ` Alberto Garcia
2020-08-19 8:57 ` Stefano Garzarella
@ 2020-09-07 9:08 ` Max Reitz
2 siblings, 0 replies; 7+ messages in thread
From: Max Reitz @ 2020-09-07 9:08 UTC (permalink / raw)
To: Yi Li, qemu-block, sgarzare; +Cc: kwolf, yilikernel, qemu-devel
[-- Attachment #1.1: Type: text/plain, Size: 268 bytes --]
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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-07 9:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 11:01 [PATCH] qemu-img: Explicit number replaced by a constant Yi Li
2020-08-18 7:19 ` Stefano Garzarella
2020-08-18 11:51 ` Max Reitz
2020-08-19 1:36 ` [PATCH v2] " Yi Li
2020-08-19 8:48 ` Alberto Garcia
2020-08-19 8:57 ` Stefano Garzarella
2020-09-07 9:08 ` Max Reitz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.