[PATCH 3/4] qemu-img: remove unused variable

mrezanin@redhat.com posted 4 patches 3 years, 3 months ago
Maintainers: Jason Wang <jasowang@redhat.com>, Sven Schnelle <svens@stackframe.org>, Gerd Hoffmann <kraxel@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
[PATCH 3/4] qemu-img: remove unused variable
Posted by mrezanin@redhat.com 3 years, 3 months ago
From: Miroslav Rezanina <mrezanin@redhat.com>

Variable block_count used in img_dd function is only incremented but never read.
This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.

Removing the variable to prevent the warning.

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 qemu-img.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index a3b64c88af..a9b3a8103c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4922,7 +4922,7 @@ static int img_dd(int argc, char **argv)
     const char *out_fmt = "raw";
     const char *fmt = NULL;
     int64_t size = 0;
-    int64_t block_count = 0, out_pos, in_pos;
+    int64_t out_pos, in_pos;
     bool force_share = false;
     struct DdInfo dd = {
         .flags = 0,
@@ -5122,7 +5122,7 @@ static int img_dd(int argc, char **argv)
 
     in.buf = g_new(uint8_t, in.bsz);
 
-    for (out_pos = 0; in_pos < size; block_count++) {
+    for (out_pos = 0; in_pos < size; ) {
         int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
 
         ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
-- 
2.31.1
Re: [PATCH 3/4] qemu-img: remove unused variable
Posted by Thomas Huth 3 years, 3 months ago
On 09/11/2022 16.57, mrezanin@redhat.com wrote:
> From: Miroslav Rezanina <mrezanin@redhat.com>
> 
> Variable block_count used in img_dd function is only incremented but never read.
> This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
> 
> Removing the variable to prevent the warning.
> 
> Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> ---
>   qemu-img.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index a3b64c88af..a9b3a8103c 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -4922,7 +4922,7 @@ static int img_dd(int argc, char **argv)
>       const char *out_fmt = "raw";
>       const char *fmt = NULL;
>       int64_t size = 0;
> -    int64_t block_count = 0, out_pos, in_pos;
> +    int64_t out_pos, in_pos;
>       bool force_share = false;
>       struct DdInfo dd = {
>           .flags = 0,
> @@ -5122,7 +5122,7 @@ static int img_dd(int argc, char **argv)
>   
>       in.buf = g_new(uint8_t, in.bsz);
>   
> -    for (out_pos = 0; in_pos < size; block_count++) {
> +    for (out_pos = 0; in_pos < size; ) {
>           int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
>   
>           ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);

Reviewed-by: Thomas Huth <thuth@redhat.com>