Skip to contentSkip to conversation

Remove dead-code (else-block) from block-qcow.c

PATCH In review Marc Bevand 3 participants 6 messages Jun 3, 2008 – Jun 5, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove dead-code (else-block) from block-qcow.c

X-BeenThere: [email protected]
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: [email protected]
List-Id: qemu-devel.nongnu.org
List-Unsubscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
<mailto:[email protected]?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/qemu-devel>
List-Post: <mailto:[email protected]>
List-Help: <mailto:[email protected]?subject=help>
List-Subscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
<mailto:[email protected]?subject=subscribe>
X-List-Received-Date: Tue, 03 Jun 2008 05:49:44 -0000

"if (allocate == 1)" is always true because the value of "allocate" is checked a few lines above.

Patch made against SVN's rev 4622.

Signed-off-by Marc Bevand <m.bevand <at> gmail.com>

Please see:
http://etud.epita.fr/~bevand_m/pub/qemu-qcow-remove-dead-code.patch

#1 lore raw
Quoted 18 lines · Marc Bevand

X-BeenThere: [email protected]
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: [email protected]
List-Id: qemu-devel.nongnu.org
List-Unsubscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
<mailto:[email protected]?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/qemu-devel>
List-Post: <mailto:[email protected]>
List-Help: <mailto:[email protected]?subject=help>
List-Subscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
<mailto:[email protected]?subject=subscribe>
Sender: [email protected]
Errors-To: [email protected]

"if (allocate == 1)" is always true because the value of "allocate" is checked a few lines above.

Quoted 6 lines

Patch made against SVN's rev 4622.

Signed-off-by Marc Bevand <m.bevand <at> gmail.com>

Please see:
http://etud.epita.fr/~bevand_m/pub/qemu-qcow-remove-dead-code.patch

Uhm, what funny thing is this and why is my name in there? O.o

(Did mailman mess up?)

Vegard

Signature · 4 lines
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
#3 lore raw
In reply to Marc Bevand
Quoted 18 lines · Marc Bevand

X-BeenThere: [email protected]
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: [email protected]
List-Id: qemu-devel.nongnu.org
List-Unsubscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
<mailto:[email protected]?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/qemu-devel>
List-Post: <mailto:[email protected]>
List-Help: <mailto:[email protected]?subject=help>
List-Subscribe: <http://lists.nongnu.org/mailman/listinfo/qemu-devel>,
<mailto:[email protected]?subject=subscribe>
Sender: [email protected]
Errors-To: [email protected]

"if (allocate == 1)" is always true because the value of "allocate" is checked a few lines above.

Quoted 7 lines

Patch made against SVN's rev 4622.

Signed-off-by Marc Bevand <m.bevand <at> gmail.com>

Please see:
http://etud.epita.fr/~bevand_m/pub/qemu-qcow-remove-dead-code.patch

Please send the patch as an attachment or inlined.

Regards,

Anthony Liguori

Quoted 2 lines
#4 lore raw
Quoted 2 lines · Anthony Liguori

Please send the patch as an attachment or inlined.

Here it is. (I originally wanted to inline it but I am currently stuck with MUAs that cannot be configured to NOT wrap text lines.)

To answer Vegard's question, It's gmane that corrupted my email.

Signature · 1 line
Marc Bevand

[PATCH] Remove dead-code (else-block) from block-qcow.c

"if (allocate == 1)" is always true because the value of "allocate" is checked a few lines above.

Patch made against SVN's rev 4622.

Signed-off-by Marc Bevand <m.bevand <at> gmail.com>
block-qcow.c +20 -25
Index: block-qcow.c
===================================================================
@@ -339,33 +339,28 @@
                 return -1;
         } else {
             cluster_offset = bdrv_getlength(s->hd);
-            if (allocate == 1) {
-                /* round to cluster size */
-                cluster_offset = (cluster_offset + s->cluster_size - 1) &
-                    ~(s->cluster_size - 1);
-                bdrv_truncate(s->hd, cluster_offset + s->cluster_size);
-                /* if encrypted, we must initialize the cluster
-                   content which won't be written */
-                if (s->crypt_method &&
-                    (n_end - n_start) < s->cluster_sectors) {
-                    uint64_t start_sect;
-                    start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
-                    memset(s->cluster_data + 512, 0x00, 512);
-                    for(i = 0; i < s->cluster_sectors; i++) {
-                        if (i < n_start || i >= n_end) {
-                            encrypt_sectors(s, start_sect + i,
-                                            s->cluster_data,
-                                            s->cluster_data + 512, 1, 1,
-                                            &s->aes_encrypt_key);
-                            if (bdrv_pwrite(s->hd, cluster_offset + i * 512,
-                                            s->cluster_data, 512) != 512)
-                                return -1;
-                        }
+            /* round to cluster size */
+            cluster_offset = (cluster_offset + s->cluster_size - 1) &
+                ~(s->cluster_size - 1);
+            bdrv_truncate(s->hd, cluster_offset + s->cluster_size);
+            /* if encrypted, we must initialize the cluster
+               content which won't be written */
+            if (s->crypt_method &&
+                (n_end - n_start) < s->cluster_sectors) {
+                uint64_t start_sect;
+                start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
+                memset(s->cluster_data + 512, 0x00, 512);
+                for(i = 0; i < s->cluster_sectors; i++) {
+                    if (i < n_start || i >= n_end) {
+                        encrypt_sectors(s, start_sect + i,
+                                        s->cluster_data,
+                                        s->cluster_data + 512, 1, 1,
+                                        &s->aes_encrypt_key);
+                        if (bdrv_pwrite(s->hd, cluster_offset + i * 512,
+                                        s->cluster_data, 512) != 512)
+                            return -1;
                     }
                 }
-            } else {
-                cluster_offset |= QCOW_OFLAG_COMPRESSED |
-                    (uint64_t)compressed_size << (63 - s->cluster_bits);
             }
         }
         /* update L2 table */
Reviewed-by
#5 lore raw
Quoted 8 lines · Marc Bevand
Quoted 2 lines · Anthony Liguori

Please send the patch as an attachment or inlined.

Here it is. (I originally wanted to inline it but I am currently stuck with MUAs that cannot be configured to NOT wrap text lines.)

Looks good to me.

Quoted 3 lines

To answer Vegard's question, It's gmane that corrupted my email.

#2 lore raw

[Qemu-devel] Off-topic (mailman bug)

In reply to Vegard Nossum
Quoted 7 lines · Vegard Nossum <vegard.nossum <at> gmail.com> writes:
Quoted 3 lines

Sender: qemu-devel-bounces+vegard.nossum=gmail.com <at> nongnu.org
Errors-To: qemu-devel-bounces+vegard.nossum=gmail.com <at> nongnu.org

Uhm, what funny thing is this and why is my name in there? O.o

(Did mailman mess up?)

Actually I think what happened is a combination of 2 bugs in gmane and mailman. When I sent the email via gmane.org, a bug in gmane made it accidently included a header fragment in my message, then when mailman tried to forward it to each subscriber, it must have used a bad rewrite rule (supposed to rewrite Sender:
and Errors-To: headers in a way unique to each subscriber), but this rule failed to notice that these lines where part of the email body instead of the headers.

That would explain why subscribers see a portion of their email address in these lines.

-marc