Commit bb5a7316 authored by Steven Rostedt's avatar Steven Rostedt Committed by Arnaldo Carvalho de Melo

tools lib traceevent: Use USECS_PER_SEC instead of hardcoded number

Instead of using 1000000, use the define in time64.h instead.

Also remove the the duplicate defines for NSECS_PER_SEC.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20161121114149.67111981@gandalf.local.homeSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 763d8960
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <stdint.h> #include <stdint.h>
#include <limits.h> #include <limits.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/time64.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "event-parse.h" #include "event-parse.h"
...@@ -5424,8 +5425,8 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, ...@@ -5424,8 +5425,8 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
use_usec_format = is_timestamp_in_us(pevent->trace_clock, use_usec_format = is_timestamp_in_us(pevent->trace_clock,
use_trace_clock); use_trace_clock);
if (use_usec_format) { if (use_usec_format) {
secs = record->ts / NSECS_PER_SEC; secs = record->ts / NSEC_PER_SEC;
nsecs = record->ts - secs * NSECS_PER_SEC; nsecs = record->ts - secs * NSEC_PER_SEC;
} }
if (pevent->latency_format) { if (pevent->latency_format) {
...@@ -5437,10 +5438,10 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, ...@@ -5437,10 +5438,10 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
usecs = nsecs; usecs = nsecs;
p = 9; p = 9;
} else { } else {
usecs = (nsecs + 500) / NSECS_PER_USEC; usecs = (nsecs + 500) / NSEC_PER_USEC;
/* To avoid usecs larger than 1 sec */ /* To avoid usecs larger than 1 sec */
if (usecs >= 1000000) { if (usecs >= USEC_PER_SEC) {
usecs -= 1000000; usecs -= USEC_PER_SEC;
secs++; secs++;
} }
p = 6; p = 6;
......
...@@ -172,9 +172,6 @@ struct pevent_plugin_option { ...@@ -172,9 +172,6 @@ struct pevent_plugin_option {
#define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS) #define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS)
#define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS) #define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS)
#define NSECS_PER_SEC 1000000000ULL
#define NSECS_PER_USEC 1000ULL
enum format_flags { enum format_flags {
FIELD_IS_ARRAY = 1, FIELD_IS_ARRAY = 1,
FIELD_IS_POINTER = 2, FIELD_IS_POINTER = 2,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment