src_tests_fd_info_SOURCES = src/tests/fd_info.c src/shared/fd_info.c
src_tests_fd_info_CFLAGS = $(check_CFLAGS)
-src_tests_fd_info_LDFLAGS = $(AM_LDFLAGS) -Wl,--wrap=sort_vector_push,--wrap=malloc,--wrap=free,--wrap=close,--wrap=extract_timestamp,--wrap=log_should_print_line
+src_tests_fd_info_LDFLAGS = $(AM_LDFLAGS) -Wl,--wrap=sort_vector_push,--wrap=malloc,--wrap=free,--wrap=close,--wrap=dlogutil_entry_ts,--wrap=log_should_print_line
src_tests_fdi_logger_SOURCES = src/tests/fdi_logger.c src/shared/fdi_logger.c src/shared/ptrs_list.c src/shared/logcommon.c
src_tests_fdi_logger_CFLAGS = $(check_CFLAGS)
src_tests_log_file_SOURCES = src/tests/log_file.c src/shared/log_file.c
src_tests_log_file_CFLAGS = $(check_CFLAGS)
-src_tests_log_file_LDFLAGS = $(AM_LDFLAGS) -Wl,--wrap=strdup,--wrap=free,--wrap=memcpy,--wrap=snprintf,--wrap=open,--wrap=fstat,--wrap=rename,--wrap=extract_timestamp,--wrap=log_print_log_line,--wrap=log_buffer_get_tag
+src_tests_log_file_LDFLAGS = $(AM_LDFLAGS) -Wl,--wrap=strdup,--wrap=free,--wrap=memcpy,--wrap=snprintf,--wrap=open,--wrap=fstat,--wrap=rename,--wrap=dlogutil_entry_ts,--wrap=log_print_log_line,--wrap=log_buffer_get_tag
src_tests_queued_entry_SOURCES = src/tests/queued_entry.c src/shared/queued_entry.c src/shared/queued_entry_timestamp.c src/shared/parsers.c src/shared/translate_syslog.c src/shared/logconfig.c src/shared/logcommon.c
src_tests_queued_entry_CFLAGS = $(check_CFLAGS)
void add_recv_timestamp(struct dlogutil_entry *le);
void copy_recv_timestamp(struct dlogutil_entry *le);
bool log_entry_is_earlier(const enum dlogutil_sorting_order sort_by, const struct dlogutil_entry *lhs, const struct dlogutil_entry *rhs);
-void extract_timestamp(const struct dlogutil_entry *le, enum dlogutil_sorting_order stamp_type, struct timespec *ts);
+struct timespec dlogutil_entry_ts(const struct dlogutil_entry *le, enum dlogutil_sorting_order stamp_type);
clockid_t get_proper_clock(enum dlogutil_sorting_order sort_by);
#endif /* _QUEUED_ENTRY_TIMESTAMP_H */
int r;
if (IS_VECTOR_SIZE_SORTABLE(logs->size)) {
- struct timespec ts;
- extract_timestamp(temp, logs->sort_by, &ts);
+ struct timespec ts = dlogutil_entry_ts(temp, logs->sort_by);
/* check if new entry is newer than util's start moment */
if (ts.tv_sec > logs->start.tv_sec || (ts.tv_sec == logs->start.tv_sec && ts.tv_nsec > logs->start.tv_nsec))
{
int written_bytes = 0;
- struct timespec ts;
- extract_timestamp(e, sort_by, &ts);
+ struct timespec ts = dlogutil_entry_ts(e, sort_by);
if (ts.tv_sec < file->prev_sec || (ts.tv_sec == file->prev_sec && ts.tv_nsec < file->prev_nsec)) {
struct dlogutil_entry_with_msg msg;
continue;
const struct dlogutil_entry *const le = fdi->ops->peek_entry(fdi);
- struct timespec current_ts;
- extract_timestamp(le, sort_by, ¤t_ts);
+ struct timespec current_ts = dlogutil_entry_ts(le, sort_by);
if (best_fdi && ((current_ts.tv_sec > best_ts.tv_sec) || (current_ts.tv_sec == best_ts.tv_sec && current_ts.tv_nsec > best_ts.tv_nsec)))
continue;
return l_sec < r_sec || (l_sec == r_sec && l_nsec < r_nsec);
}
-void extract_timestamp(const struct dlogutil_entry *le, enum dlogutil_sorting_order stamp_type, struct timespec *ts)
+struct timespec dlogutil_entry_ts(const struct dlogutil_entry *le, enum dlogutil_sorting_order stamp_type)
{
assert(le);
- assert(ts);
+
+ struct timespec ret;
switch (stamp_type) {
case SORT_SENT_MONO:
- ts->tv_sec = le->sec_sent_mono;
- ts->tv_nsec = le->nsec_sent_mono;
+ ret.tv_sec = le->sec_sent_mono;
+ ret.tv_nsec = le->nsec_sent_mono;
break;
case SORT_SENT_REAL:
- ts->tv_sec = le->sec_sent_real;
- ts->tv_nsec = le->nsec_sent_real;
+ ret.tv_sec = le->sec_sent_real;
+ ret.tv_nsec = le->nsec_sent_real;
break;
case SORT_RECV_MONO:
- ts->tv_sec = le->sec_recv_mono;
- ts->tv_nsec = le->nsec_recv_mono;
+ ret.tv_sec = le->sec_recv_mono;
+ ret.tv_nsec = le->nsec_recv_mono;
break;
case SORT_RECV_REAL:
- ts->tv_sec = le->sec_recv_real;
- ts->tv_nsec = le->nsec_recv_real;
+ ret.tv_sec = le->sec_recv_real;
+ ret.tv_nsec = le->nsec_recv_real;
break;
default: assert(false); // LCOV_EXCL_LINE
}
+
+ return ret;
}
clockid_t get_proper_clock(enum dlogutil_sorting_order sort_by)
long sort_vector_time_span(struct sort_vector *logs)
{
- struct timespec now, oldest;
long diff_s, diff_ns;
if (sort_vector_empty(logs))
return 0;
+ struct timespec now, oldest = dlogutil_entry_ts(sort_vector_back(logs), logs->sort_by);
clock_gettime(get_proper_clock(logs->sort_by), &now);
- extract_timestamp(sort_vector_back(logs), logs->sort_by, &oldest);
diff_s = now.tv_sec - oldest.tv_sec;
diff_ns = now.tv_nsec - oldest.tv_nsec;
if (timeout != -1) {
- struct timespec log_ts;
- extract_timestamp(e, stamp_type, &log_ts);
+ struct timespec log_ts = dlogutil_entry_ts(e, stamp_type);
long s = reference_ts.tv_sec - log_ts.tv_sec;
long ns = reference_ts.tv_nsec - log_ts.tv_nsec;
return fail_extract ? NULL : (struct dlogutil_entry *) 0xBADFEEL;
}
-void __wrap_extract_timestamp(const struct dlogutil_entry *le, enum dlogutil_sorting_order stamp_type, struct timespec *ts)
+struct timespec __wrap_dlogutil_entry_ts(const struct dlogutil_entry *le, enum dlogutil_sorting_order stamp_type)
{
assert(le == (struct dlogutil_entry *)0xBADFEEL);
- ts->tv_sec = 1;
- ts->tv_nsec = 1;
+ return (struct timespec) {
+ .tv_sec = 1,
+ .tv_nsec = 1,
+ };
}
static struct fd_info *expected_destroyee;
return -1;
}
-void __wrap_extract_timestamp(const struct dlogutil_entry *le, enum dlogutil_sorting_order stamp_type, struct timespec *ts)
+struct timespec __wrap_dlogutil_entry_ts(const struct dlogutil_entry *le, enum dlogutil_sorting_order stamp_type)
{
assert(stamp_type == SORT_SENT_MONO);
assert(le == (struct dlogutil_entry *) 0xBA5EBALL);
- ts->tv_sec = 3333;
- ts->tv_nsec = 9999;
+ return (struct timespec) {
+ .tv_sec = 3333,
+ .tv_nsec = 9999,
+ };
}
char *__wrap_log_buffer_get_tag(const struct dlogutil_entry *entry)
.sec_recv_real = 7,
.nsec_recv_real = 8,
};
- extract_timestamp(&le, SORT_SENT_MONO, &ts);
+ ts = dlogutil_entry_ts(&le, SORT_SENT_MONO);
assert(ts.tv_sec == le. sec_sent_mono);
assert(ts.tv_nsec == le.nsec_sent_mono);
- extract_timestamp(&le, SORT_RECV_REAL, &ts);
+ ts = dlogutil_entry_ts(&le, SORT_RECV_REAL);
assert(ts.tv_sec == le. sec_recv_real);
assert(ts.tv_nsec == le.nsec_recv_real);
- extract_timestamp(&le, SORT_SENT_REAL, &ts);
+ ts = dlogutil_entry_ts(&le, SORT_SENT_REAL);
assert(ts.tv_sec == le. sec_sent_real);
assert(ts.tv_nsec == le.nsec_sent_real);
- extract_timestamp(&le, SORT_RECV_MONO, &ts);
+ ts = dlogutil_entry_ts(&le, SORT_RECV_MONO);
assert(ts.tv_sec == le. sec_recv_mono);
assert(ts.tv_nsec == le.nsec_recv_mono);