#define DYNAMIC_CONFIG_FILENAME "05-logctl.conf"
bool __dynamic_config_create(struct log_config *config);
-void __dynamic_config_destroy();
-void __dynamic_config_update();
+void __dynamic_config_destroy(void);
+void __dynamic_config_update(void);
#ifdef __cplusplus
}
struct log_config;
extern int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg, struct timespec *tp_mono);
-extern void (*destroy_backend)();
+extern void (*destroy_backend)(void);
extern pthread_rwlock_t log_limiter_lock;
extern bool limiter;
int __log_limiter_dump_rule(struct rule **, char *, const size_t);
// Note: result only valid until next __log_limiter_{update,destroy}
-list_head __log_limiter_get_pid_limits();
+list_head __log_limiter_get_pid_limits(void);
#ifdef __cplusplus
}
size_t size;
struct timespec oldest_log;
};
-struct log_filter *log_filter_new();
+struct log_filter *log_filter_new(void);
void log_filter_free(struct log_filter *p_filter);
struct log_filter {
void log_filter_init(struct log_filter *p_filter);
-struct log_write_buffer log_write_buffer_new();
+struct log_write_buffer log_write_buffer_new(void);
void log_write_buffer_free(struct log_write_buffer *buf);
#include <dlogutil.h>
-struct metrics *metrics_create();
+struct metrics *metrics_create(void);
void metrics_destroy(struct metrics *);
bool metrics_add_log(struct metrics *, const dlogutil_entry_s *);
static char warning_content[WARNING_MAX];
static deduplicate_log basic_log;
-static void refresh_deduplication_limits()
+static void refresh_deduplication_limits(void)
{
known_hashes_size = 0;
}
}
}
-void __deduplicate_destroy()
+void __deduplicate_destroy(void)
{
known_hashes_size = 0;
free(known_hashes_vector);
void deduplicate_warn(char *buf, size_t size, size_t len);
void __configure_deduplicate(struct log_config *config);
-void __deduplicate_destroy();
+void __deduplicate_destroy(void);
extern dlog_deduplicate_e (*deduplicate_func)(const char *, size_t, struct timespec *);
#endif /* _DEDUPLICATE_H_ */
return true;
}
-static void __apply_update()
+static void __apply_update(void)
{
assert(inotify_path);
}
/// caller has to guarantee exclusive access
-void __dynamic_config_destroy()
+void __dynamic_config_destroy(void)
{
assert(inotify_fd < 0 || inotify_path);
assert(inotify_fd >= 0 || !inotify_path);
inotify_fd = -1;
}
-void __dynamic_config_update()
+void __dynamic_config_update(void)
{
if (inotify_fd < 0)
return;
* @see __dlog_init_backend
*/
int (*write_to_log)(log_id_t log_id, log_priority prio, const char *tag, const char *msg, struct timespec *tp_mono) = NULL;
-void (*destroy_backend)();
+void (*destroy_backend)(void);
int (*stash_failed_log)(log_id_t log_id, log_priority prio, const char *tag, const char *msg) = NULL;
#ifndef UNIT_TEST
return 1;
}
-static void __set_plog_default_values()
+static void __set_plog_default_values(void)
{
for (size_t i = 0; i < NELEMS(plog); ++i)
plog_default_values[i] = plog[i];
}
static bool first = true;
-static bool initialize()
+static bool initialize(void)
{
if (is_initialized)
return true;
return ret;
}
-static void __destroy_androidlogger()
+static void __destroy_androidlogger(void)
{
/* No need for an explicit lock here; this should only be called
* by the library destructor which has its own lock */
return ret;
}
-static void __destroy_pipe()
+static void __destroy_pipe(void)
{
/* No need for an explicit lock here; this should only be called
* by the library destructor which has its own lock */
* @brief Print help
* @details Prints basic usage tips
*/
-static void help()
+static void help(void)
{
printf("Usage: %s [options]\n"
"\t-h Show this help\n"
* @details Resets privileges to those specified at build-time
* @return 0 on success, else -errno
*/
-int reset_self_privileges()
+int reset_self_privileges(void)
{
uid_t uid;
gid_t gid;
#include <sys/types.h>
int parse_permissions(const char *str);
-int reset_self_privileges();
+int reset_self_privileges(void);
int usergr2id(const char *user, const char *group, uid_t *uid, gid_t *gid);
return 0;
}
-static struct reader_logger *reader_logger_alloc()
+static struct reader_logger *reader_logger_alloc(void)
{
struct reader_logger *const ret = calloc(1, sizeof *ret);
if (!ret)
static const char dev_log_sock[] = "/run/dlog/dev-log";
static const char dev_log_link[] = "/dev/log";
-int dev_log_sock_get()
+int dev_log_sock_get(void)
{
return systemd_sock_get(dev_log_sock, SOCK_DGRAM);
}
-int dev_log_sock_create()
+int dev_log_sock_create(void)
{
int fd = bind_fd_create(dev_log_sock, SOCK_DGRAM);
if (fd >= 0) {
int socket_initialize(struct sock_data *sock, struct log_buffer *buffer, service_socket_t service_socket, struct socket_config_data *data);
void socket_close(struct sock_data *sock);
-int dev_log_sock_get();
-int dev_log_sock_create();
+int dev_log_sock_get(void);
+int dev_log_sock_create(void);
#ifdef UNIT_TEST
int bind_fd_create(const char *path, int type);
cached_pid_rule = p;
}
-static struct pass_log_result block_by_pid()
+static struct pass_log_result block_by_pid(void)
{
pid_t my_pid = getpid();
return 0;
}
-static void destroy_hashmap_etc()
+static void destroy_hashmap_etc(void)
{
hashmap_destroy(&rules_hashmap);
rules_destroy(&original_rules_table);
return 0;
}
-list_head __log_limiter_get_pid_limits()
+list_head __log_limiter_get_pid_limits(void)
{
return pid_rules;
}
int capacity;
};
-struct metrics *metrics_create()
+struct metrics *metrics_create(void)
{
return calloc(1, sizeof(struct metrics));
}
return fail_calloc ? NULL : __real_calloc(nmemb, size);
}
-int main()
+int main(void)
{
const char * get;
struct log_config config;
called_atexit = true;
}
-int main()
+int main(void)
{
called_atexit = false;
assert(!atexit(atexit_f));
assert(dlog_print(DLOG_INFO, "tag", fmt) == ret);
}
-void test_basic_1ms_interval()
+void test_basic_1ms_interval(void)
{
local_advanced = "only_identical_neighbours";
local_time_ms = "1";
__dlog_fini();
}
-void test_basic_10ms_interval()
+void test_basic_10ms_interval(void)
{
local_advanced = "only_identical_neighbours";
local_time_ms = "10";
__dlog_fini();
}
-void test_basic_1ms_interval_warning()
+void test_basic_1ms_interval_warning(void)
{
local_advanced = "only_identical_neighbours";
local_time_ms = "10";
__dlog_fini();
}
-void test_advanced_1ms_interval()
+void test_advanced_1ms_interval(void)
{
local_advanced = "all_identical_logs";
local_time_ms = "1";
__dlog_fini();
}
-void test_advanced_10ms_interval()
+void test_advanced_10ms_interval(void)
{
local_advanced = "all_identical_logs";
local_time_ms = "10";
__dlog_fini();
}
-void test_advanced_10ms_interval_warning()
+void test_advanced_10ms_interval_warning(void)
{
local_advanced = "all_identical_logs";
local_time_ms = "10";
__dlog_fini();
}
-void test_advanced_many_hashes()
+void test_advanced_many_hashes(void)
{
local_advanced = "all_identical_logs";
local_time_ms = "1";
__dlog_fini();
}
-void test_advanced_many_millisec()
+void test_advanced_many_millisec(void)
{
local_advanced = "all_identical_logs";
local_time_ms = "1";
__dlog_fini();
}
-void test_deduplicate_warn()
+void test_deduplicate_warn(void)
{
use_real_deduplicate_warn = true;
local_warn_quantity = "11";
__dlog_fini();
}
-void test_deduplicate_warn_random()
+void test_deduplicate_warn_random(void)
{
use_real_deduplicate_warn = false;
local_advanced = "only_identical_neighbours";
__dlog_fini();
}
-int main()
+int main(void)
{
test_basic_1ms_interval();
test_basic_10ms_interval();
return pretend_the_mutex_is_locked ? -1 : __real_pthread_mutex_trylock(mutex);
}
-int main()
+int main(void)
{
// check whether these blow up when called before init
__dynamic_config_update();
#include "fd_info_wrap.c"
-int main()
+int main(void)
{
struct fd_ops fops = {
.destroy = test_destroy,
#include "fd_info_wrap.c"
-int main()
+int main(void)
{
struct fd_ops fops = {
.destroy = test_destroy,
#include "fdi_logger_wrap.c"
-int main()
+int main(void)
{
struct fd_info fdi = {
.fd = -1,
assert(READS[N] == ops_logger.read(fdi));
}
-int main()
+int main(void)
{
struct fd_info fdi = {
.fd = -1,
#include "fdi_pipe_wrap.c"
-int main()
+int main(void)
{
struct fd_info info = {
.ops = &ops_pipe,
#include "fdi_pipe_wrap.c"
-int main()
+int main(void)
{
struct fd_info info = {
.ops = &ops_pipe,
return result;
}
-int check_colons()
+int check_colons(void)
{
struct log_filter *const f = log_filter_new();
assert(f);
return result;
}
-int main()
+int main(void)
{
int err;
int result = 0;
index++;
}
-static void validate_hash()
+static void validate_hash(void)
{
static const size_t BUCKET_SIZE = UINT32_MAX / NUM_BUCKETS + 1;
static const size_t BUCKET_AVG_COUNT = NELEMS(hash_values) / NUM_BUCKETS;
}
}
-static void test_permutations()
+static void test_permutations(void)
{
char hash[3];
add_hash(hash, sizeof hash);
}
-int main()
+int main(void)
{
srand(SEED);
#include "kmsg_assert.c"
-int main()
+int main(void)
{
assert_result("" , -EINVAL);
assert_result("invalid" , -EINVAL);
#include "kmsg_assert.c"
-int main()
+int main(void)
{
struct dlogutil_entry_with_msg lem;
#include "libdlog_android_wrapper.c"
-int main()
+int main(void)
{
fail_open = true;
__dlog_init_android(&CONF);
#include "libdlog_android_wrapper.c"
-int main()
+int main(void)
{
fail_open = false;
__dlog_init_android(&CONF);
#endif /* USE_ANDROID_MONOTONIC */
int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg, struct timespec *tp_mono) = NULL;
-void (*destroy_backend)() = NULL;
+void (*destroy_backend)(void) = NULL;
extern void __dlog_init_android(const struct log_config *conf);
static struct log_config CONF;
#include "libdlog_base_wrap.c"
-int main()
+int main(void)
{
fail_conf_read = true;
__configure();
#include "libdlog_base_wrap.c"
-int main()
+int main(void)
{
log_config_set(&CONFIG, "backend", "pipe");
log_config_set(&CONFIG, "limiter", "0");
void __log_limiter_update(const struct log_config *config) { }
void __log_limiter_destroy(void) { }
-void __dynamic_config_destroy() { }
+void __dynamic_config_destroy(void) { }
static bool destroyed;
-void destroy()
+void destroy(void)
{
destroyed = true;
}
bool __dynamic_config_create(struct log_config *config) { return use_dynamic_conf; }
static bool dynamic_config_called;
-void __dynamic_config_update() { dynamic_config_called = true; }
+void __dynamic_config_update(void) { dynamic_config_called = true; }
bool fail_snprintf;
int __wrap_snprintf(char *str, size_t size, const char *format, ...)
return ret;
}
-void tct_tests()
+void tct_tests(void)
{
/* These are a copy of TCT tests:
* repository: test/tct/native/api on tizen.org
#include <logconfig.h>
int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg) = NULL;
-void (*destroy_backend)() = NULL;
+void (*destroy_backend)(void) = NULL;
extern void __dlog_init_pipe(const struct log_config *conf);
return 0;
}
-int main()
+int main(void)
{
struct log_config conf = {NULL, NULL};
// lobotomize various mechanisms I don't want to deal with
void __log_limiter_update(const struct log_config *config) { }
void __log_limiter_destroy(void) { }
-void __dynamic_config_destroy() { }
+void __dynamic_config_destroy(void) { }
struct pass_log_result __log_limiter_pass_log(const char *tag, int prio) { return (struct pass_log_result) { .decision = DECISION_ALLOWED }; }
int __log_limiter_create(const struct log_config *config) { return 1; }
bool __dynamic_config_create(struct log_config *config) { return false; }
-void __dynamic_config_update() { }
+void __dynamic_config_update(void) { }
void __dlog_init_android(const struct log_config *conf) { }
-int main()
+int main(void)
{
#define VALID_FILTER(x) assert(dlog_set_minimum_priority(x) == DLOG_ERROR_NONE)
#define INVALID_FILTER(x) assert(dlog_set_minimum_priority(x) == DLOG_ERROR_INVALID_PARAMETER)
#include "limiter_wrap.c"
-int main()
+int main(void)
{
__log_limiter_destroy(); // check whether it explodes if called before init
#include "limiter_wrap.c"
-int main()
+int main(void)
{
struct log_config conf = {NULL, NULL};
assert(!__log_limiter_create(&conf));
#include <loglimiter.h>
#include <loglimiter-internal.h>
-static size_t get_rulecount()
+static size_t get_rulecount(void)
{
size_t cnt = 0;
struct rule *r = NULL;
// We should also set errno, but we won't
}
-int main()
+int main(void)
{
struct log_file lf;
logfile_init(&lf);
}
#define COMPARE_FILE(lines) _compare_file(lines, NELEMS(lines))
-void test_copy_file_with_exceptions()
+void test_copy_file_with_exceptions(void)
{
static const char *const lines_in[] = {
"FOO=BAR",
free(kv.values);
}
-void test_handle_clear()
+void test_handle_clear(void)
{
static const char *const lines_in[] = {
"limiter|x|y=BAR",
COMPARE_FILE(lines_out);
}
-void test_handle_set()
+void test_handle_set(void)
{
static const char *const lines_in[] = {
"QWER=QWER",
assert(EXIT_SUCCESS == handle_set(&pp, TMPFILE_PATH, NULL));
}
-void test_handle_plog()
+void test_handle_plog(void)
{
static const char *const lines_in[] = {
"QWER=QWER",
assert(!pp.tag || !strcmp(exp->pp.tag, pp.tag));
}
-void test_parse_options()
+void test_parse_options(void)
{
/* These are primarily covered by integration tests but there's some value
* in running this at build time as well to detect any breakage ASAP. */
#undef CHECK_OPTION_SET
}
-int main()
+int main(void)
{
test_copy_file_with_exceptions();
test_parse_options();
int bind_fd_create(const char *path, int type);
int listen_fd_create(const char *path, int permissions);
int systemd_sock_get(const char *path, int type);
-int dev_log_sock_get();
-int dev_log_sock_create();
+int dev_log_sock_get(void);
+int dev_log_sock_create(void);
int create_kmsg_writer(struct writer **writer, struct log_buffer *log_buffer);
int service_writer_kmsg(struct logger *server, struct writer *wr, struct epoll_event *event);
int create_syslog_writer(struct writer **writer, struct log_buffer *log_buffer);
return new_reader_fail ? NULL : (log_storage_reader *)0x600D;
}
-int main()
+int main(void)
{
assert(parse_permissions(NULL) == (S_IWUSR | S_IWGRP | S_IWOTH));
assert(parse_permissions("All the permissions") == 0);
#define CHECK_LOGPRINT_TESTCASES(MSG, TESTS) check_logprint_testcases_standard(MSG, sizeof MSG, TESTS, NELEMS(TESTS))
#define CHECK_LOGPRINT_TESTCASES_INVALID(MSG, TESTS) check_logprint_testcases_invalid(MSG, sizeof MSG, TESTS, NELEMS(TESTS))
-void check_log_print_log_line()
+void check_log_print_log_line(void)
{
static const struct logprint_test_case tests_basic[] = {
// formats using the SENT timestamp
CHECK_LOGPRINT_TESTCASES_INVALID("BASIC TAG\0Basic message.", tests_fixup_pipe);
}
-void check_log_print_log_line_buffer()
+void check_log_print_log_line_buffer(void)
{
struct dlogutil_entry_with_msg entry;
const char tag_msg[] = "tag\0msg";
const char *json_priority_name(log_priority prio);
struct timespec entry_get_ts(const dlogutil_entry_s *entry, bool sent, bool mono);
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()
+void check_json(void)
{
// TODO: Failure testing
check_json_escape_string_testcase("abc/def", "abc/def");
free(ent);
}
-void check_utf8_correctness()
+void check_utf8_correctness(void)
{
/* © is two bytes */
static const struct logprint_test_case test_2_bytes_0_shift[] = {
CHECK_LOGPRINT_TESTCASES("123💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯\0foo1", test_4_bytes_3_shift);
}
-void check_syscall_failure_handling()
+void check_syscall_failure_handling(void)
{
struct log_filter *const filter = log_filter_new();
assert(filter);
log_filter_free(filter);
}
-void check_invalid_input()
+void check_invalid_input(void)
{
const dlogutil_entry_s entry = { .len = 1 };
const char *data;
log_filter_free(filter);
}
-void check_log_format_from_string()
+void check_log_format_from_string(void)
{
static const struct {
char const *string;
assert(log_format_from_string(expected_formats[i].string) == expected_formats[i].format);
}
-void check_get_format_sorting()
+void check_get_format_sorting(void)
{
static const struct {
log_print_format format;
}
}
-void check_filter_pri_to_char()
+void check_filter_pri_to_char(void)
{
static const struct {
log_priority pri;
assert(filter_pri_to_char(expected_chars[i].pri) == expected_chars[i].c);
}
-void log_filter_default()
+void log_filter_default(void)
{
struct log_filter *const filter = log_filter_new();
bool ret = log_filter_need_apply_default(filter);
log_filter_free(filter);
}
-int main()
+int main(void)
{
check_log_format_from_string();
check_get_format_sorting();
return 0;
}
-int main()
+int main(void)
{
struct sort_vector sv;
sort_vector_init(&sv);
#include "logutil_wrap.c"
-int main()
+int main(void)
{
struct sort_vector sv;
sort_vector_init(&sv);
#include "logutil_wrap.c"
-int main()
+int main(void)
{
struct sort_vector sv;
sort_vector_init(&sv);
return tmp;
}
-int main()
+int main(void)
{
struct metrics *m = metrics_create();
assert(m);
#include <loglimiter-internal.h>
time_t time_ret = 0;
-void advance_clock()
+void advance_clock(void)
{
time_ret += 61;
}
}
pid_t pid_ret = 0;
-pid_t __wrap_getpid()
+pid_t __wrap_getpid(void)
{
return pid_ret;
}
-int main()
+int main(void)
{
struct log_config conf = {NULL, NULL};
log_config_set(&conf, "pidlimit|77", "7");
return 0;
}
-int main()
+int main(void)
{
int prio = 5;
char tag[] = "TEST_TAG";
return total_logs;
}
-void test_proportional_raw()
+void test_proportional_raw(void)
{
struct metrics_pid_aggr_info i1 [] =
{{ .count = 8, }
assert(i1[3].count == 80);
}
-void test_equal()
+void test_equal(void)
{
struct metrics_pid_aggr_info i1 [] =
{{ .count = 1, }
assert(i1[3].count == 50);
}
-void test_equal_dual()
+void test_equal_dual(void)
{
struct metrics_pid_aggr_info i1 [] =
{{ .count = 20, }
assert(i1[2].count == 90); // 120 >= 200/3, 90 == (200-20)/2
}
-void test_equal_multi()
+void test_equal_multi(void)
{
struct metrics_pid_aggr_info i1 [] =
{{ .count = 30, }
assert(i2[2].count == 95); // 120 >= 200/3, and 120 >= (200-20)/2, and 120 >= (200-20-85)/1
}
-void test_proportional_talmud()
+void test_proportional_talmud(void)
{
struct metrics_pid_aggr_info i1 [] =
{{ .count = 50, }
assert(i8[3].count == 317);
}
-int main()
+int main(void)
{
test_proportional_raw();
test_equal();
#include <queued_entry.h>
#include <queued_entry_timestamp.h>
-int main()
+int main(void)
{
struct log_config conf = {NULL, NULL};
const struct {
#include <queued_entry.h>
#include <queued_entry_timestamp.h>
-int main()
+int main(void)
{
assert(get_proper_clock(DLOGUTIL_SORT_SENT_MONO) == CLOCK_MONOTONIC);
assert(get_proper_clock(DLOGUTIL_SORT_SENT_REAL) == CLOCK_REALTIME);
#include <logcommon.h>
#include <queued_entry.h>
-void test_negative()
+void test_negative(void)
{
struct dlogutil_entry_with_msg dewm;
assert(dewm.header.nsec_sent_mono == -1);
}
-void test_positive()
+void test_positive(void)
{
struct dlogutil_entry_with_msg dewm;
assert(dewm.header.nsec_sent_real == 666666666);
}
-int main()
+int main(void)
{
test_negative();
test_positive();
return fail_calloc ? NULL : __real_calloc(nmemb, size);
}
-void fail_calloc_test()
+void fail_calloc_test(void)
{
struct sort_vector sv;
sort_vector_init(&sv);
fail_calloc = false;
}
-void empty_timestamp()
+void empty_timestamp(void)
{
struct sort_vector sv;
sort_vector_init(&sv);
assert(sort_vector_time_span(&sv, (struct timespec) { .tv_nsec = -1, }) == -1);
}
-void logs_order_empty()
+void logs_order_empty(void)
{
struct sort_vector sv;
sort_vector_init(&sv);
assert(third->pid == 789);
}
-void logs_order_mix()
+void logs_order_mix(void)
{
struct sort_vector sv;
sort_vector_init(&sv);
assert(fourth->pid == 789);
}
-int main()
+int main(void)
{
fail_calloc_test();
empty_timestamp();
return 0;
}
-void complex_test()
+void complex_test(void)
{
struct sort_vector sv;
sort_vector_init(&sv);
use_real_free = true;
}
-time_t get_time_t_max()
+time_t get_time_t_max(void)
{
return ~(1UL << (sizeof(time_t) * CHAR_BIT - 1));
}
-time_t get_time_t_min()
+time_t get_time_t_min(void)
{
return 1UL << (sizeof(time_t) * CHAR_BIT - 1);
}
assert((unsigned long) (sort_vector_time_span(&sv, (struct timespec) { .tv_nsec = -1 })) == time_span);
}
-void call_time_span_test()
+void call_time_span_test(void)
{
time_span_test(5, 7, 2000);
time_span_test(7, 5, (unsigned long) -2000);
#endif
}
-int main()
+int main(void)
{
complex_test();
call_time_span_test();
#include <stdio.h>
#include <assert.h>
-int main()
+int main(void)
{
char buffer[1024];
int len;
#include <stdio.h>
#include <assert.h>
-int main()
+int main(void)
{
char buffer[1024];
int len;
test_reader_get_new_entry(r, check_base+i+1);
}
-int main()
+int main(void)
{
/************* TEST 1 ***************/
/* Small storage, calling callbacks on removing log entries */
#include "test_ptrs_list_wrap.c"
-int main()
+int main(void)
{
list_head head = NULL;
assert(list_count(head) == 0);
#include "test_ptrs_list_wrap.c"
-int main()
+int main(void)
{
list_head head = NULL;
assert(list_count(head) == 0);
dlogutil_state_destroy(state);
}
-void clear_main()
+void clear_main(void)
{
dlogutil_config_s *c = dlogutil_config_create();
dlogutil_state_destroy(state);
}
-void negative_main()
+void negative_main(void)
{
dlogutil_config_s *config = dlogutil_config_create();
assert(config);