[1/2] qemu-img: Use strerror() for generic resize error
diff mbox

Message ID 20160615153630.2116-2-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz June 15, 2016, 3:36 p.m. UTC
Emitting the plain error number is not very helpful. Use strerror()
instead.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 qemu-img.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Blake June 15, 2016, 3:44 p.m. UTC | #1
On 06/15/2016 09:36 AM, Max Reitz wrote:
> Emitting the plain error number is not very helpful. Use strerror()
> instead.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  qemu-img.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 14e2661..d5ccd9a 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -3277,7 +3277,7 @@ static int img_resize(int argc, char **argv)
>          error_report("Image is read-only");
>          break;
>      default:
> -        error_report("Error resizing image (%d)", -ret);
> +        error_report("Error resizing image: %s", strerror(-ret));
>          break;

I've argued in the past that we have lots of error_report() callers
using strerror(), and may want to add an error_report_errno() (similar
to error_setg_errno()); this just adds to the list of things that would
benefit.  But such a conversion would be a separate BiteSized task, and
doesn't invalidate your patch.

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

Patch
diff mbox

diff --git a/qemu-img.c b/qemu-img.c
index 14e2661..d5ccd9a 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3277,7 +3277,7 @@  static int img_resize(int argc, char **argv)
         error_report("Image is read-only");
         break;
     default:
-        error_report("Error resizing image (%d)", -ret);
+        error_report("Error resizing image: %s", strerror(-ret));
         break;
     }
 out: