Re: [systemd-devel] [PATCH] bootchart: use NSEC_PER_SEC

2014-08-18 Thread Lennart Poettering
On Sat, 16.08.14 14:24, Ronny Chevalier (chevalier.ro...@gmail.com) wrote:

 ---
  src/bootchart/store.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/src/bootchart/store.c b/src/bootchart/store.c
 index cedcba8..d838a53 100644
 --- a/src/bootchart/store.c
 +++ b/src/bootchart/store.c
 @@ -34,6 +34,7 @@
  #include time.h
  
  #include util.h
 +#include time-util.h
  #include strxcpyx.h
  #include store.h
  #include bootchart.h
 @@ -54,14 +55,14 @@ double gettime_ns(void) {
  
  clock_gettime(CLOCK_MONOTONIC, n);
  
 -return (n.tv_sec + (n.tv_nsec / 10.0));
 +return (n.tv_sec + (n.tv_nsec / NSEC_PER_SEC));
  }

This is really not the same. You need to cast NSEC_PER_SEC into a double
before making use of it. Note that the value you specified was a double
because it was suffixed with .0, but your replacement is a usec_t.

This should work:

return (n.tv_sec + (n.tv_nsec / (double) NSEC_PER_SEC));


  
  static double gettime_up(void) {
  struct timespec n;
  
  clock_gettime(CLOCK_BOOTTIME, n);
 -return (n.tv_sec + (n.tv_nsec / 10.0));
 +return (n.tv_sec + (n.tv_nsec / NSEC_PER_SEC));

Same here:

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] bootchart: use NSEC_PER_SEC

2014-08-16 Thread Ronny Chevalier
---
 src/bootchart/store.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index cedcba8..d838a53 100644
--- a/src/bootchart/store.c
+++ b/src/bootchart/store.c
@@ -34,6 +34,7 @@
 #include time.h
 
 #include util.h
+#include time-util.h
 #include strxcpyx.h
 #include store.h
 #include bootchart.h
@@ -54,14 +55,14 @@ double gettime_ns(void) {
 
 clock_gettime(CLOCK_MONOTONIC, n);
 
-return (n.tv_sec + (n.tv_nsec / 10.0));
+return (n.tv_sec + (n.tv_nsec / NSEC_PER_SEC));
 }
 
 static double gettime_up(void) {
 struct timespec n;
 
 clock_gettime(CLOCK_BOOTTIME, n);
-return (n.tv_sec + (n.tv_nsec / 10.0));
+return (n.tv_sec + (n.tv_nsec / NSEC_PER_SEC));
 }
 
 void log_uptime(void) {
-- 
2.0.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel