qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/1] block migration: fix return value mismatch


From: Gary Hook
Subject: Re: [Qemu-devel] [PATCH 1/1] block migration: fix return value mismatch
Date: Thu, 13 Nov 2014 16:43:36 +0000

On 11/13/14, 5:20 AM, "Stefan Hajnoczi" <address@hidden> wrote:

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;
}

Well, that format wasn¹t my first choice. I¹m still unclear on some of the
style requirements on this project, so I went with terse. Your rewrite
would have been my preference, but I¹m wondering if the syntax checker
will want the parentheses stripped as ³Unnecessary² despite how much they
aid in readability.

This one has caused us no end of pain. It¹s wonderful to eradicate it.


reply via email to

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