diff options
author | iphydf <iphydf@users.noreply.github.com> | 2017-01-04 22:37:53 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2017-01-11 19:43:08 +0000 |
commit | 8b4eae4038db87f2df1c40856c99c3ffca8887fe (patch) | |
tree | a3d712f2adf081f56a4295a34f5a8c75523e5a18 /toxcore/util.c | |
parent | 583d71680ec12349cd1bedea72ae136d55667ecb (diff) |
Remove `TOX_DEBUG` and have asserts always enabled.
These are cheap asserts. I've also replaced the fprintf's with
`LOGGER_ERROR` calls.
Diffstat (limited to 'toxcore/util.c')
-rw-r--r-- | toxcore/util.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/toxcore/util.c b/toxcore/util.c index 1d2a85dc..b390b169 100644 --- a/toxcore/util.c +++ b/toxcore/util.c | |||
@@ -116,13 +116,11 @@ void lendian_to_host32(uint32_t *dest, const uint8_t *lendian) | |||
116 | } | 116 | } |
117 | 117 | ||
118 | /* state load/save */ | 118 | /* state load/save */ |
119 | int load_state(load_state_callback_func load_state_callback, void *outer, | 119 | int load_state(load_state_callback_func load_state_callback, Logger *log, void *outer, |
120 | const uint8_t *data, uint32_t length, uint16_t cookie_inner) | 120 | const uint8_t *data, uint32_t length, uint16_t cookie_inner) |
121 | { | 121 | { |
122 | if (!load_state_callback || !data) { | 122 | if (!load_state_callback || !data) { |
123 | #ifdef TOX_DEBUG | 123 | LOGGER_ERROR(log, "load_state() called with invalid args.\n"); |
124 | fprintf(stderr, "load_state() called with invalid args.\n"); | ||
125 | #endif | ||
126 | return -1; | 124 | return -1; |
127 | } | 125 | } |
128 | 126 | ||
@@ -139,17 +137,13 @@ int load_state(load_state_callback_func load_state_callback, void *outer, | |||
139 | 137 | ||
140 | if (length < length_sub) { | 138 | if (length < length_sub) { |
141 | /* file truncated */ | 139 | /* file truncated */ |
142 | #ifdef TOX_DEBUG | 140 | LOGGER_ERROR(log, "state file too short: %u < %u\n", length, length_sub); |
143 | fprintf(stderr, "state file too short: %u < %u\n", length, length_sub); | ||
144 | #endif | ||
145 | return -1; | 141 | return -1; |
146 | } | 142 | } |
147 | 143 | ||
148 | if (lendian_to_host16((cookie_type >> 16)) != cookie_inner) { | 144 | if (lendian_to_host16((cookie_type >> 16)) != cookie_inner) { |
149 | /* something is not matching up in a bad way, give up */ | 145 | /* something is not matching up in a bad way, give up */ |
150 | #ifdef DEBUG | 146 | LOGGER_ERROR(log, "state file garbled: %04x != %04x\n", (cookie_type >> 16), cookie_inner); |
151 | fprintf(stderr, "state file garbled: %04x != %04x\n", (cookie_type >> 16), cookie_inner); | ||
152 | #endif | ||
153 | return -1; | 147 | return -1; |
154 | } | 148 | } |
155 | 149 | ||