various: use mp_assert macro

This commit is contained in:
Kacper Michajłow
2025-03-01 10:36:15 +01:00
parent c0dbdcf7ad
commit 1c49cfdb97
149 changed files with 817 additions and 813 deletions

View File

@@ -244,7 +244,7 @@ static void prepare_prefix(struct mp_log_root *root, bstr *out, int lev, int ter
bstr up_clear = bstr0("\033[A\033[K");
for (int i = 1; i < root->status_lines; ++i)
bstr_xappend(root, out, up_clear);
assert(root->status_lines > 0 && root->blank_lines >= root->status_lines);
mp_assert(root->status_lines > 0 && root->blank_lines >= root->status_lines);
line_skip = root->blank_lines - root->status_lines;
}
@@ -432,7 +432,7 @@ static void append_terminal_line(struct mp_log *log, int lev,
static struct mp_log_buffer_entry *log_buffer_read(struct mp_log_buffer *buffer)
{
assert(buffer->num_entries);
mp_assert(buffer->num_entries);
struct mp_log_buffer_entry *res = buffer->entries[buffer->entry0];
buffer->entry0 = (buffer->entry0 + 1) % buffer->capacity;
buffer->num_entries -= 1;
@@ -521,7 +521,7 @@ static void write_term_msg(struct mp_log *log, int lev, bstr text, bstr *out)
while (str.len) {
bstr line = bstr_getline(str, &str);
if (line.start[line.len - 1] != '\n') {
assert(str.len == 0);
mp_assert(str.len == 0);
str = line;
break;
}
@@ -636,7 +636,7 @@ static void destroy_log(void *ptr)
struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent,
const char *name)
{
assert(parent);
mp_assert(parent);
struct mp_log *log = talloc_zero(talloc_ctx, struct mp_log);
if (!parent->root)
return log; // same as null_log
@@ -670,7 +670,7 @@ struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent,
void mp_msg_init(struct mpv_global *global)
{
assert(!global->log);
mp_assert(!global->log);
struct mp_log_root *root = talloc_zero(NULL, struct mp_log_root);
*root = (struct mp_log_root){
@@ -897,7 +897,7 @@ void mp_msg_uninit(struct mpv_global *global)
terminate_log_file_thread(root);
mp_msg_log_buffer_destroy(root->early_buffer);
mp_msg_log_buffer_destroy(root->early_filebuffer);
assert(root->num_buffers == 0);
mp_assert(root->num_buffers == 0);
if (root->stats_file)
fclose(root->stats_file);
talloc_free(root->stats_path);
@@ -941,7 +941,7 @@ static void mp_msg_set_early_logging_raw(struct mpv_global *global, bool enable,
struct mp_log_buffer *buf =
mp_msg_log_buffer_new(global, size, level, NULL, NULL);
mp_mutex_lock(&root->lock);
assert(!*root_logbuf); // no concurrent calls to this function
mp_assert(!*root_logbuf); // no concurrent calls to this function
*root_logbuf = buf;
} else {
struct mp_log_buffer *buf = *root_logbuf;
@@ -992,7 +992,7 @@ struct mp_log_buffer *mp_msg_log_buffer_new(struct mpv_global *global,
}
}
assert(size > 0);
mp_assert(size > 0);
struct mp_log_buffer *buffer = talloc_ptrtype(NULL, buffer);
*buffer = (struct mp_log_buffer) {
@@ -1018,7 +1018,7 @@ void mp_msg_log_buffer_resize(struct mp_log_buffer *buffer, int size)
{
mp_mutex_lock(&buffer->lock);
assert(size > 0);
mp_assert(size > 0);
if (buffer->capacity < size &&
buffer->entry0 + buffer->num_entries <= buffer->capacity) {
// shortcut if buffer doesn't wrap