On 11/13/14, 6:46 AM, "Markus Armbruster" <arm...@redhat.com<mailto:arm...@redhat.com>> wrote:
Stefan Hajnoczi <stefa...@gmail.com<mailto:stefa...@gmail.com>> 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.