[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH 1/2] qemu-img: Fix dd with skip= and count=

From: Eric Blake
Subject: Re: [Qemu-block] [PATCH 1/2] qemu-img: Fix dd with skip= and count=
Date: Wed, 15 Aug 2018 21:17:01 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 08/15/2018 09:03 PM, Max Reitz wrote:

@@ -4559,19 +4559,23 @@ static int img_dd(int argc, char **argv)
          goto out;

+    /* Overflow means the specified offset is beyond input image's size */
+    if (dd.flags & C_SKIP && (in.offset > INT64_MAX / in.bsz ||
+                              size < in.bsz * in.offset)) {
+        size = 0;
+        error_report("%s: cannot skip to specified offset", in.filename);

in_pos should be initialized as well (to "size", I suppose), or my gcc
will continue to complain. :-)

Serves me right for compiling with -g instead of -O2 (gcc only does that warning on optimized builds, for some weird reason). Will fix in v2.

+++ b/tests/qemu-iotests/160
@@ -44,6 +44,7 @@ _supported_os Linux
  TEST_SKIP_BLOCKS="1 2 30 30K"

  for skip in $TEST_SKIP_BLOCKS; do
+  for count in '' 'count=1 '; do

Ah, so this is why we indent everything by four spaces!  So you can
squeeze in three more block headers without having to re-indent
everything.  I finally see. O:-)

I'm seriously thinking of reindenting things in this and the next patch, rather than my initial quick-and-dirty "squeeze it in". 'git diff -w' is not that hard to use, after all.

(Not sure why you put a space after the 'count=1', though, but OK)

For this line:

+    echo "== Converting the image with dd with ${count}skip=$skip =="

so that when $count is empty, the .out file doesn't end up with a double space. Okay, I do have some sense of output aesthetics, even if my re-indentation skills are lacking ;=)

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]