From c218d8926f527cd05f28c794a36b16dad68f2b51 Mon Sep 17 00:00:00 2001 From: Mateusz Majewski Date: Mon, 9 Dec 2019 08:50:30 +0100 Subject: [PATCH] Create a typedef for dlogutil_entry Change-Id: I73ff0af0d07490e6fdadd3ed1c95c42046662700 --- include/dlog_ioctl.h | 2 +- include/fd_info.h | 6 +++--- include/log_file.h | 6 +++--- include/logprint.h | 10 +++++----- include/queued_entry.h | 12 ++++++------ include/queued_entry_timestamp.h | 8 ++++---- include/sort_vector.h | 6 +++--- src/logger/log_storage.c | 8 ++++---- src/logger/log_storage.h | 6 +++--- src/logger/logger.c | 10 +++++----- src/shared/fd_info.c | 2 +- src/shared/fdi_logger.c | 8 ++++---- src/shared/fdi_pipe.c | 12 ++++++------ src/shared/log_file.c | 4 ++-- src/shared/logprint.c | 22 +++++++++++----------- src/shared/logretrieve.c | 2 +- src/shared/queued_entry.c | 14 +++++++------- src/shared/queued_entry_timestamp.c | 8 ++++---- src/shared/sort_vector.c | 10 +++++----- src/tests/fd_info.c | 20 ++++++++++---------- src/tests/fdi_logger.c | 8 ++++---- src/tests/fdi_pipe.c | 8 ++++---- src/tests/filters.c | 8 ++++---- src/tests/kmsg_parser.c | 2 +- src/tests/log_file.c | 28 ++++++++++++++-------------- src/tests/logger.c | 12 ++++++------ src/tests/logprint.c | 8 ++++---- src/tests/logutil.c | 24 ++++++++++++------------ src/tests/pipe_message.c | 2 +- src/tests/queued_entry.c | 2 +- src/tests/sort_vector.c | 32 ++++++++++++++++---------------- src/tests/syslog_parser.c | 2 +- src/tests/test_logger_log_storage.c | 18 +++++++++--------- 33 files changed, 165 insertions(+), 165 deletions(-) diff --git a/include/dlog_ioctl.h b/include/dlog_ioctl.h index f877eca..49c5124 100644 --- a/include/dlog_ioctl.h +++ b/include/dlog_ioctl.h @@ -4,7 +4,7 @@ #include #define LOGGER_ENTRY_MAX_LEN (4*1024) -#define LOGGER_ENTRY_MAX_PAYLOAD (LOGGER_ENTRY_MAX_LEN - sizeof(struct dlogutil_entry)) +#define LOGGER_ENTRY_MAX_PAYLOAD (LOGGER_ENTRY_MAX_LEN - sizeof(dlogutil_entry_s)) // These are taken from the kernel: ./drivers/staging/android/logger.h #define __LOGGERIO 0xAE diff --git a/include/fd_info.h b/include/fd_info.h index b476bdb..c747166 100644 --- a/include/fd_info.h +++ b/include/fd_info.h @@ -47,10 +47,10 @@ struct fd_ops { bool (*has_log)(struct fd_info *fdi); /// Extracts a buffered entry and relinquishes its ownership - struct dlogutil_entry *(*extract_entry)(struct fd_info *fdi); + dlogutil_entry_s *(*extract_entry)(struct fd_info *fdi); /// Returns a buffered entry without relinquishing ownership - const struct dlogutil_entry *(*peek_entry)(const struct fd_info *fdi); + const dlogutil_entry_s *(*peek_entry)(const struct fd_info *fdi); /// Transition into a state that allows reading and printing out logs /// Return values > 0 mean everything went fine but we don't want to print @@ -71,5 +71,5 @@ void fdi_free(struct fd_info *fdi); void fdi_array_free(struct fd_info ***arr); bool fdi_has_log(struct fd_info *fdi); int fdi_push_log(struct fd_info *fdi, struct sort_vector *logs, dlogutil_write_cb callback, void *userdata, dlogutil_filter_options_s *filter); -struct dlogutil_entry *fdi_extract_entry(struct fd_info *fdi); +dlogutil_entry_s *fdi_extract_entry(struct fd_info *fdi); int fdi_read(struct fd_info *fdi); diff --git a/include/log_file.h b/include/log_file.h index 364df4a..4cbafce 100644 --- a/include/log_file.h +++ b/include/log_file.h @@ -55,16 +55,16 @@ int logfile_set_path(struct log_file *l_file, const char *path); int logfile_open(struct log_file *l_file); int logfile_rotate_needed(struct log_file *l_file); void logfile_do_rotate(struct log_file *file); -int logfile_write_with_rotation(const struct dlogutil_entry *e, struct log_file *file, dlogutil_sorting_order_e sort_by); +int logfile_write_with_rotation(const dlogutil_entry_s *e, struct log_file *file, dlogutil_sorting_order_e sort_by); -typedef int dlogutil_write_cb(const struct dlogutil_entry *e, void *userdata); +typedef int dlogutil_write_cb(const dlogutil_entry_s *e, void *userdata); struct logfile_callback_data { struct log_file *file; dlogutil_sorting_order_e sort_by; }; -int logfile_callback(const struct dlogutil_entry *e, void *userdata); +int logfile_callback(const dlogutil_entry_s *e, void *userdata); #ifdef __cplusplus } diff --git a/include/logprint.h b/include/logprint.h index 5bb353d..93a2f63 100644 --- a/include/logprint.h +++ b/include/logprint.h @@ -154,21 +154,21 @@ log_priority log_filter_get_global_priority(dlogutil_filter_options_s *p_filter, * data (priority, tag, pid and tid), and false if it should not */ bool log_should_print_line( - dlogutil_filter_options_s *p_filter, const struct dlogutil_entry *entry); + dlogutil_filter_options_s *p_filter, const dlogutil_entry_s *entry); /** * Returns pointer to log entry tag * * Finds the beginning of a log tag in entry's payload and returns it */ -const char* dlogutil_entry_tag(const struct dlogutil_entry *entry); +const char* dlogutil_entry_tag(const dlogutil_entry_s *entry); /** * Returns pointer to log entry message * * Finds the beginning of a log message in entry's payload and returns it */ -const char* dlogutil_entry_msg(const struct dlogutil_entry *entry); +const char* dlogutil_entry_msg(const dlogutil_entry_s *entry); /** * Formats a log message into a buffer @@ -182,7 +182,7 @@ char *log_format_log_line( const struct log_format p_format, char *defaultBuffer, size_t defaultBufferSize, - const struct dlogutil_entry *p_line, + const dlogutil_entry_s *p_line, size_t *p_outLength); /** @@ -194,7 +194,7 @@ char *log_format_log_line( int log_print_log_line( struct log_format p_format, int fd, - const struct dlogutil_entry *entry); + const dlogutil_entry_s *entry); log_priority filter_char_to_pri(char c); diff --git a/include/queued_entry.h b/include/queued_entry.h index 2a4d3cc..98e9846 100644 --- a/include/queued_entry.h +++ b/include/queued_entry.h @@ -51,7 +51,7 @@ enum { #define INVALID_SEC 0 #define INVALID_NSEC -1 -struct dlogutil_entry { +typedef struct dlogutil_entry { uint16_t len; /* length of the payload */ uint8_t priority; /* entry's priority*/ uint8_t padding;/* padding for alignment */ @@ -68,10 +68,10 @@ struct dlogutil_entry { int32_t tag_len; int32_t default_send_ts_type; /* default backend-dependant send time type */ char msg[]; /* the entry's payload */ -}; +} dlogutil_entry_s; struct dlogutil_entry_with_msg { - struct dlogutil_entry header; + dlogutil_entry_s header; char msg[LOG_MAX_PAYLOAD_SIZE]; }; @@ -138,9 +138,9 @@ extern "C" { void create_pipe_message(void * buf, int prio, char const * tag, char const * msg); int parse_kmsg_message(char *buffer, struct dlogutil_entry_with_msg *lem, int buffer_size); -int parse_syslog_datagram(const char * buffer, int buffer_size, struct dlogutil_entry * le); -void parse_androidlogger_message(struct android_logger_entry *ale, struct dlogutil_entry *le, size_t dgram_size); -void parse_pipe_message(struct pipe_logger_entry *ple, struct dlogutil_entry *le, size_t msg_size); +int parse_syslog_datagram(const char * buffer, int buffer_size, dlogutil_entry_s * le); +void parse_androidlogger_message(struct android_logger_entry *ale, dlogutil_entry_s *le, size_t dgram_size); +void parse_pipe_message(struct pipe_logger_entry *ple, dlogutil_entry_s *le, size_t msg_size); #ifdef __cplusplus } diff --git a/include/queued_entry_timestamp.h b/include/queued_entry_timestamp.h index 6b9d15f..7814a11 100644 --- a/include/queued_entry_timestamp.h +++ b/include/queued_entry_timestamp.h @@ -24,10 +24,10 @@ #include #include -void add_recv_timestamp(struct dlogutil_entry *le); -void copy_recv_timestamp(struct dlogutil_entry *le); -bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const struct dlogutil_entry *lhs, const struct dlogutil_entry *rhs); -struct timespec dlogutil_entry_ts(const struct dlogutil_entry *le, dlogutil_sorting_order_e stamp_type); +void add_recv_timestamp(dlogutil_entry_s *le); +void copy_recv_timestamp(dlogutil_entry_s *le); +bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const dlogutil_entry_s *lhs, const dlogutil_entry_s *rhs); +struct timespec dlogutil_entry_ts(const dlogutil_entry_s *le, dlogutil_sorting_order_e stamp_type); clockid_t get_proper_clock(dlogutil_sorting_order_e sort_by); #endif /* _QUEUED_ENTRY_TIMESTAMP_H */ diff --git a/include/sort_vector.h b/include/sort_vector.h index 6fefd99..54a4ccc 100644 --- a/include/sort_vector.h +++ b/include/sort_vector.h @@ -30,7 +30,7 @@ #define DEFAULT_SORT_BUFFER_SIZE 131072 // the size (in ENTRIES!) of the sorting buffer struct sort_vector { - struct dlogutil_entry **data; + dlogutil_entry_s **data; int begin; int end; size_t size; @@ -44,13 +44,13 @@ struct sort_vector { void sort_vector_init(struct sort_vector *logs); int sort_vector_finalize(struct sort_vector *logs); void sort_vector_free(struct sort_vector *logs); -struct dlogutil_entry *sort_vector_back(struct sort_vector *logs); +dlogutil_entry_s *sort_vector_back(struct sort_vector *logs); int sort_vector_enlarge(struct sort_vector *logs); int sort_vector_empty(struct sort_vector *logs); int sort_vector_full(struct sort_vector *logs); int sort_vector_used_size(struct sort_vector *logs); void sort_vector_pop(struct sort_vector *logs); void sort_vector_apply_config(struct sort_vector *logs, const struct log_config *config); -int sort_vector_push(struct sort_vector *logs, struct dlogutil_entry *p, dlogutil_write_cb callback, void *userdata); +int sort_vector_push(struct sort_vector *logs, dlogutil_entry_s *p, dlogutil_write_cb callback, void *userdata); long sort_vector_time_span(struct sort_vector *logs); int sort_vector_flush(struct sort_vector *logs, dlogutil_write_cb callback, void *userdata, bool force); diff --git a/src/logger/log_storage.c b/src/logger/log_storage.c index f8da07f..fcd3a40 100644 --- a/src/logger/log_storage.c +++ b/src/logger/log_storage.c @@ -114,7 +114,7 @@ typedef struct log_storage_entry { struct log_storage_entry *prev; list_head readers; // the field below must be the very last field in the struct, because it has variable size - struct dlogutil_entry entry; + dlogutil_entry_s entry; } log_storage_entry; struct log_storage { @@ -286,7 +286,7 @@ static void log_storage_remove_the_earliest_log(log_storage *storage) free(free_me); } -bool log_storage_add_new_entry(log_storage *storage, const struct dlogutil_entry *le) +bool log_storage_add_new_entry(log_storage *storage, const dlogutil_entry_s *le) { assert(storage); assert(le); @@ -386,11 +386,11 @@ bool log_storage_reader_is_new_entry_available(const log_storage_reader *reader) (NULL == reader->current && NULL != reader->storage->entries); } -const struct dlogutil_entry *log_storage_reader_get_new_entry(log_storage_reader *reader) +const dlogutil_entry_s *log_storage_reader_get_new_entry(log_storage_reader *reader) { assert(reader); - const struct dlogutil_entry *le = NULL; + const dlogutil_entry_s *le = NULL; // storage is NULL if a dumping/one-shot reader has finished reading if (NULL == reader->storage) diff --git a/src/logger/log_storage.h b/src/logger/log_storage.h index 7b21f52..9f49ab3 100644 --- a/src/logger/log_storage.h +++ b/src/logger/log_storage.h @@ -72,7 +72,7 @@ dlogutil_sorting_order_e log_storage_get_sorting_order(const log_storage *storag * @param[in] le The log entry which will be added. * @return true on success, false on failure - on lack of memory. */ -bool log_storage_add_new_entry(log_storage *storage, const struct dlogutil_entry *le); +bool log_storage_add_new_entry(log_storage *storage, const dlogutil_entry_s *le); /** * @brief This function makes all the log entries disappear. They vanish. Completely. @@ -94,7 +94,7 @@ typedef struct log_storage_reader log_storage_reader; * @brief A type for callbacks that are called when there is last chance for a reader * to handle a log entry. */ -typedef void (*log_storage_reader_callback)(const struct dlogutil_entry *le, void *user_data); +typedef void (*log_storage_reader_callback)(const dlogutil_entry_s *le, void *user_data); /** * @brief This function creates a new reader. @@ -136,7 +136,7 @@ bool log_storage_reader_is_new_entry_available(const log_storage_reader *reader) * because this log entry may be deleted by the storage without warning. Precisely, when you put * another log entry into the storage. */ -const struct dlogutil_entry *log_storage_reader_get_new_entry(log_storage_reader *reader); +const dlogutil_entry_s *log_storage_reader_get_new_entry(log_storage_reader *reader); /** diff --git a/src/logger/logger.c b/src/logger/logger.c index 731d877..220e395 100644 --- a/src/logger/logger.c +++ b/src/logger/logger.c @@ -598,7 +598,7 @@ int reader_should_buffer(struct reader *reader, const struct buf_params *buf_par * @param[in] entry The entry to append * @param[in] b The buffer whither to append */ -int buffer_append(const struct dlogutil_entry *entry, struct log_buffer *b) +int buffer_append(const dlogutil_entry_s *entry, struct log_buffer *b) { if (!log_storage_add_new_entry(b->log_storage, entry)) return -ENOMEM; @@ -641,7 +641,7 @@ static void check_if_fd_limit_reached(struct logger *server, int err) printf("ERROR: not enough memory either, please check platform settings as the daemon is seriously resource-starved!\n"); } -static int reader_print_out_single_log(struct reader *reader, const struct dlogutil_entry *dlogutil_entry) +static int reader_print_out_single_log(struct reader *reader, const dlogutil_entry_s *dlogutil_entry) { assert(reader); assert(reader->buf_ptr); @@ -711,7 +711,7 @@ int print_out_logs(struct reader *reader) } while (log_storage_reader_is_new_entry_available(reader->log_storage_reader)) { - const struct dlogutil_entry* ple = (const struct dlogutil_entry *)log_storage_reader_get_new_entry(reader->log_storage_reader); + const dlogutil_entry_s* ple = (const dlogutil_entry_s *)log_storage_reader_get_new_entry(reader->log_storage_reader); assert(ple); @@ -829,12 +829,12 @@ int service_reader_file(struct reader* reader) return 0; } -void reader_notify_losing_log(const struct dlogutil_entry *le, void *reader_) +void reader_notify_losing_log(const dlogutil_entry_s *le, void *reader_) { struct reader *reader = reader_; assert(le); assert(reader); - reader_print_out_single_log(reader, (struct dlogutil_entry *)le); + reader_print_out_single_log(reader, (dlogutil_entry_s *)le); } /** diff --git a/src/shared/fd_info.c b/src/shared/fd_info.c index 197af37..b276086 100644 --- a/src/shared/fd_info.c +++ b/src/shared/fd_info.c @@ -82,7 +82,7 @@ int fdi_push_log(struct fd_info *fdi, struct sort_vector *logs, dlogutil_write_c assert(logs); assert(filter); - struct dlogutil_entry *temp = fdi->ops->extract_entry(fdi); + dlogutil_entry_s *temp = fdi->ops->extract_entry(fdi); if (!temp) return -ENOMEM; diff --git a/src/shared/fdi_logger.c b/src/shared/fdi_logger.c index 0bfcbc6..bdb1270 100644 --- a/src/shared/fdi_logger.c +++ b/src/shared/fdi_logger.c @@ -35,7 +35,7 @@ struct logger_priv_data { int log_len; - struct dlogutil_entry *entry; + dlogutil_entry_s *entry; }; static int logger_ioctl(int fd, int ioctl_id) @@ -264,18 +264,18 @@ static int logger_read(struct fd_info *fdi) return r; } -static struct dlogutil_entry *logger_extract_entry(struct fd_info *fdi) +static dlogutil_entry_s *logger_extract_entry(struct fd_info *fdi) { assert(fdi); struct logger_priv_data *lpd = (struct logger_priv_data *)fdi->priv_data; assert(lpd); - struct dlogutil_entry *const ret = lpd->entry; + dlogutil_entry_s *const ret = lpd->entry; lpd->entry = NULL; return ret; } -static const struct dlogutil_entry *logger_peek_entry(const struct fd_info *fdi) +static const dlogutil_entry_s *logger_peek_entry(const struct fd_info *fdi) { assert(fdi); const struct logger_priv_data *const lpd = (const struct logger_priv_data *)fdi->priv_data; diff --git a/src/shared/fdi_pipe.c b/src/shared/fdi_pipe.c index 69bd234..6fda08b 100644 --- a/src/shared/fdi_pipe.c +++ b/src/shared/fdi_pipe.c @@ -240,21 +240,21 @@ static bool pipe_has_log(struct fd_info *fdi) struct pipe_priv_data *ppd = (struct pipe_priv_data *)fdi->priv_data; assert(ppd); - const struct dlogutil_entry *const le = (const struct dlogutil_entry *)(ppd->buff + ppd->offset); + const dlogutil_entry_s *const le = (const dlogutil_entry_s *)(ppd->buff + ppd->offset); return ppd->data_len >= sizeof le->len && ppd->data_len >= le->len; } -static struct dlogutil_entry *pipe_extract_entry(struct fd_info *fdi) +static dlogutil_entry_s *pipe_extract_entry(struct fd_info *fdi) { assert(fdi); struct pipe_priv_data *ppd = (struct pipe_priv_data *)fdi->priv_data; assert(ppd); - struct dlogutil_entry *const buf_le = (struct dlogutil_entry *)(ppd->buff + ppd->offset); + dlogutil_entry_s *const buf_le = (dlogutil_entry_s *)(ppd->buff + ppd->offset); if (!buf_le->len) return NULL; - struct dlogutil_entry *const new_le = malloc(buf_le->len); + dlogutil_entry_s *const new_le = malloc(buf_le->len); if (!new_le) return NULL; @@ -265,13 +265,13 @@ static struct dlogutil_entry *pipe_extract_entry(struct fd_info *fdi) return new_le; } -static const struct dlogutil_entry *pipe_peek_entry(const struct fd_info *fdi) +static const dlogutil_entry_s *pipe_peek_entry(const struct fd_info *fdi) { assert(fdi); const struct pipe_priv_data *const ppd = (const struct pipe_priv_data *)fdi->priv_data; assert(ppd); - return (const struct dlogutil_entry *)(ppd->buff + ppd->offset); + return (const dlogutil_entry_s *)(ppd->buff + ppd->offset); } struct fd_ops ops_pipe = { diff --git a/src/shared/log_file.c b/src/shared/log_file.c index 2297b14..462dc25 100644 --- a/src/shared/log_file.c +++ b/src/shared/log_file.c @@ -216,7 +216,7 @@ static void logfile_add_timestamp(struct log_file *file, struct timespec ts) * @param[in] file The file to write to * @returns 0 if log was successfully written, else 1 */ -int logfile_write_with_rotation(const struct dlogutil_entry *e, struct log_file *file, dlogutil_sorting_order_e sort_by) +int logfile_write_with_rotation(const dlogutil_entry_s *e, struct log_file *file, dlogutil_sorting_order_e sort_by) { if (file->colors_auto) file->format.color = file->isatty; @@ -257,7 +257,7 @@ int logfile_write_with_rotation(const struct dlogutil_entry *e, struct log_file return 0; } -int logfile_callback(const struct dlogutil_entry *e, void *userdata) +int logfile_callback(const dlogutil_entry_s *e, void *userdata) { struct logfile_callback_data *data = userdata; return logfile_write_with_rotation(e, data->file, data->sort_by); diff --git a/src/shared/logprint.c b/src/shared/logprint.c index f1c86be..b1923e8 100644 --- a/src/shared/logprint.c +++ b/src/shared/logprint.c @@ -201,7 +201,7 @@ char filter_pri_to_char(log_priority pri) * @param[in] entry The log entry to filter * @return True if the line should be printed, else false */ -bool log_should_print_line(dlogutil_filter_options_s *p_filter, const struct dlogutil_entry *entry) +bool log_should_print_line(dlogutil_filter_options_s *p_filter, const dlogutil_entry_s *entry) { assert(p_filter); assert(entry); @@ -540,11 +540,11 @@ int dlogutil_filter_options_tid(dlogutil_filter_options_s *p_filter, pid_t tid) * @param[in] entry The log entry * @return Pointer to log tag */ -const char* dlogutil_entry_tag(const struct dlogutil_entry *entry) +const char* dlogutil_entry_tag(const dlogutil_entry_s *entry) { assert(entry); - if (entry->len - (int) sizeof(struct dlogutil_entry) < 2) + if (entry->len - (int) sizeof(dlogutil_entry_s) < 2) return NULL; if (((const char *)entry)[entry->len - 1] != '\0') return NULL; @@ -558,11 +558,11 @@ const char* dlogutil_entry_tag(const struct dlogutil_entry *entry) * @param[in] entry The log entry * @return Pointer to log message */ -const char* dlogutil_entry_msg(const struct dlogutil_entry *entry) +const char* dlogutil_entry_msg(const dlogutil_entry_s *entry) { assert(entry); - if (entry->len - (int) sizeof(struct dlogutil_entry) < 2) + if (entry->len - (int) sizeof(dlogutil_entry_s) < 2) return NULL; if (((const char *)entry)[entry->len - 1] != '\0') return NULL; @@ -738,7 +738,7 @@ const char *json_priority_name(log_priority prio) char *log_format_json( char *default_buffer, size_t default_buffer_size, - const struct dlogutil_entry *entry, + const dlogutil_entry_s *entry, size_t *p_outLength, const char *tag, const char *msg) @@ -842,7 +842,7 @@ enum ts_type { TS_RECV, }; -static bool entry_get_ts_inner(const struct dlogutil_entry *entry, bool sent, bool mono, struct timespec *target) +static bool entry_get_ts_inner(const dlogutil_entry_s *entry, bool sent, bool mono, struct timespec *target) { int sec = sent ? (mono ? entry->sec_sent_mono : entry->sec_sent_real) @@ -859,7 +859,7 @@ static bool entry_get_ts_inner(const struct dlogutil_entry *entry, bool sent, bo return true; } -struct timespec entry_get_ts(const struct dlogutil_entry *entry, const log_print_format format, enum ts_type type) +struct timespec entry_get_ts(const dlogutil_entry_s *entry, const log_print_format format, enum ts_type type) { /* The returned timestamp should match the format (as in, the printf specifier) used below. * In particular, monotonic timestamps should be the ones represented by the 'raw' (%u) @@ -909,7 +909,7 @@ char *log_format_log_line( const struct log_format p_format, char *defaultBuffer, size_t defaultBufferSize, - const struct dlogutil_entry *entry, + const dlogutil_entry_s *entry, size_t *p_outLength) { #if defined(HAVE_LOCALTIME_R) @@ -1107,7 +1107,7 @@ char *log_format_log_line( char *p; size_t bufferSize; const char *pm; - int message_len = entry->len - sizeof(struct dlogutil_entry) - entry->tag_len - 2 /* tag and msg delimiters */; + int message_len = entry->len - sizeof(dlogutil_entry_s) - entry->tag_len - 2 /* tag and msg delimiters */; const char *const pre_color_prefix = get_pre_color((log_priority)entry->priority, colorPrefix && p_format.color); const char *const pre_color_suffix = get_pre_color((log_priority)entry->priority, colorSuffix && p_format.color); @@ -1220,7 +1220,7 @@ char *log_format_log_line( int log_print_log_line( struct log_format p_format, int fd, - const struct dlogutil_entry *entry) + const dlogutil_entry_s *entry) { int ret; char defaultBuffer[512]; diff --git a/src/shared/logretrieve.c b/src/shared/logretrieve.c index 65e8589..1bd2655 100644 --- a/src/shared/logretrieve.c +++ b/src/shared/logretrieve.c @@ -112,7 +112,7 @@ struct fd_info *find_earliest_log(struct fd_info **data_fds, int fd_count, dlogu if (!fdi || !fdi->ops->has_log(fdi)) continue; - const struct dlogutil_entry *const le = fdi->ops->peek_entry(fdi); + const dlogutil_entry_s *const le = fdi->ops->peek_entry(fdi); 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))) diff --git a/src/shared/queued_entry.c b/src/shared/queued_entry.c index 96724a0..5727dfb 100644 --- a/src/shared/queued_entry.c +++ b/src/shared/queued_entry.c @@ -150,7 +150,7 @@ int parse_kmsg_message(char *buffer, struct dlogutil_entry_with_msg *lem, int bu lem->header.len = lem->header.tag_len + 1; // plus NULL delimiter lem->header.len += 1 + snprintf(lem->msg + lem->header.len, sizeof lem->msg - 1 - lem->header.len, "%s", msg_begin); - lem->header.len += sizeof(struct dlogutil_entry); + lem->header.len += sizeof(dlogutil_entry_s); lem->header.padding = 0; return 0; @@ -181,7 +181,7 @@ int parse_kmsg_message(char *buffer, struct dlogutil_entry_with_msg *lem, int bu } #ifdef USE_ANDROID_MONOTONIC -static void parse_android_logger_footer(struct android_logger_entry *ale, struct dlogutil_entry *le, size_t *payload_size) +static void parse_android_logger_footer(struct android_logger_entry *ale, dlogutil_entry_s *le, size_t *payload_size) { assert(ale); assert(le); @@ -208,7 +208,7 @@ static void parse_android_logger_footer(struct android_logger_entry *ale, struct * @param[out] le Target structure to contain the log * @param[in] size The size of the datagram */ -void parse_androidlogger_message(struct android_logger_entry *ale, struct dlogutil_entry *le, size_t dgram_size) +void parse_androidlogger_message(struct android_logger_entry *ale, dlogutil_entry_s *le, size_t dgram_size) { size_t payload_size = dgram_size - sizeof *ale; assert(payload_size > 0); @@ -232,7 +232,7 @@ void parse_androidlogger_message(struct android_logger_entry *ale, struct dlogut le->default_send_ts_type = LOGGER_ENTRY_REALTIME; } -void parse_pipe_message(struct pipe_logger_entry *ple, struct dlogutil_entry *le, size_t msg_size) +void parse_pipe_message(struct pipe_logger_entry *ple, dlogutil_entry_s *le, size_t msg_size) { size_t payload_size = msg_size - sizeof *ple; assert(payload_size <= LOG_MAX_PAYLOAD_SIZE); @@ -255,7 +255,7 @@ void parse_pipe_message(struct pipe_logger_entry *ple, struct dlogutil_entry *le * @param[in] pid Process ID * @param msg Message */ -static void construct_logger_entry_from_syslog(struct dlogutil_entry *le, int priority, const char *tag, struct tm *timestamp, int pid, const char *msg) +static void construct_logger_entry_from_syslog(dlogutil_entry_s *le, int priority, const char *tag, struct tm *timestamp, int pid, const char *msg) { assert(le); assert(tag); @@ -265,7 +265,7 @@ static void construct_logger_entry_from_syslog(struct dlogutil_entry *le, int pr le->tag_len = strlen(tag); const int msg_len = strlen(msg) + 1; - le->len = sizeof(struct dlogutil_entry) + le->tag_len + 1 + msg_len; + le->len = sizeof(dlogutil_entry_s) + le->tag_len + 1 + msg_len; le->pid = pid; le->tid = 0; // could be set to PID but this way it's explicit the TID is not known le->sec_sent_real = mktime(timestamp); @@ -289,7 +289,7 @@ static void construct_logger_entry_from_syslog(struct dlogutil_entry *le, int pr * @param[out] le The logger entry to fill * @return 0 on failure, 1 on success */ -int parse_syslog_datagram(const char *buffer, int buffer_size, struct dlogutil_entry * le) +int parse_syslog_datagram(const char *buffer, int buffer_size, dlogutil_entry_s * le) { int fac_prio = -1, pid = 0; struct tm timestamp; diff --git a/src/shared/queued_entry_timestamp.c b/src/shared/queued_entry_timestamp.c index 6256485..a1184cf 100644 --- a/src/shared/queued_entry_timestamp.c +++ b/src/shared/queued_entry_timestamp.c @@ -28,7 +28,7 @@ * @details Add a timestamp describing reception time. * @param[in/out] le The logger entry to stamp time on. */ -void add_recv_timestamp(struct dlogutil_entry *le) +void add_recv_timestamp(dlogutil_entry_s *le) { struct timespec ts; @@ -46,7 +46,7 @@ void add_recv_timestamp(struct dlogutil_entry *le) * @details Replicates recv timestamp from sent timestamp where adding a new one would not make sense * @param[in/out] le The logger entry to replicate the time stamp for. */ -void copy_recv_timestamp(struct dlogutil_entry *le) +void copy_recv_timestamp(dlogutil_entry_s *le) { le->sec_recv_mono = le->sec_sent_mono; le->nsec_recv_mono = le->nsec_sent_mono; @@ -54,7 +54,7 @@ void copy_recv_timestamp(struct dlogutil_entry *le) le->nsec_recv_real = le->nsec_sent_real; } -bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const struct dlogutil_entry *lhs, const struct dlogutil_entry *rhs) +bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const dlogutil_entry_s *lhs, const dlogutil_entry_s *rhs) { assert(lhs); assert(rhs); @@ -95,7 +95,7 @@ bool log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const struct d return l_sec < r_sec || (l_sec == r_sec && l_nsec < r_nsec); } -struct timespec dlogutil_entry_ts(const struct dlogutil_entry *le, dlogutil_sorting_order_e stamp_type) +struct timespec dlogutil_entry_ts(const dlogutil_entry_s *le, dlogutil_sorting_order_e stamp_type) { assert(le); diff --git a/src/shared/sort_vector.c b/src/shared/sort_vector.c index 2def691..a260332 100644 --- a/src/shared/sort_vector.c +++ b/src/shared/sort_vector.c @@ -57,7 +57,7 @@ int sort_vector_finalize(struct sort_vector *logs) if (!IS_VECTOR_SIZE_SORTABLE(logs->size)) return 1; - logs->data = (struct dlogutil_entry **)calloc(logs->size, sizeof(struct dlogutil_entry *)); + logs->data = (dlogutil_entry_s **)calloc(logs->size, sizeof(dlogutil_entry_s *)); return logs->data != NULL; } @@ -77,7 +77,7 @@ void sort_vector_apply_config(struct sort_vector *logs, const struct log_config logs->timeout = log_config_get_int(config, "util_sorting_time_window", logs->timeout); } -struct dlogutil_entry *sort_vector_back(struct sort_vector *logs) +dlogutil_entry_s *sort_vector_back(struct sort_vector *logs) { return logs->data[logs->begin]; } @@ -114,7 +114,7 @@ int sort_vector_used_size(struct sort_vector *logs) * @param[in] logs Log sorting vector * @return 0 on success, -errno on failure */ -int sort_vector_push(struct sort_vector *logs, struct dlogutil_entry *p, dlogutil_write_cb callback, void *userdata) +int sort_vector_push(struct sort_vector *logs, dlogutil_entry_s *p, dlogutil_write_cb callback, void *userdata) { assert(logs); assert(logs->data); @@ -181,7 +181,7 @@ int sort_vector_push(struct sort_vector *logs, struct dlogutil_entry *p, dloguti * always all of the entries we receive have the same timestamps. Also, in such cases * correct sorting is impossible anyway. */ - struct dlogutil_entry *const e = logs->data[(i ?: logs->size) - 1]; + dlogutil_entry_s *const e = logs->data[(i ?: logs->size) - 1]; if (!log_entry_is_earlier(logs->sort_by, p, e)) break; logs->data[i] = e; @@ -223,7 +223,7 @@ long sort_vector_time_span(struct sort_vector *logs) * @param[out] callback_ret Return value of the callback if it has been called * @return bool whether the log was old enough */ -bool process_log(const struct dlogutil_entry *e, struct timespec reference_ts, dlogutil_sorting_order_e stamp_type, dlogutil_write_cb callback, void *userdata, long timeout, int *callback_ret) +bool process_log(const dlogutil_entry_s *e, struct timespec reference_ts, dlogutil_sorting_order_e stamp_type, dlogutil_write_cb callback, void *userdata, long timeout, int *callback_ret) { assert(e); assert(callback_ret); diff --git a/src/tests/fd_info.c b/src/tests/fd_info.c index 1570dc6..7536dfd 100644 --- a/src/tests/fd_info.c +++ b/src/tests/fd_info.c @@ -35,9 +35,9 @@ int __wrap_close(int fd) } static bool sv_flushed; -int callback(const struct dlogutil_entry *entry, void *userdata) +int callback(const dlogutil_entry_s *entry, void *userdata) { - assert(entry == (struct dlogutil_entry *) 0xBADFEEL); + assert(entry == (dlogutil_entry_s *) 0xBADFEEL); assert(userdata == (struct log_file *) 0xDEFACED); sv_flushed = true; @@ -46,9 +46,9 @@ int callback(const struct dlogutil_entry *entry, void *userdata) static bool sv_pushed; static int sv_push_retval; -int __wrap_sort_vector_push(struct sort_vector *logs, struct dlogutil_entry *p, dlogutil_write_cb comp_callback, void *userdata) +int __wrap_sort_vector_push(struct sort_vector *logs, dlogutil_entry_s *p, dlogutil_write_cb comp_callback, void *userdata) { - assert(p == (struct dlogutil_entry *) 0xBADFEEL); + assert(p == (dlogutil_entry_s *) 0xBADFEEL); assert(comp_callback == callback); assert(userdata == (struct log_file *) 0xDEFACED); @@ -59,15 +59,15 @@ int __wrap_sort_vector_push(struct sort_vector *logs, struct dlogutil_entry *p, struct fd_info G_fdi; static bool fail_extract; -struct dlogutil_entry *test_extract(struct fd_info *fdi) +dlogutil_entry_s *test_extract(struct fd_info *fdi) { assert(fdi == &G_fdi); - return fail_extract ? NULL : (struct dlogutil_entry *) 0xBADFEEL; + return fail_extract ? NULL : (dlogutil_entry_s *) 0xBADFEEL; } -struct timespec __wrap_dlogutil_entry_ts(const struct dlogutil_entry *le, dlogutil_sorting_order_e stamp_type) +struct timespec __wrap_dlogutil_entry_ts(const dlogutil_entry_s *le, dlogutil_sorting_order_e stamp_type) { - assert(le == (struct dlogutil_entry *)0xBADFEEL); + assert(le == (dlogutil_entry_s *)0xBADFEEL); return (struct timespec) { .tv_sec = 1, .tv_nsec = 1, @@ -81,10 +81,10 @@ void test_destroy(struct fd_info *fdi) } static bool should_print_line = true; -bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const struct dlogutil_entry *entry) +bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const dlogutil_entry_s *entry) { assert(p_filter == (dlogutil_filter_options_s *)404); - assert(entry == (struct dlogutil_entry *)0xBADFEEL); + assert(entry == (dlogutil_entry_s *)0xBADFEEL); return should_print_line; } diff --git a/src/tests/fdi_logger.c b/src/tests/fdi_logger.c index 3f79c34..70bb867 100644 --- a/src/tests/fdi_logger.c +++ b/src/tests/fdi_logger.c @@ -35,8 +35,8 @@ int __wrap_dlogutil_filter_options_filterspec(dlogutil_filter_options_s *p_filte assert(false); } -void __wrap_parse_androidlogger_message(struct android_logger_entry *ale, struct dlogutil_entry *le, size_t dgram_size) { } -void __wrap_copy_recv_timestamp(struct dlogutil_entry *le) { } +void __wrap_parse_androidlogger_message(struct android_logger_entry *ale, dlogutil_entry_s *le, size_t dgram_size) { } +void __wrap_copy_recv_timestamp(dlogutil_entry_s *le) { } static bool use_real_close; int __real_close(int fd); @@ -204,11 +204,11 @@ int main() if (!fail_malloc && i < NELEMS(READS) && READS[i] > sizeof(struct android_logger_entry)) { assert(ops_logger.has_log(&fdi)); assert(-EAGAIN == ops_logger.read(&fdi)); - const struct dlogutil_entry *const le = ops_logger.peek_entry(&fdi); + const dlogutil_entry_s *const le = ops_logger.peek_entry(&fdi); assert(le); assert(le == ops_logger.peek_entry(&fdi)); assert(le == ops_logger.extract_entry(&fdi)); - free((struct dlogutil_entry *) le); + free((dlogutil_entry_s *) le); } fail_malloc = 0; assert(!ops_logger.has_log(&fdi)); diff --git a/src/tests/fdi_pipe.c b/src/tests/fdi_pipe.c index 26dc2ad..3e8b023 100644 --- a/src/tests/fdi_pipe.c +++ b/src/tests/fdi_pipe.c @@ -179,8 +179,8 @@ int main() assert(ops_pipe.read(&info) == -EIO); read_errno = 0; - read_datalen = sizeof(struct dlogutil_entry) + 4; - struct dlogutil_entry *ent = read_data = malloc(read_datalen); + read_datalen = sizeof(dlogutil_entry_s) + 4; + dlogutil_entry_s *ent = read_data = malloc(read_datalen); assert(ent); read_pos = 0; ent->len = read_datalen; @@ -196,7 +196,7 @@ int main() assert(!ops_pipe.extract_entry(&info)); malloc_fail = false; - struct dlogutil_entry *ent2 = ops_pipe.extract_entry(&info); + dlogutil_entry_s *ent2 = ops_pipe.extract_entry(&info); assert(!memcmp(ent, ent2, ent->len)); __real_free(ent2); @@ -233,7 +233,7 @@ ok: } __real_free(ent); - read_datalen = sizeof(struct dlogutil_entry); + read_datalen = sizeof(dlogutil_entry_s); read_data = calloc(1, read_datalen); read_pos = 0; assert(ops_pipe.read(&info) == read_datalen); diff --git a/src/tests/filters.c b/src/tests/filters.c index e8f23a2..444a716 100644 --- a/src/tests/filters.c +++ b/src/tests/filters.c @@ -39,7 +39,7 @@ int check_print_line_tid_single(int line, dlogutil_filter_options_s *p_filter, p entry.header.pid = 0; entry.header.tid = tid; entry.header.priority = DLOG_DEBUG; // priority, for unmatched entries that have to face the global filter - entry.header.len = sizeof(struct dlogutil_entry) + 2; + entry.header.len = sizeof(dlogutil_entry_s) + 2; if (expected != log_should_print_line(p_filter, &entry.header)) { printf("Check in line %d for tid %lu failed to return %d \n", line, tid, @@ -85,7 +85,7 @@ int check_print_line_pid_single(int line, dlogutil_filter_options_s *p_filter, p entry.header.tid = 0; entry.header.pid = pid; entry.header.priority = DLOG_DEBUG; // priority, for unmatched entries that have to face the global filter - entry.header.len = sizeof(struct dlogutil_entry) + 2; + entry.header.len = sizeof(dlogutil_entry_s) + 2; if (expected != log_should_print_line(p_filter, &entry.header)) { printf("Check in line %d for pid %d failed to return %d \n", line, pid, @@ -131,7 +131,7 @@ int check_print_line_tag_prior(int line, dlogutil_filter_options_s *p_filter, ch entry.header.priority = priority; strncpy(entry.msg, tag, strlen(tag) + 1); entry.msg[strlen(tag) + 1] = '\0'; // second NULL terminator: empty message - entry.header.len = sizeof(struct dlogutil_entry) + strlen(tag) + 2; + entry.header.len = sizeof(dlogutil_entry_s) + strlen(tag) + 2; if (expected != log_should_print_line(p_filter, &entry.header)) { printf("Check in line %d for tag %s and priority %c failed to return %d \n", line, tag, @@ -232,7 +232,7 @@ int main() strncpy(entry.msg, "crap", taglen); entry.msg[taglen] = '\0'; /* tag delimiter */ entry.msg[taglen + 1] = '\0'; /* empty msg */ - entry.header.len = sizeof(struct dlogutil_entry) + taglen + 2; + entry.header.len = sizeof(dlogutil_entry_s) + taglen + 2; assert(log_should_print_line(p_filter, &entry.header)); result += check_print_line_tag(__LINE__, p_filter, "crap", verbose | debug | info | warn | error | fatal); diff --git a/src/tests/kmsg_parser.c b/src/tests/kmsg_parser.c index 5ea04b4..b989f6d 100644 --- a/src/tests/kmsg_parser.c +++ b/src/tests/kmsg_parser.c @@ -57,7 +57,7 @@ int main() lem.header.len = lem.header.tag_len + 1; // plus NULL delimiter lem.header.len += 1 + snprintf(lem.msg + lem.header.len, sizeof lem.msg - 1 - lem.header.len, "%s", "Some message."); - lem.header.len += sizeof(struct dlogutil_entry); + lem.header.len += sizeof(dlogutil_entry_s); lem.header.padding = 0; assert_entry("1,234,56789,-;Some message.\n _SOME_IRRELEVANT_TAG=BLA\n", &lem); diff --git a/src/tests/log_file.c b/src/tests/log_file.c index ff2db4b..2e6da0e 100644 --- a/src/tests/log_file.c +++ b/src/tests/log_file.c @@ -34,19 +34,19 @@ int __wrap_rename(const char *oldpath, const char *newpath) return -1; } -struct timespec __wrap_dlogutil_entry_ts(const struct dlogutil_entry *le, dlogutil_sorting_order_e stamp_type) +struct timespec __wrap_dlogutil_entry_ts(const dlogutil_entry_s *le, dlogutil_sorting_order_e stamp_type) { assert(stamp_type == DLOGUTIL_SORT_SENT_MONO); - assert(le == (struct dlogutil_entry *) 0xBA5EBALL); + assert(le == (dlogutil_entry_s *) 0xBA5EBALL); return (struct timespec) { .tv_sec = 3333, .tv_nsec = 9999, }; } -char *__wrap_dlogutil_entry_tag(const struct dlogutil_entry *entry) +char *__wrap_dlogutil_entry_tag(const dlogutil_entry_s *entry) { - assert(entry == (struct dlogutil_entry *) 0xBA5EBALL); + assert(entry == (dlogutil_entry_s *) 0xBA5EBALL); return ""; } @@ -58,7 +58,7 @@ void *__wrap_memcpy(void *dest, const void *src, size_t n) return __real_memcpy(dest, src, n); assert(src == (void *) 0xBA5EBALL); - assert(n == sizeof(struct dlogutil_entry)); + assert(n == sizeof(dlogutil_entry_s)); return dest; } @@ -70,7 +70,7 @@ int __wrap_snprintf(char *str, size_t size, const char *format, ...) static int log_print_log_line_ret; static bool log_print_log_line_correct_color; -int __wrap_log_print_log_line(struct log_format p_format, int fd, const struct dlogutil_entry *entry) +int __wrap_log_print_log_line(struct log_format p_format, int fd, const dlogutil_entry_s *entry) { assert(fd == 0xFD); assert(p_format.color == log_print_log_line_correct_color); @@ -187,48 +187,48 @@ int main() isatty_ret = lf.isatty = false; log_print_log_line_ret = -1; log_print_log_line_correct_color = false; - assert(logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); + assert(logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); assert(lf.prev_sec == 4444); assert(lf.prev_nsec == 6666); log_print_log_line_ret = 1; fail_snprintf = true; - assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); + assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); assert(lf.prev_sec == 3333); assert(lf.prev_nsec == 9999); lf.colors_auto = true; - assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); + assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); assert(lf.prev_sec == 3333); assert(lf.prev_nsec == 9999); isatty_ret = lf.isatty = true; lf.colors_auto = false; - assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); + assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); assert(lf.prev_sec == 3333); assert(lf.prev_nsec == 9999); lf.colors_auto = true; log_print_log_line_correct_color = true; - assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); + assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); assert(lf.prev_sec == 3333); assert(lf.prev_nsec == 9999); isatty_ret = lf.isatty = false; lf.format.color = true; lf.colors_auto = false; - assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); + assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); assert(lf.prev_sec == 3333); assert(lf.prev_nsec == 9999); lf.colors_auto = true; log_print_log_line_correct_color = false; - assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); + assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); assert(lf.prev_sec == 3333); assert(lf.prev_nsec == 9999); fail_snprintf = false; - assert(!logfile_write_with_rotation((struct dlogutil_entry *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); + assert(!logfile_write_with_rotation((dlogutil_entry_s *) 0xBA5EBALL, &lf, DLOGUTIL_SORT_SENT_MONO)); custom_memcpy = false; logfile_free(&lf); diff --git a/src/tests/logger.c b/src/tests/logger.c index 509cc37..e0d24a0 100644 --- a/src/tests/logger.c +++ b/src/tests/logger.c @@ -34,7 +34,7 @@ int reader_is_bufferable(const struct reader *reader); int reader_ms_since(const struct reader *reader, struct timespec *ts); int reader_should_buffer(struct reader *reader, const struct buf_params *buf_params, struct timespec now); void reader_free(struct reader* reader); -int buffer_append(const struct dlogutil_entry *entry, struct log_buffer *b); +int buffer_append(const dlogutil_entry_s *entry, struct log_buffer *b); int reader_init_for_pipe(struct reader *reader, const char *buf_name, struct logger *server); int reader_init_for_logger(struct reader *reader, const char *buf_name, struct logger *server); int print_out_logs(struct reader *reader); @@ -44,7 +44,7 @@ int modify_fd_entity(const struct logger *logger, struct fd_entity *fd_entity, i int remove_fd_entity(struct logger *logger, struct fd_entity *fd_entity); void writer_close_fd(struct logger* server, struct writer* wr); int add_buffer_reader(struct log_buffer *buffer, struct reader *reader); -void reader_notify_losing_log(const struct dlogutil_entry *le, void *reader_); +void reader_notify_losing_log(const dlogutil_entry_s *le, void *reader_); bool fail_dlog_group_server = false; int __wrap_getgrnam_r(const char *name, struct group *grp, @@ -372,10 +372,10 @@ void __wrap_logfile_free(struct log_file *l_file) } bool add_new_entry_result = true; -bool __wrap_log_storage_add_new_entry(log_storage *storage, const struct dlogutil_entry *le) +bool __wrap_log_storage_add_new_entry(log_storage *storage, const dlogutil_entry_s *le) { assert(storage == (log_storage *)570); - assert(le == (struct dlogutil_entry *)0xE); + assert(le == (dlogutil_entry_s *)0xE); return add_new_entry_result; } @@ -853,10 +853,10 @@ int main() }; add_new_entry_result = false; - assert(buffer_append((struct dlogutil_entry *)0xE, &adder) == -ENOMEM); + assert(buffer_append((dlogutil_entry_s *)0xE, &adder) == -ENOMEM); add_new_entry_result = true; - assert(buffer_append((struct dlogutil_entry *)0xE, &adder) == 0); + assert(buffer_append((dlogutil_entry_s *)0xE, &adder) == 0); struct reader reader3 = {}; struct logger server = { diff --git a/src/tests/logprint.c b/src/tests/logprint.c index 7542aca..36c0d5b 100644 --- a/src/tests/logprint.c +++ b/src/tests/logprint.c @@ -339,8 +339,8 @@ enum ts_type { TS_RECV, }; const char *json_priority_name(log_priority prio); -struct timespec entry_get_ts(const struct dlogutil_entry *entry, const log_print_format format, enum ts_type type); -char *log_format_json(char *default_buffer, size_t default_buffer_size, const struct dlogutil_entry *entry, size_t *p_outLength, char *tag, char *msg); +struct timespec entry_get_ts(const dlogutil_entry_s *entry, const log_print_format format, enum ts_type type); +char *log_format_json(char *default_buffer, size_t default_buffer_size, const dlogutil_entry_s *entry, size_t *p_outLength, char *tag, char *msg); void check_json() { // TODO: Failure testing @@ -365,7 +365,7 @@ void check_json() assert(!strcmp(json_priority_name(123), "unknown")); char data[] = "tag\0important message"; - struct dlogutil_entry *ent = calloc(1, sizeof(struct dlogutil_entry) + sizeof data); + dlogutil_entry_s *ent = calloc(1, sizeof(dlogutil_entry_s) + sizeof data); assert(ent); ent->len = sizeof data; ent->tag_len = 3; @@ -557,7 +557,7 @@ void check_syscall_failure_handling() void check_invalid_input() { - const struct dlogutil_entry entry = { .len = 1 }; + const dlogutil_entry_s entry = { .len = 1 }; assert(!dlogutil_entry_msg(&entry)); assert(!dlogutil_entry_tag(&entry)); diff --git a/src/tests/logutil.c b/src/tests/logutil.c index 80812e6..19f07a8 100644 --- a/src/tests/logutil.c +++ b/src/tests/logutil.c @@ -6,7 +6,7 @@ #include #include -bool process_log(const struct dlogutil_entry *e, struct timespec reference_ts, dlogutil_sorting_order_e stamp_type, dlogutil_write_cb callback, void *userdata, long timeout, int *callback_ret); +bool process_log(const dlogutil_entry_s *e, struct timespec reference_ts, dlogutil_sorting_order_e stamp_type, dlogutil_write_cb callback, void *userdata, long timeout, int *callback_ret); struct fd_info *find_earliest_log(struct fd_info **data_fds, int fd_count, dlogutil_sorting_order_e sort_by); int put_logs_into_vector(struct fd_info **data_fds, int fd_count, int nfds, struct sort_vector *logs, dlogutil_write_cb callback, void *userdata, dlogutil_filter_options_s *filter); int validate_buffers(int *enabled_buffers); @@ -14,7 +14,7 @@ int validate_buffers(int *enabled_buffers); int written_logs = 0; bool free_entries = false; int callback_ret = 0; -int callback(const struct dlogutil_entry *entry, void *userdata) +int callback(const dlogutil_entry_s *entry, void *userdata) { assert(userdata == (void *)0xDDD); @@ -33,7 +33,7 @@ int __wrap_clock_gettime(clockid_t clk_id, struct timespec *tp) return 0; } -bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const struct dlogutil_entry *entry) +bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const dlogutil_entry_s *entry) { return true; } @@ -41,7 +41,7 @@ bool __wrap_log_should_print_line(dlogutil_filter_options_s *p_filter, const str struct fdi_internal { bool has_log; - const struct dlogutil_entry *ent; + const dlogutil_entry_s *ent; }; bool test_has_log(struct fd_info *fdi) @@ -50,7 +50,7 @@ bool test_has_log(struct fd_info *fdi) return ii->has_log; } -const struct dlogutil_entry *test_peek_entry(const struct fd_info *fdi) +const dlogutil_entry_s *test_peek_entry(const struct fd_info *fdi) { struct fdi_internal *ii = fdi->priv_data; return ii->ent; @@ -62,9 +62,9 @@ int __wrap_fdi_push_log(struct fd_info *fdi, struct sort_vector *logs, dlogutil_ assert(filter == (dlogutil_filter_options_s *)0xEEE); if (fdi_push_log_ret != 0) return fdi_push_log_ret; - struct dlogutil_entry *ent = calloc(1, sizeof(struct dlogutil_entry)); + dlogutil_entry_s *ent = calloc(1, sizeof(dlogutil_entry_s)); assert(ent); - memcpy(ent, fdi->ops->peek_entry(fdi), sizeof(struct dlogutil_entry)); + memcpy(ent, fdi->ops->peek_entry(fdi), sizeof(dlogutil_entry_s)); struct fdi_internal *ii = fdi->priv_data; ii->has_log = false; return sort_vector_push(logs, ent, callback, userdata); @@ -72,7 +72,7 @@ int __wrap_fdi_push_log(struct fd_info *fdi, struct sort_vector *logs, dlogutil_ int main() { - struct dlogutil_entry ent = { + dlogutil_entry_s ent = { .sec_sent_mono = 0, .nsec_sent_mono = 900000000, .sec_sent_real = 0, @@ -130,7 +130,7 @@ int main() assert(written_logs == 3 && sort_vector_used_size(&sv) == 0); for (int i = 0; i < 10; ++i) { - struct dlogutil_entry *ent2 = calloc(1, sizeof(struct dlogutil_entry)); + dlogutil_entry_s *ent2 = calloc(1, sizeof(dlogutil_entry_s)); assert(ent2); ent2->sec_sent_mono = 1; ent2->nsec_sent_mono = (79 + i) * 10000000; @@ -142,7 +142,7 @@ int main() sort_vector_flush(&sv, callback, (struct log_file *)0xDDD, false); assert(written_logs == 9 && sort_vector_used_size(&sv) == 4); - struct dlogutil_entry *ent3 = calloc(1, sizeof(struct dlogutil_entry)); + dlogutil_entry_s *ent3 = calloc(1, sizeof(dlogutil_entry_s)); assert(ent3); ent3->sec_sent_mono = 0; ent3->nsec_sent_mono = 999999999; @@ -156,7 +156,7 @@ int main() struct fd_info fd_stor[10] = {}; struct fdi_internal ii_stor[10] = {}; - struct dlogutil_entry ent_stor[10 - 3] = {}; + dlogutil_entry_s ent_stor[10 - 3] = {}; for (int i = 0; i < 10; ++i) { if (i < 3) ii_stor[i].has_log = false; @@ -183,7 +183,7 @@ int main() while (!sort_vector_empty(&sv)) sort_vector_pop(&sv); - struct dlogutil_entry *ent_future = calloc(1, sizeof(struct dlogutil_entry)); + dlogutil_entry_s *ent_future = calloc(1, sizeof(dlogutil_entry_s)); assert(ent_future); ent_future->sec_sent_mono = 2; ent_future->nsec_sent_mono = 0; diff --git a/src/tests/pipe_message.c b/src/tests/pipe_message.c index 4b852f1..66c81c1 100644 --- a/src/tests/pipe_message.c +++ b/src/tests/pipe_message.c @@ -22,7 +22,7 @@ int main() char tag[] = "TEST_TAG"; char msg[] = "Test message with a newline \n and some special characters \e[31m in colour"; struct pipe_logger_entry *ple = alloca(LOG_MAX_PAYLOAD_SIZE + sizeof *ple); - struct dlogutil_entry *le = alloca(LOG_MAX_PAYLOAD_SIZE + sizeof *le); + dlogutil_entry_s *le = alloca(LOG_MAX_PAYLOAD_SIZE + sizeof *le); struct timespec ts_pre, ts_post; clock_gettime(CLOCK_MONOTONIC, &ts_pre); diff --git a/src/tests/queued_entry.c b/src/tests/queued_entry.c index 30fddea..852ba23 100644 --- a/src/tests/queued_entry.c +++ b/src/tests/queued_entry.c @@ -48,7 +48,7 @@ int main() } struct timespec ts; - struct dlogutil_entry le = { + dlogutil_entry_s le = { .sec_sent_mono = 1, .nsec_sent_mono = 2, .sec_sent_real = 3, diff --git a/src/tests/sort_vector.c b/src/tests/sort_vector.c index dadb158..b3c174a 100644 --- a/src/tests/sort_vector.c +++ b/src/tests/sort_vector.c @@ -7,14 +7,14 @@ size_t total_flushed; int callback_ret = 0; -int callback(const struct dlogutil_entry *e, void *userdata) +int callback(const dlogutil_entry_s *e, void *userdata) { assert(userdata == (void *)0xDA7A); total_flushed += (size_t) e; return callback_ret; } -bool __wrap_log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const struct dlogutil_entry *lhs, const struct dlogutil_entry *rhs) +bool __wrap_log_entry_is_earlier(const dlogutil_sorting_order_e sort_by, const dlogutil_entry_s *lhs, const dlogutil_entry_s *rhs) { return lhs < rhs; } @@ -75,7 +75,7 @@ int main() struct log_file lf; memset(&lf, 0, sizeof(struct log_file)); -#define ADD(x) assert(sort_vector_push(&sv, (struct dlogutil_entry *) x, callback, (void *)0xDA7A) == callback_ret) +#define ADD(x) assert(sort_vector_push(&sv, (dlogutil_entry_s *) x, callback, (void *)0xDA7A) == callback_ret) #define POP(x) \ free_total = 0; \ sort_vector_pop(&sv); \ @@ -99,7 +99,7 @@ int main() * └──┴──┴──┴──┴──┴──┴──┘ */ assert(!sort_vector_empty(&sv)); assert(!sort_vector_full(&sv)); - assert((struct dlogutil_entry *) 12 == sort_vector_back(&sv)); + assert((dlogutil_entry_s *) 12 == sort_vector_back(&sv)); assert(5 == sort_vector_used_size(&sv)); POP(12); @@ -110,7 +110,7 @@ int main() * └──┴──┴──┴──┴──┴──┴──┘ */ assert(!sort_vector_empty(&sv)); assert(sort_vector_full(&sv)); // the empty slot is reserved for operations - assert((struct dlogutil_entry *) 7 == sort_vector_back(&sv)); + assert((dlogutil_entry_s *) 7 == sort_vector_back(&sv)); assert(6 == sort_vector_used_size(&sv)); ADD(24); @@ -121,7 +121,7 @@ int main() * └──┴──┴──┴──┴──┴──┴──┘ */ assert(!sort_vector_empty(&sv)); assert(sort_vector_full(&sv)); - assert((struct dlogutil_entry *) 17 == sort_vector_back(&sv)); + assert((dlogutil_entry_s *) 17 == sort_vector_back(&sv)); assert(6 == sort_vector_used_size(&sv)); POP(17); @@ -134,7 +134,7 @@ int main() * └──┴──┴──┴──┴──┴──┴──┘ */ assert(!sort_vector_empty(&sv)); assert(sort_vector_full(&sv)); - assert((struct dlogutil_entry *) 20 == sort_vector_back(&sv)); + assert((dlogutil_entry_s *) 20 == sort_vector_back(&sv)); assert(6 == sort_vector_used_size(&sv)); callback_ret = 13; @@ -146,24 +146,24 @@ int main() * └──┴──┴──┴──┴──┴──┴──┘ */ assert(!sort_vector_empty(&sv)); assert(sort_vector_full(&sv)); - assert((struct dlogutil_entry *) 20 == sort_vector_back(&sv)); + assert((dlogutil_entry_s *) 20 == sort_vector_back(&sv)); assert(6 == sort_vector_used_size(&sv)); callback_ret = 0; #undef ADD #undef POP - assert(sv.data[0] == (struct dlogutil_entry *) 33); - assert(sv.data[1] == (struct dlogutil_entry *) 40); - assert(sv.data[2] == (struct dlogutil_entry *) 41); - assert(sv.data[3] == (struct dlogutil_entry *) 0); - assert(sv.data[4] == (struct dlogutil_entry *) 20); - assert(sv.data[5] == (struct dlogutil_entry *) 24); - assert(sv.data[6] == (struct dlogutil_entry *) 25); + assert(sv.data[0] == (dlogutil_entry_s *) 33); + assert(sv.data[1] == (dlogutil_entry_s *) 40); + assert(sv.data[2] == (dlogutil_entry_s *) 41); + assert(sv.data[3] == (dlogutil_entry_s *) 0); + assert(sv.data[4] == (dlogutil_entry_s *) 20); + assert(sv.data[5] == (dlogutil_entry_s *) 24); + assert(sv.data[6] == (dlogutil_entry_s *) 25); assert(sv.begin == 4); assert(sv.end == 3); - struct dlogutil_entry **const data = sv.data; + dlogutil_entry_s **const data = sv.data; free_total = 0; sort_vector_free(&sv); assert(total_flushed == 0); diff --git a/src/tests/syslog_parser.c b/src/tests/syslog_parser.c index 49e1e39..6c4b39a 100644 --- a/src/tests/syslog_parser.c +++ b/src/tests/syslog_parser.c @@ -7,7 +7,7 @@ int main() { char buffer[1024]; int len; - struct dlogutil_entry * sle = alloca(1024); + dlogutil_entry_s * sle = alloca(1024); // No priority delimiter '>'. len = snprintf(buffer, sizeof buffer, "<10 Jan 02 03:04:05 progname: msg"); diff --git a/src/tests/test_logger_log_storage.c b/src/tests/test_logger_log_storage.c index 723e5d3..e11ca6a 100644 --- a/src/tests/test_logger_log_storage.c +++ b/src/tests/test_logger_log_storage.c @@ -22,10 +22,10 @@ #define STR1 "a" -#define LE_SM(str, tsec, tnsec) {{sizeof(struct dlogutil_entry)+sizeof(str)+1, 0, 0, 1, 1, (tsec), (tnsec), 0U, 0U, 0U, 0U, 0U, 0U, 0U, LOGGER_ENTRY_MONOTONIC}, str} -#define LE_SR(str, tsec, tnsec) {{sizeof(struct dlogutil_entry)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, (tsec), (tnsec), 0U, 0U, 0U, 0U, 0U, LOGGER_ENTRY_REALTIME}, str} -#define LE_RM(str, tsec, tnsec) {{sizeof(struct dlogutil_entry)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, 0U, 0U, (tsec), (tnsec), 0U, 0U, 0U, LOGGER_ENTRY_MONOTONIC}, str} -#define LE_RR(str, tsec, tnsec) {{sizeof(struct dlogutil_entry)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, 0U, 0U, 0U, 0U, (tsec), (tnsec), 0U, LOGGER_ENTRY_REALTIME}, str} +#define LE_SM(str, tsec, tnsec) {{sizeof(dlogutil_entry_s)+sizeof(str)+1, 0, 0, 1, 1, (tsec), (tnsec), 0U, 0U, 0U, 0U, 0U, 0U, 0U, LOGGER_ENTRY_MONOTONIC}, str} +#define LE_SR(str, tsec, tnsec) {{sizeof(dlogutil_entry_s)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, (tsec), (tnsec), 0U, 0U, 0U, 0U, 0U, LOGGER_ENTRY_REALTIME}, str} +#define LE_RM(str, tsec, tnsec) {{sizeof(dlogutil_entry_s)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, 0U, 0U, (tsec), (tnsec), 0U, 0U, 0U, LOGGER_ENTRY_MONOTONIC}, str} +#define LE_RR(str, tsec, tnsec) {{sizeof(dlogutil_entry_s)+sizeof(str)+1, 0, 0, 1, 1, 0U, 0U, 0U, 0U, 0U, 0U, (tsec), (tnsec), 0U, LOGGER_ENTRY_REALTIME}, str} static bool fail_malloc = false; void *__real_malloc(size_t size); @@ -34,14 +34,14 @@ void *__wrap_malloc(size_t size) return fail_malloc ? NULL : __real_malloc(size); } -void dont_call_this_callback(const struct dlogutil_entry *le, void *user_data) +void dont_call_this_callback(const dlogutil_entry_s *le, void *user_data) { assert(false); } int callback_count = 0; -void callback_check_msg(const struct dlogutil_entry *le, void *user_data) +void callback_check_msg(const dlogutil_entry_s *le, void *user_data) { assert(le); assert(user_data); @@ -53,7 +53,7 @@ void callback_check_msg(const struct dlogutil_entry *le, void *user_data) int check_sec = 0; -void callback_check_sec(const struct dlogutil_entry *le, void *user_data) +void callback_check_sec(const dlogutil_entry_s *le, void *user_data) { assert(le); @@ -61,7 +61,7 @@ void callback_check_sec(const struct dlogutil_entry *le, void *user_data) callback_count++; } -void callback_count_inc(const struct dlogutil_entry *le, void *user_data) +void callback_count_inc(const dlogutil_entry_s *le, void *user_data) { assert(le); @@ -108,7 +108,7 @@ void test_reader_get_new_entry(log_storage_reader *r, unsigned sec_to_check) assert(r); const struct log_storage *s = log_storage_reader_get_storage(r); - const struct dlogutil_entry *le = log_storage_reader_get_new_entry(r); + const dlogutil_entry_s *le = log_storage_reader_get_new_entry(r); assert(le); assert(s); int32_t entry_sec; -- 2.7.4