From 73be7d4f12c6f63cc5a662acd41bb1c14ec5ae2c Mon Sep 17 00:00:00 2001 From: iphydf Date: Sat, 28 Dec 2024 19:10:17 +0000 Subject: [PATCH] cleanup: Align internal logger with external on type of source line. We use `uint32_t` everywhere now. It's easier that way, and line numbers are never negative. --- .circleci/config.yml | 22 +++++++++++++++++++++ .cirrus.yml | 10 +++++----- auto_tests/auto_test_support.c | 4 ++-- auto_tests/auto_test_support.h | 2 +- other/DHT_bootstrap.c | 4 ++-- other/bootstrap_daemon/src/tox-bootstrapd.c | 4 ++-- toxcore/logger.c | 2 +- toxcore/logger.h | 4 ++-- toxcore/tox.c | 2 +- 9 files changed, 38 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 646b0d7620..264139ada2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,6 +6,8 @@ workflows: circleci: jobs: - bazel-asan + - bazel-dbg + - bazel-opt - clang-analyze - cpplint - static-analysis @@ -23,6 +25,26 @@ jobs: - run: .circleci/bazel-test //c-toxcore/... + bazel-dbg: + working_directory: /tmp/cirrus-ci-build + docker: + - image: toxchat/toktok-stack:latest-debug + + steps: + - checkout + - run: .circleci/bazel-test + //c-toxcore/... + + bazel-opt: + working_directory: /tmp/cirrus-ci-build + docker: + - image: toxchat/toktok-stack:latest-release + + steps: + - checkout + - run: .circleci/bazel-test + //c-toxcore/... + static-analysis: working_directory: ~/work docker: diff --git a/.cirrus.yml b/.cirrus.yml index 36d584eb77..ea412d5770 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,9 +1,9 @@ --- bazel-opt_task: - timeout_in: 5m + timeout_in: 10m container: image: toxchat/toktok-stack:latest-release - cpu: 2 + cpu: 8 memory: 2G configure_script: - git submodule update --init --recursive @@ -18,10 +18,10 @@ bazel-opt_task: -//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections. bazel-dbg_task: - timeout_in: 5m + timeout_in: 10m container: image: toxchat/toktok-stack:latest-debug - cpu: 2 + cpu: 8 memory: 2G configure_script: - git submodule update --init --recursive @@ -36,7 +36,7 @@ bazel-dbg_task: -//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections. bazel-msan_task: - timeout_in: 5m + timeout_in: 10m container: image: toxchat/toktok-stack:latest-msan cpu: 2 diff --git a/auto_tests/auto_test_support.c b/auto_tests/auto_test_support.c index 213e70570c..483e3130b7 100644 --- a/auto_tests/auto_test_support.c +++ b/auto_tests/auto_test_support.c @@ -444,9 +444,9 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin } } -void print_debug_logger(void *context, Logger_Level level, const char *file, int line, const char *func, const char *message, void *userdata) +void print_debug_logger(void *context, Logger_Level level, const char *file, uint32_t line, const char *func, const char *message, void *userdata) { - print_debug_log(nullptr, (Tox_Log_Level) level, file, (uint32_t) line, func, message, userdata); + print_debug_log(nullptr, (Tox_Log_Level) level, file, line, func, message, userdata); } Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data, bool lan_discovery) diff --git a/auto_tests/auto_test_support.h b/auto_tests/auto_test_support.h index b9132e16bc..cd883e28c9 100644 --- a/auto_tests/auto_test_support.h +++ b/auto_tests/auto_test_support.h @@ -60,7 +60,7 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin const char *message, void *user_data); // Use this function when setting the log callback on a Logger object -void print_debug_logger(void *context, Logger_Level level, const char *file, int line, +void print_debug_logger(void *context, Logger_Level level, const char *file, uint32_t line, const char *func, const char *message, void *userdata); Tox *tox_new_log(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data); diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 56821bf785..cd7ea4df8b 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c @@ -117,10 +117,10 @@ static const char *strlevel(Logger_Level level) } } -static void print_log(void *context, Logger_Level level, const char *file, int line, +static void print_log(void *context, Logger_Level level, const char *file, uint32_t line, const char *func, const char *message, void *userdata) { - fprintf(stderr, "[%s] %s:%d(%s) %s\n", strlevel(level), file, line, func, message); + fprintf(stderr, "[%s] %s:%u(%s) %s\n", strlevel(level), file, line, func, message); } int main(int argc, char *argv[]) diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c index 5745b74ffc..ad4dbec1ae 100644 --- a/other/bootstrap_daemon/src/tox-bootstrapd.c +++ b/other/bootstrap_daemon/src/tox-bootstrapd.c @@ -200,10 +200,10 @@ static LOG_LEVEL logger_level_to_log_level(Logger_Level level) } } -static void toxcore_logger_callback(void *context, Logger_Level level, const char *file, int line, +static void toxcore_logger_callback(void *context, Logger_Level level, const char *file, uint32_t line, const char *func, const char *message, void *userdata) { - log_write(logger_level_to_log_level(level), "%s:%d(%s) %s\n", file, line, func, message); + log_write(logger_level_to_log_level(level), "%s:%u(%s) %s\n", file, line, func, message); } static volatile sig_atomic_t caught_signal = 0; diff --git a/toxcore/logger.c b/toxcore/logger.c index 5fc01ee1c8..376058c49c 100644 --- a/toxcore/logger.c +++ b/toxcore/logger.c @@ -57,7 +57,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void * log->userdata = userdata; } -void logger_write(const Logger *log, Logger_Level level, const char *file, int line, const char *func, +void logger_write(const Logger *log, Logger_Level level, const char *file, uint32_t line, const char *func, const char *format, ...) { if (log == nullptr) { diff --git a/toxcore/logger.h b/toxcore/logger.h index ef012d7cc8..893c21fd10 100644 --- a/toxcore/logger.h +++ b/toxcore/logger.h @@ -33,7 +33,7 @@ typedef enum Logger_Level { typedef struct Logger Logger; -typedef void logger_cb(void *context, Logger_Level level, const char *file, int line, +typedef void logger_cb(void *context, Logger_Level level, const char *file, uint32_t line, const char *func, const char *message, void *userdata); /** @@ -66,7 +66,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void * */ non_null(3, 5, 6) nullable(1) GNU_PRINTF(6, 7) void logger_write( - const Logger *log, Logger_Level level, const char *file, int line, const char *func, + const Logger *log, Logger_Level level, const char *file, uint32_t line, const char *func, const char *format, ...); /* @brief Terminate the program with a signal. */ diff --git a/toxcore/tox.c b/toxcore/tox.c index 52388a4ed0..ff2fa47358 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -79,7 +79,7 @@ struct Tox_Userdata { static logger_cb tox_log_handler; non_null(1, 3, 5, 6) nullable(7) -static void tox_log_handler(void *context, Logger_Level level, const char *file, int line, const char *func, +static void tox_log_handler(void *context, Logger_Level level, const char *file, uint32_t line, const char *func, const char *message, void *userdata) { Tox *tox = (Tox *)context;