From: Christian Borntraeger <borntraeger@de.ibm.com>
To: rutu.shah.26@gmail.com, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, kvm@vger.kernel.org, mst@redhat.com,
jasowang@redhat.com, mark.cave-ayland@ilande.co.uk,
lcapitulino@redhat.com, kraxel@redhat.com, qemu-block@nongnu.org,
agraf@suse.de, samuel.thibault@ens-lyon.org,
alistair.francis@xilinx.com, qemu-arm@nongnu.org,
stefanha@redhat.com, pbonzini@redhat.com,
cornelia.huck@de.ibm.com, jsnow@redhat.com, rth@twiddle.net,
kwolf@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com,
blauwirbel@gmail.co, qemu-ppc@nongnu.org, imammedo@redhat.com
Subject: Re: [Qemu-devel] [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com>
Date: Fri, 11 Mar 2016 12:44:33 +0100 [thread overview]
Message-ID: <56E2AFA1.5010201@de.ibm.com> (raw)
In-Reply-To: <1457638209-14218-1-git-send-email-rutu.shah.26@gmail.com>
On 03/10/2016 08:30 PM, rutu.shah.26@gmail.com wrote:
> From: Rutuja Shah <rutu.shah.26@gmail.com>
[...]
> - s->tick_offset_vmstate = s->tick_offset + delta / get_ticks_per_sec();
> + s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND;
[...]
While technically correct, I do not like these changes. The interfaces expect "ticks",
and the fact that this happens to be a nanosecond does not help regarding
readability.
Lets look at the snippet from above. The variable is called TICK_offset_vmstate.
so, the first line (-) makes sense when reading, the 2nd line (+) does not.
A reader that does not know the timer code will ask itself: "Why do we use
NANOSECONDS_PER_SECOND to calculate ticks?" The reader has to know that a tick
is a nanosecond to understand that line. So the cleanup makes the code harder to
read in my opinion.
If - for some reason - we want to replace a function with a MACRO, then
please introduce TICKS_PER_SECOND which just feels better when reading the code.
It would also fix the >80 chars per line problem.
On the other hand get_ticks_per_sec is a static inline function:
- it will get inlined, no overhead over a macro
- it will add type safety if we ever change things (e.g. somebody might introduce
a tick_t)
So I would prefer to not change things.
Christian
next prev parent reply other threads:[~2016-03-11 11:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 19:30 [Qemu-devel] [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com> rutu.shah.26
2016-03-10 21:10 ` Eric Blake
2016-03-11 6:57 ` rutuja shah
2016-03-11 11:01 ` Stefan Hajnoczi
2016-03-11 11:44 ` Christian Borntraeger [this message]
2016-03-11 12:07 ` Paolo Bonzini
2016-03-11 12:12 ` Christian Borntraeger
2016-03-11 12:26 ` Paolo Bonzini
2016-03-11 13:22 ` Christian Borntraeger
2016-03-12 16:20 ` rutuja shah
2016-03-15 10:08 ` [Qemu-devel] [Qemu-ppc] " Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56E2AFA1.5010201@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=agraf@suse.de \
--cc=alistair.francis@xilinx.com \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.co \
--cc=cornelia.huck@de.ibm.com \
--cc=crosthwaite.peter@gmail.com \
--cc=imammedo@redhat.com \
--cc=jasowang@redhat.com \
--cc=jsnow@redhat.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rth@twiddle.net \
--cc=rutu.shah.26@gmail.com \
--cc=samuel.thibault@ens-lyon.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).