Replace SDL_assert() by assert()
SDL_assert() open a dialog on assertion failure. There is no reason not to use assert() directly.
This commit is contained in:
parent
b5ebb234dd
commit
510caff0cd
15 changed files with 49 additions and 43 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "control_msg.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <SDL2/SDL_assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "util/buffer_util.h"
|
||||
|
@ -27,7 +27,7 @@ write_string(const char *utf8, size_t max_len, unsigned char *buf) {
|
|||
|
||||
static uint16_t
|
||||
to_fixed_point_16(float f) {
|
||||
SDL_assert(f >= 0.0f && f <= 1.0f);
|
||||
assert(f >= 0.0f && f <= 1.0f);
|
||||
uint32_t u = f * 0x1p16f; // 2^16
|
||||
if (u >= 0xffff) {
|
||||
u = 0xffff;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "controller.h"
|
||||
|
||||
#include <SDL2/SDL_assert.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "util/lock.h"
|
||||
|
@ -85,7 +85,8 @@ run_controller(void *data) {
|
|||
}
|
||||
struct control_msg msg;
|
||||
bool non_empty = cbuf_take(&controller->queue, &msg);
|
||||
SDL_assert(non_empty);
|
||||
assert(non_empty);
|
||||
(void) non_empty;
|
||||
mutex_unlock(controller->mutex);
|
||||
|
||||
bool ok = process_msg(controller, &msg);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/time.h>
|
||||
#include <SDL2/SDL_assert.h>
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
#include <SDL2/SDL_thread.h>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "device_msg.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <SDL2/SDL_assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "util/buffer_util.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "file_handler.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <SDL2/SDL_assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "command.h"
|
||||
|
@ -120,7 +120,8 @@ run_file_handler(void *data) {
|
|||
}
|
||||
struct file_handler_request req;
|
||||
bool non_empty = cbuf_take(&file_handler->queue, &req);
|
||||
SDL_assert(non_empty);
|
||||
assert(non_empty);
|
||||
(void) non_empty;
|
||||
|
||||
process_t process;
|
||||
if (req.action == ACTION_INSTALL_APK) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "fps_counter.h"
|
||||
|
||||
#include <SDL2/SDL_assert.h>
|
||||
#include <assert.h>
|
||||
#include <SDL2/SDL_timer.h>
|
||||
|
||||
#include "config.h"
|
||||
|
@ -77,7 +77,7 @@ run_fps_counter(void *data) {
|
|||
uint32_t now = SDL_GetTicks();
|
||||
check_interval_expired(counter, now);
|
||||
|
||||
SDL_assert(counter->next_timestamp > now);
|
||||
assert(counter->next_timestamp > now);
|
||||
uint32_t remaining = counter->next_timestamp - now;
|
||||
|
||||
// ignore the reason (timeout or signaled), we just loop anyway
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "input_manager.h"
|
||||
|
||||
#include <SDL2/SDL_assert.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "event_converter.h"
|
||||
|
@ -217,7 +217,7 @@ input_manager_process_text_input(struct input_manager *im,
|
|||
if (!im->prefer_text) {
|
||||
char c = event->text[0];
|
||||
if (isalpha(c) || c == ' ') {
|
||||
SDL_assert(event->text[1] == '\0');
|
||||
assert(event->text[1] == '\0');
|
||||
// letters and space are handled as raw key event
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "receiver.h"
|
||||
|
||||
#include <SDL2/SDL_assert.h>
|
||||
#include <assert.h>
|
||||
#include <SDL2/SDL_clipboard.h>
|
||||
|
||||
#include "config.h"
|
||||
|
@ -49,7 +49,7 @@ process_msgs(const unsigned char *buf, size_t len) {
|
|||
device_msg_destroy(&msg);
|
||||
|
||||
head += r;
|
||||
SDL_assert(head <= len);
|
||||
assert(head <= len);
|
||||
if (head == len) {
|
||||
return head;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ run_receiver(void *data) {
|
|||
size_t head = 0;
|
||||
|
||||
for (;;) {
|
||||
SDL_assert(head < DEVICE_MSG_SERIALIZED_MAX_SIZE);
|
||||
assert(head < DEVICE_MSG_SERIALIZED_MAX_SIZE);
|
||||
ssize_t r = net_recv(receiver->control_socket, buf,
|
||||
DEVICE_MSG_SERIALIZED_MAX_SIZE - head);
|
||||
if (r <= 0) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "recorder.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <libavutil/time.h>
|
||||
#include <SDL2/SDL_assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "compat.h"
|
||||
|
@ -116,7 +116,7 @@ recorder_get_format_name(enum recorder_format format) {
|
|||
bool
|
||||
recorder_open(struct recorder *recorder, const AVCodec *input_codec) {
|
||||
const char *format_name = recorder_get_format_name(recorder->format);
|
||||
SDL_assert(format_name);
|
||||
assert(format_name);
|
||||
const AVOutputFormat *format = find_muxer(format_name);
|
||||
if (!format) {
|
||||
LOGE("Could not find muxer");
|
||||
|
@ -357,7 +357,7 @@ recorder_join(struct recorder *recorder) {
|
|||
bool
|
||||
recorder_push(struct recorder *recorder, const AVPacket *packet) {
|
||||
mutex_lock(recorder->mutex);
|
||||
SDL_assert(!recorder->stopped);
|
||||
assert(!recorder->stopped);
|
||||
|
||||
if (recorder->failed) {
|
||||
// reject any new packet (this will stop the stream)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "screen.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
|
@ -110,7 +111,7 @@ get_optimal_size(struct size current_size, struct size frame_size) {
|
|||
}
|
||||
|
||||
// w and h must fit into 16 bits
|
||||
SDL_assert_release(w < 0x10000 && h < 0x10000);
|
||||
assert(w < 0x10000 && h < 0x10000);
|
||||
return (struct size) {w, h};
|
||||
}
|
||||
|
||||
|
@ -392,8 +393,8 @@ screen_handle_window_event(struct screen *screen,
|
|||
break;
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
// The backup size must be non-nul.
|
||||
SDL_assert(screen->windowed_window_size_backup.width);
|
||||
SDL_assert(screen->windowed_window_size_backup.height);
|
||||
assert(screen->windowed_window_size_backup.width);
|
||||
assert(screen->windowed_window_size_backup.height);
|
||||
// Revert the last size, it was updated while screen was maximized.
|
||||
screen->windowed_window_size = screen->windowed_window_size_backup;
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "server.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <SDL2/SDL_assert.h>
|
||||
#include <SDL2/SDL_timer.h>
|
||||
|
||||
#include "config.h"
|
||||
|
@ -199,7 +199,7 @@ connect_to_server(uint16_t port, uint32_t attempts, uint32_t delay) {
|
|||
|
||||
static void
|
||||
close_socket(socket_t *socket) {
|
||||
SDL_assert(*socket != INVALID_SOCKET);
|
||||
assert(*socket != INVALID_SOCKET);
|
||||
net_shutdown(*socket, SHUT_RDWR);
|
||||
if (!net_close(*socket)) {
|
||||
LOGW("Could not close socket");
|
||||
|
@ -323,7 +323,7 @@ server_stop(struct server *server) {
|
|||
close_socket(&server->control_socket);
|
||||
}
|
||||
|
||||
SDL_assert(server->process != PROCESS_NONE);
|
||||
assert(server->process != PROCESS_NONE);
|
||||
|
||||
if (!cmd_terminate(server->process)) {
|
||||
LOGW("Could not terminate server");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "stream.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/time.h>
|
||||
#include <SDL2/SDL_assert.h>
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
#include <SDL2/SDL_thread.h>
|
||||
|
@ -44,8 +44,8 @@ stream_recv_packet(struct stream *stream, AVPacket *packet) {
|
|||
|
||||
uint64_t pts = buffer_read64be(header);
|
||||
uint32_t len = buffer_read32be(&header[8]);
|
||||
SDL_assert(pts == NO_PTS || (pts & 0x8000000000000000) == 0);
|
||||
SDL_assert(len);
|
||||
assert(pts == NO_PTS || (pts & 0x8000000000000000) == 0);
|
||||
assert(len);
|
||||
|
||||
if (av_new_packet(packet, len)) {
|
||||
LOGE("Could not allocate packet");
|
||||
|
@ -108,8 +108,9 @@ stream_parse(struct stream *stream, AVPacket *packet) {
|
|||
AV_NOPTS_VALUE, AV_NOPTS_VALUE, -1);
|
||||
|
||||
// PARSER_FLAG_COMPLETE_FRAMES is set
|
||||
SDL_assert(r == in_len);
|
||||
SDL_assert(out_len == in_len);
|
||||
assert(r == in_len);
|
||||
(void) r;
|
||||
assert(out_len == in_len);
|
||||
|
||||
if (stream->parser->key_frame == 1) {
|
||||
packet->flags |= AV_PKT_FLAG_KEY;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "tiny_xpm.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -51,24 +52,26 @@ read_xpm(char *xpm[]) {
|
|||
int chars = strtol(endptr + 1, &endptr, 10);
|
||||
|
||||
// sanity checks
|
||||
SDL_assert(0 <= width && width < 256);
|
||||
SDL_assert(0 <= height && height < 256);
|
||||
SDL_assert(0 <= colors && colors < 256);
|
||||
SDL_assert(chars == 1); // this implementation does not support more
|
||||
assert(0 <= width && width < 256);
|
||||
assert(0 <= height && height < 256);
|
||||
assert(0 <= colors && colors < 256);
|
||||
assert(chars == 1); // this implementation does not support more
|
||||
|
||||
(void) chars;
|
||||
|
||||
// init index
|
||||
struct index index[colors];
|
||||
for (int i = 0; i < colors; ++i) {
|
||||
const char *line = xpm[1+i];
|
||||
index[i].c = line[0];
|
||||
SDL_assert(line[1] == '\t');
|
||||
SDL_assert(line[2] == 'c');
|
||||
SDL_assert(line[3] == ' ');
|
||||
assert(line[1] == '\t');
|
||||
assert(line[2] == 'c');
|
||||
assert(line[3] == ' ');
|
||||
if (line[4] == '#') {
|
||||
index[i].color = 0xff000000 | strtol(&line[5], &endptr, 0x10);
|
||||
SDL_assert(*endptr == '\0');
|
||||
assert(*endptr == '\0');
|
||||
} else {
|
||||
SDL_assert(!strcmp("None", &line[4]));
|
||||
assert(!strcmp("None", &line[4]));
|
||||
index[i].color = 0;
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +88,8 @@ read_xpm(char *xpm[]) {
|
|||
char c = line[x];
|
||||
uint32_t color;
|
||||
bool color_found = find_color(index, colors, c, &color);
|
||||
SDL_assert(color_found);
|
||||
assert(color_found);
|
||||
(void) color_found;
|
||||
pixels[y * width + x] = color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#ifndef QUEUE_H
|
||||
#define QUEUE_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <SDL2/SDL_assert.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
|||
// type so that we can "return" it)
|
||||
#define queue_take(PQ, NEXTFIELD, PITEM) \
|
||||
(void) ({ \
|
||||
SDL_assert(!queue_is_empty(PQ)); \
|
||||
assert(!queue_is_empty(PQ)); \
|
||||
*(PITEM) = (PQ)->first; \
|
||||
(PQ)->first = (PQ)->first->NEXTFIELD; \
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "video_buffer.h"
|
||||
|
||||
#include <SDL2/SDL_assert.h>
|
||||
#include <assert.h>
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavformat/avformat.h>
|
||||
|
@ -91,7 +91,7 @@ video_buffer_offer_decoded_frame(struct video_buffer *vb,
|
|||
|
||||
const AVFrame *
|
||||
video_buffer_consume_rendered_frame(struct video_buffer *vb) {
|
||||
SDL_assert(!vb->rendering_frame_consumed);
|
||||
assert(!vb->rendering_frame_consumed);
|
||||
vb->rendering_frame_consumed = true;
|
||||
fps_counter_add_rendered_frame(vb->fps_counter);
|
||||
if (vb->render_expired_frames) {
|
||||
|
|
Loading…
Reference in a new issue