Skip to content

Commit 5bd8a85

Browse files
committed
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.
1 parent e9bf524 commit 5bd8a85

File tree

9 files changed

+42
-20
lines changed

9 files changed

+42
-20
lines changed

.circleci/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ workflows:
66
circleci:
77
jobs:
88
- bazel-asan
9+
- bazel-dbg
10+
- bazel-opt
911
- clang-analyze
1012
- cpplint
1113
- static-analysis
@@ -23,6 +25,26 @@ jobs:
2325
- run: .circleci/bazel-test
2426
//c-toxcore/...
2527

28+
bazel-dbg:
29+
working_directory: /tmp/cirrus-ci-build
30+
docker:
31+
- image: toxchat/toktok-stack:latest-debug
32+
33+
steps:
34+
- checkout
35+
- run: .circleci/bazel-test
36+
//c-toxcore/...
37+
38+
bazel-opt:
39+
working_directory: /tmp/cirrus-ci-build
40+
docker:
41+
- image: toxchat/toktok-stack:latest-release
42+
43+
steps:
44+
- checkout
45+
- run: .circleci/bazel-test
46+
//c-toxcore/...
47+
2648
static-analysis:
2749
working_directory: ~/work
2850
docker:

.cirrus.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
bazel-opt_task:
3-
timeout_in: 5m
3+
timeout_in: 10m
44
container:
55
image: toxchat/toktok-stack:latest-release
6-
cpu: 2
6+
cpu: 8
77
memory: 2G
88
configure_script:
99
- git submodule update --init --recursive
1010
- /src/workspace/tools/inject-repo c-toxcore
1111
test_all_script:
12-
- cd /src/workspace && bazel
12+
- cd /src/workspace && tools/retry 5 bazel
1313
test -k
1414
--build_tag_filters=-haskell
1515
--test_tag_filters=-haskell
@@ -18,16 +18,16 @@ bazel-opt_task:
1818
-//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections.
1919

2020
bazel-dbg_task:
21-
timeout_in: 5m
21+
timeout_in: 10m
2222
container:
2323
image: toxchat/toktok-stack:latest-debug
24-
cpu: 2
24+
cpu: 8
2525
memory: 2G
2626
configure_script:
2727
- git submodule update --init --recursive
2828
- /src/workspace/tools/inject-repo c-toxcore
2929
test_all_script:
30-
- cd /src/workspace && bazel
30+
- cd /src/workspace && tools/retry 5 bazel
3131
test -k
3232
--build_tag_filters=-haskell
3333
--test_tag_filters=-haskell
@@ -36,7 +36,7 @@ bazel-dbg_task:
3636
-//c-toxcore/auto_tests:tcp_relay_test # Cirrus doesn't allow external network connections.
3737

3838
bazel-msan_task:
39-
timeout_in: 5m
39+
timeout_in: 10m
4040
container:
4141
image: toxchat/toktok-stack:latest-msan
4242
cpu: 2
@@ -45,7 +45,7 @@ bazel-msan_task:
4545
- git submodule update --init --recursive
4646
- /src/workspace/tools/inject-repo c-toxcore
4747
test_all_script:
48-
- cd /src/workspace && bazel
48+
- cd /src/workspace && tools/retry 5 bazel
4949
test -k
5050
--
5151
//c-toxcore/auto_tests:lossless_packet_test
@@ -97,4 +97,4 @@ freebsd_task:
9797
-DAUTOTEST=ON \
9898
-GNinja
9999
cmake --build . --target install
100-
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
100+
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3 || ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3

auto_tests/auto_test_support.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
444444
}
445445
}
446446

447-
void print_debug_logger(void *context, Logger_Level level, const char *file, int line, const char *func, const char *message, void *userdata)
447+
void print_debug_logger(void *context, Logger_Level level, const char *file, uint32_t line, const char *func, const char *message, void *userdata)
448448
{
449-
print_debug_log(nullptr, (Tox_Log_Level) level, file, (uint32_t) line, func, message, userdata);
449+
print_debug_log(nullptr, (Tox_Log_Level) level, file, line, func, message, userdata);
450450
}
451451

452452
Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data, bool lan_discovery)

auto_tests/auto_test_support.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
6060
const char *message, void *user_data);
6161

6262
// Use this function when setting the log callback on a Logger object
63-
void print_debug_logger(void *context, Logger_Level level, const char *file, int line,
63+
void print_debug_logger(void *context, Logger_Level level, const char *file, uint32_t line,
6464
const char *func, const char *message, void *userdata);
6565

6666
Tox *tox_new_log(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data);

other/DHT_bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ static const char *strlevel(Logger_Level level)
117117
}
118118
}
119119

120-
static void print_log(void *context, Logger_Level level, const char *file, int line,
120+
static void print_log(void *context, Logger_Level level, const char *file, uint32_t line,
121121
const char *func, const char *message, void *userdata)
122122
{
123-
fprintf(stderr, "[%s] %s:%d(%s) %s\n", strlevel(level), file, line, func, message);
123+
fprintf(stderr, "[%s] %s:%u(%s) %s\n", strlevel(level), file, line, func, message);
124124
}
125125

126126
int main(int argc, char *argv[])

other/bootstrap_daemon/src/tox-bootstrapd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ static LOG_LEVEL logger_level_to_log_level(Logger_Level level)
200200
}
201201
}
202202

203-
static void toxcore_logger_callback(void *context, Logger_Level level, const char *file, int line,
203+
static void toxcore_logger_callback(void *context, Logger_Level level, const char *file, uint32_t line,
204204
const char *func, const char *message, void *userdata)
205205
{
206-
log_write(logger_level_to_log_level(level), "%s:%d(%s) %s\n", file, line, func, message);
206+
log_write(logger_level_to_log_level(level), "%s:%u(%s) %s\n", file, line, func, message);
207207
}
208208

209209
static volatile sig_atomic_t caught_signal = 0;

toxcore/logger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void *
5757
log->userdata = userdata;
5858
}
5959

60-
void logger_write(const Logger *log, Logger_Level level, const char *file, int line, const char *func,
60+
void logger_write(const Logger *log, Logger_Level level, const char *file, uint32_t line, const char *func,
6161
const char *format, ...)
6262
{
6363
if (log == nullptr) {

toxcore/logger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef enum Logger_Level {
3333

3434
typedef struct Logger Logger;
3535

36-
typedef void logger_cb(void *context, Logger_Level level, const char *file, int line,
36+
typedef void logger_cb(void *context, Logger_Level level, const char *file, uint32_t line,
3737
const char *func, const char *message, void *userdata);
3838

3939
/**
@@ -66,7 +66,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void *
6666
*/
6767
non_null(3, 5, 6) nullable(1) GNU_PRINTF(6, 7)
6868
void logger_write(
69-
const Logger *log, Logger_Level level, const char *file, int line, const char *func,
69+
const Logger *log, Logger_Level level, const char *file, uint32_t line, const char *func,
7070
const char *format, ...);
7171

7272
/* @brief Terminate the program with a signal. */

toxcore/tox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct Tox_Userdata {
7979

8080
static logger_cb tox_log_handler;
8181
non_null(1, 3, 5, 6) nullable(7)
82-
static void tox_log_handler(void *context, Logger_Level level, const char *file, int line, const char *func,
82+
static void tox_log_handler(void *context, Logger_Level level, const char *file, uint32_t line, const char *func,
8383
const char *message, void *userdata)
8484
{
8585
Tox *tox = (Tox *)context;

0 commit comments

Comments
 (0)