Skip to contentSkip to conversation

block migration: fix return value mismatch

PATCH Gary Hook 3 participants 5 messages Nov 13, 2014

lore
Share & tools
lore

Gary Hook

author
#0 lore raw

On 11/13/14, 6:46 AM, "Markus Armbruster" <[email protected]<mailto:[email protected]>> wrote:

Stefan Hajnoczi <[email protected]<mailto:[email protected]>> writes:

On Wed, Nov 12, 2014 at 06:48:18PM +0000, Gary Hook wrote:

-    return qemu_ftell(f) - last_ftell;
+    delta_ftell = qemu_ftell(f) - last_ftell;
+    return( (delta_ftell > 0) ? 1 : (delta_ftell < 0) ? -1 : 0 );

Good find!

Please don't nest the ternary operator, it is hard to read.

if (delta_ftell < 0) {
     return -1;
} else if (delta_ftell > 0) {
     return 1;
} else {
     return 0;
}

Bah, that's for wimps ;)

    return (delta_ftell > 0) - (delta_ftell < 0);

Look ma, no branches!

Ha-ha! Very good, but even less readable than the compressed ternary version,
IMO. This function only gets called once per migration; I don't see a few branches as performance-critical and worth the sacrifice of clarity as to intent.

#1 lore raw

On 11/13/2014 09:44 AM, Gary Hook wrote:

[metacomment]

Quoted 5 lines · On 11/13/14, 6:46 AM, "Markus Armbruster"…

Stefan Hajnoczi <[email protected]<mailto:[email protected]>> writes:

On Wed, Nov 12, 2014 at 06:48:18PM +0000, Gary Hook wrote:

Your quoting style leaves a lot to be desired. While you correctly attributed multiple contributors of the material quoted below...

Quoted 16 lines
(quoted diff) +2 -1
-    return qemu_ftell(f) - last_ftell;
+    delta_ftell = qemu_ftell(f) - last_ftell;
+    return( (delta_ftell > 0) ? 1 : (delta_ftell < 0) ? -1 : 0 );

Good find!

Please don't nest the ternary operator, it is hard to read.

if (delta_ftell < 0) {
     return -1;
} else if (delta_ftell > 0) {
     return 1;
} else {
     return 0;
}
Quoted 8 lines

Bah, that's for wimps ;)

    return (delta_ftell > 0) - (delta_ftell < 0);

Look ma, no branches!

Ha-ha! Very good, but even less readable than the compressed ternary version,
IMO. This function only gets called once per migration; I don't see a few branches as performance-critical and worth the sacrifice of clarity as to intent.

...all three sets of contributions were listed with NO differentiation in indentation or leading '>' or other indication which part was quoted vs. which part was new material from you. Most people on this list use a REAL mail agent (such as mutt or Thunderbird), and avoid web mail, precisely because most web mail implementations are absolutely lousy at writing decently threaded conversations.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#2 lore raw
Quoted 42 lines · Eric Blake

On 11/13/2014 09:44 AM, Gary Hook wrote:

[metacomment]

Quoted 6 lines

On 11/13/14, 6:46 AM, "Markus Armbruster" <[email protected]<mailto:[email protected]>> wrote:

Stefan Hajnoczi <[email protected]<mailto:[email protected]>> writes:

On Wed, Nov 12, 2014 at 06:48:18PM +0000, Gary Hook wrote:

Your quoting style leaves a lot to be desired. While you correctly attributed multiple contributors of the material quoted below...

Quoted 20 lines
(quoted diff) +2 -1
-    return qemu_ftell(f) - last_ftell;
+    delta_ftell = qemu_ftell(f) - last_ftell;
+    return( (delta_ftell > 0) ? 1 : (delta_ftell < 0) ? -1 : 0 );

Good find!

Please don't nest the ternary operator, it is hard to read.

if (delta_ftell < 0) {
     return -1;
} else if (delta_ftell > 0) {
     return 1;
} else {
     return 0;
}

Bah, that's for wimps ;)

    return (delta_ftell > 0) - (delta_ftell < 0);
Quoted 7 lines

Look ma, no branches!

Ha-ha! Very good, but even less readable than the compressed ternary version,
IMO. This function only gets called once per migration; I don't see a few branches as performance-critical and worth the sacrifice of clarity as to intent.

Quoted 10 lines

...all three sets of contributions were listed with NO differentiation in indentation or leading '>' or other indication which part was quoted vs. which part was new material from you. Most people on this list use a REAL mail agent (such as mutt or Thunderbird), and avoid web mail, precisely because most web mail implementations are absolutely lousy at writing decently threaded conversations.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Son of aŠ. You¹re absolutely right. Outlook is not helping me out here at all. Mea culpa. I never used to have this problem with xmh.

I¹ll pay more attention going forward.

#3 lore raw
Quoted 51 lines · Gary Hook
Quoted 49 lines · Eric Blake

On 11/13/2014 09:44 AM, Gary Hook wrote:

[metacomment]

Quoted 6 lines

On 11/13/14, 6:46 AM, "Markus Armbruster" <[email protected]<mailto:[email protected]>> wrote:

Stefan Hajnoczi <[email protected]<mailto:[email protected]>> writes:

On Wed, Nov 12, 2014 at 06:48:18PM +0000, Gary Hook wrote:

Your quoting style leaves a lot to be desired. While you correctly attributed multiple contributors of the material quoted below...

Quoted 20 lines
(quoted diff) +2 -1
-    return qemu_ftell(f) - last_ftell;
+    delta_ftell = qemu_ftell(f) - last_ftell;
+    return( (delta_ftell > 0) ? 1 : (delta_ftell < 0) ? -1 : 0 );

Good find!

Please don't nest the ternary operator, it is hard to read.

if (delta_ftell < 0) {
     return -1;
} else if (delta_ftell > 0) {
     return 1;
} else {
     return 0;
}

Bah, that's for wimps ;)

    return (delta_ftell > 0) - (delta_ftell < 0);
Quoted 7 lines

Look ma, no branches!

Ha-ha! Very good, but even less readable than the compressed ternary version,
IMO. This function only gets called once per migration; I don't see a few branches as performance-critical and worth the sacrifice of clarity as to intent.

...all three sets of contributions were listed with NO differentiation in indentation or leading '>' or other indication which part was quoted vs. which part was new material from you. Most people on this list use a REAL mail agent (such as mutt or Thunderbird), and avoid web mail, precisely because most web mail implementations are absolutely lousy at writing decently threaded conversations.

Quoted 8 lines
Quoted 3 lines

--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Son of aŠ. You¹re absolutely right. Outlook is not helping me out here at all. Mea culpa. I never used to have this problem with xmh.

I¹ll pay more attention going forward.

One more thing about email configuration: the character set encoding of your emails seems to be incorrect.

GMail is rendering a superscript 1 (like "to the power of one") when you wanted a single quote:
https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts

In your email message there is a 0xb9 value instead of an ASCII single quote (for example, "I'll" is encoded "I=B9ll").

The headers claim the encoding is Windows-1252. The problem is that 0xb9 is the superscript one character and not the single quote:
https://en.wikipedia.org/wiki/Windows-1252

I guess you didn't really send a Windows-1252 message but some other 8-bit encoding.

Stefan

#4 lore raw
Quoted 15 lines

Stefan Hajnoczi <mailto:[email protected]>
November 13, 2014 at 12:55 PM

One more thing about email configuration: the character set encoding of your emails seems to be incorrect.

GMail is rendering a superscript 1 (like "to the power of one") when you wanted a single quote:
https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts

In your email message there is a 0xb9 value instead of an ASCII single quote (for example, "I'll" is encoded "I=B9ll").

Quoted 8 lines

The headers claim the encoding is Windows-1252. The problem is that 0xb9 is the superscript one character and not the single quote:
https://en.wikipedia.org/wiki/Windows-1252

I guess you didn't really send a Windows-1252 message but some other 8-bit encoding.

Stefan

Well, Outlook appears to have done some very strange things, things I should have turned off. Kicking the tires on Postbox with this one.... I'm not real sure about line wrap just yet, however.