From 9ffd4f03f314cc6e0254449593def95c9bc203d6 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 28 Mar 2019 00:56:20 +0100 Subject: [PATCH] On errors, abort() instead of exit(1); exit() in a multithreaded program just gives more problems, and we want a core file. --- futatabi/db.cpp | 76 ++++++++++++++++----------------- futatabi/export.cpp | 2 +- futatabi/flags.cpp | 8 ++-- futatabi/flow.cpp | 4 +- futatabi/flow_main.cpp | 16 +++---- futatabi/frame_on_disk.cpp | 4 +- futatabi/jpeg_frame_view.cpp | 2 +- futatabi/main.cpp | 32 +++++++------- futatabi/mainwindow.cpp | 2 +- futatabi/player.cpp | 2 +- futatabi/vaapi_jpeg_decoder.cpp | 2 +- futatabi/video_stream.cpp | 2 +- futatabi/vis.cpp | 2 +- nageru/alsa_output.cpp | 4 +- nageru/alsa_pool.cpp | 2 +- nageru/analyzer.cpp | 6 +-- nageru/audio_encoder.cpp | 18 ++++---- nageru/audio_mixer.cpp | 2 +- nageru/chroma_subsampler.cpp | 2 +- nageru/decklink_capture.cpp | 40 ++++++++--------- nageru/decklink_output.cpp | 30 ++++++------- nageru/decklink_util.cpp | 8 ++-- nageru/ffmpeg_capture.cpp | 6 +-- nageru/ffmpeg_util.cpp | 2 +- nageru/flags.cpp | 46 ++++++++++---------- nageru/image_input.cpp | 2 +- nageru/kaeru.cpp | 2 +- nageru/main.cpp | 2 +- nageru/mainwindow.cpp | 2 +- nageru/mixer.cpp | 10 ++--- nageru/mjpeg_encoder.cpp | 6 +-- nageru/quicksync_encoder.cpp | 14 +++--- nageru/theme.cpp | 38 ++++++++--------- nageru/v210_converter.cpp | 2 +- nageru/x264_dynamic.cpp | 4 +- nageru/x264_encoder.cpp | 2 +- shared/bin2h.cpp | 4 +- shared/context.cpp | 4 +- shared/midi_device.cpp | 2 +- shared/mux.cpp | 12 +++--- shared/read_file.cpp | 12 +++--- 41 files changed, 219 insertions(+), 219 deletions(-) diff --git a/futatabi/db.cpp b/futatabi/db.cpp index 636b63e..6764f84 100644 --- a/futatabi/db.cpp +++ b/futatabi/db.cpp @@ -12,7 +12,7 @@ DB::DB(const string &filename) int ret = sqlite3_open(filename.c_str(), &db); if (ret != SQLITE_OK) { fprintf(stderr, "%s: %s\n", filename.c_str(), sqlite3_errmsg(db)); - exit(1); + abort(); } // Set an effectively infinite timeout for waiting for write locks; @@ -20,7 +20,7 @@ DB::DB(const string &filename) ret = sqlite3_busy_timeout(db, 3600000); if (ret != SQLITE_OK) { fprintf(stderr, "sqlite3_busy_timeout: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } sqlite3_exec(db, R"( @@ -69,7 +69,7 @@ StateProto DB::get_state() int ret = sqlite3_prepare_v2(db, "SELECT state FROM state", -1, &stmt, 0); if (ret != SQLITE_OK) { fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_step(stmt); @@ -77,17 +77,17 @@ StateProto DB::get_state() bool ok = state.ParseFromArray(sqlite3_column_blob(stmt, 0), sqlite3_column_bytes(stmt, 0)); if (!ok) { fprintf(stderr, "State in database is corrupted!\n"); - exit(1); + abort(); } } else if (ret != SQLITE_DONE) { fprintf(stderr, "SELECT step: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_finalize(stmt); if (ret != SQLITE_OK) { fprintf(stderr, "SELECT finalize: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } return state; @@ -101,14 +101,14 @@ void DB::store_state(const StateProto &state) int ret = sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr); if (ret != SQLITE_OK) { fprintf(stderr, "BEGIN: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } sqlite3_stmt *stmt; ret = sqlite3_prepare_v2(db, "REPLACE INTO state VALUES (?)", -1, &stmt, 0); if (ret != SQLITE_OK) { fprintf(stderr, "REPLACE prepare: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } sqlite3_bind_blob(stmt, 1, serialized.data(), serialized.size(), SQLITE_STATIC); @@ -116,19 +116,19 @@ void DB::store_state(const StateProto &state) ret = sqlite3_step(stmt); if (ret == SQLITE_ROW) { fprintf(stderr, "REPLACE step: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_finalize(stmt); if (ret != SQLITE_OK) { fprintf(stderr, "REPLACE finalize: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr); if (ret != SQLITE_OK) { fprintf(stderr, "COMMIT: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } } @@ -140,7 +140,7 @@ SettingsProto DB::get_settings() int ret = sqlite3_prepare_v2(db, "SELECT settings FROM settings", -1, &stmt, 0); if (ret != SQLITE_OK) { fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_step(stmt); @@ -148,17 +148,17 @@ SettingsProto DB::get_settings() bool ok = settings.ParseFromArray(sqlite3_column_blob(stmt, 0), sqlite3_column_bytes(stmt, 0)); if (!ok) { fprintf(stderr, "State in database is corrupted!\n"); - exit(1); + abort(); } } else if (ret != SQLITE_DONE) { fprintf(stderr, "SELECT step: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_finalize(stmt); if (ret != SQLITE_OK) { fprintf(stderr, "SELECT finalize: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } return settings; @@ -172,14 +172,14 @@ void DB::store_settings(const SettingsProto &settings) int ret = sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr); if (ret != SQLITE_OK) { fprintf(stderr, "BEGIN: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } sqlite3_stmt *stmt; ret = sqlite3_prepare_v2(db, "REPLACE INTO settings VALUES (?)", -1, &stmt, 0); if (ret != SQLITE_OK) { fprintf(stderr, "REPLACE prepare: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } sqlite3_bind_blob(stmt, 1, serialized.data(), serialized.size(), SQLITE_STATIC); @@ -187,19 +187,19 @@ void DB::store_settings(const SettingsProto &settings) ret = sqlite3_step(stmt); if (ret == SQLITE_ROW) { fprintf(stderr, "REPLACE step: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_finalize(stmt); if (ret != SQLITE_OK) { fprintf(stderr, "REPLACE finalize: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr); if (ret != SQLITE_OK) { fprintf(stderr, "COMMIT: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } } @@ -211,7 +211,7 @@ vector DB::load_frame_file(const string &filename, int ret = sqlite3_prepare_v2(db, "SELECT frames FROM filev2 WHERE filename=? AND size=?", -1, &stmt, 0); if (ret != SQLITE_OK) { fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } sqlite3_bind_text(stmt, 1, filename.data(), filename.size(), SQLITE_STATIC); @@ -222,17 +222,17 @@ vector DB::load_frame_file(const string &filename, bool ok = file_contents.ParseFromArray(sqlite3_column_blob(stmt, 0), sqlite3_column_bytes(stmt, 0)); if (!ok) { fprintf(stderr, "Frame list in database is corrupted!\n"); - exit(1); + abort(); } } else if (ret != SQLITE_DONE) { fprintf(stderr, "SELECT step: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_finalize(stmt); if (ret != SQLITE_OK) { fprintf(stderr, "SELECT finalize: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } vector frames; @@ -256,7 +256,7 @@ void DB::store_frame_file(const string &filename, size_t size, const vector &used_filenames) int ret = sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr); if (ret != SQLITE_OK) { fprintf(stderr, "BEGIN: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_exec(db, R"( @@ -332,7 +332,7 @@ void DB::clean_unused_frame_files(const vector &used_filenames) if (ret != SQLITE_OK) { fprintf(stderr, "CREATE TEMPORARY TABLE: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } // Insert the new rows. @@ -340,7 +340,7 @@ void DB::clean_unused_frame_files(const vector &used_filenames) ret = sqlite3_prepare_v2(db, "INSERT INTO used_filenames (filename) VALUES (?)", -1, &stmt, 0); if (ret != SQLITE_OK) { fprintf(stderr, "INSERT prepare: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } for (const string &filename : used_filenames) { @@ -349,20 +349,20 @@ void DB::clean_unused_frame_files(const vector &used_filenames) ret = sqlite3_step(stmt); if (ret == SQLITE_ROW) { fprintf(stderr, "INSERT step: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_reset(stmt); if (ret == SQLITE_ROW) { fprintf(stderr, "INSERT reset: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } } ret = sqlite3_finalize(stmt); if (ret != SQLITE_OK) { fprintf(stderr, "INSERT finalize: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_exec(db, R"( @@ -372,7 +372,7 @@ void DB::clean_unused_frame_files(const vector &used_filenames) if (ret != SQLITE_OK) { fprintf(stderr, "DELETE: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } ret = sqlite3_exec(db, R"( @@ -382,13 +382,13 @@ void DB::clean_unused_frame_files(const vector &used_filenames) if (ret != SQLITE_OK) { fprintf(stderr, "DROP TABLE: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } // Commit. ret = sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr); if (ret != SQLITE_OK) { fprintf(stderr, "COMMIT: %s\n", sqlite3_errmsg(db)); - exit(1); + abort(); } } diff --git a/futatabi/export.cpp b/futatabi/export.cpp index a865ac6..5b8da13 100644 --- a/futatabi/export.cpp +++ b/futatabi/export.cpp @@ -104,7 +104,7 @@ void export_multitrack_clip(const string &filename, const Clip &clip) AVStream *avstream_video = avformat_new_stream(avctx, nullptr); if (avstream_video == nullptr) { fprintf(stderr, "avformat_new_stream() failed\n"); - exit(1); + abort(); } avstream_video->time_base = AVRational{ 1, TIMEBASE }; avstream_video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; diff --git a/futatabi/flags.cpp b/futatabi/flags.cpp index fa1fe6e..eea7c07 100644 --- a/futatabi/flags.cpp +++ b/futatabi/flags.cpp @@ -85,7 +85,7 @@ void parse_flags(int argc, char *const argv[]) global_flags.output_framerate = num; } else { fprintf(stderr, "Invalid frame rate given (must be on the form N or N/M)\n"); - exit(1); + abort(); } break; } @@ -123,19 +123,19 @@ void parse_flags(int argc, char *const argv[]) fprintf(stderr, "Unknown option '%s'\n", argv[option_index]); fprintf(stderr, "\n"); usage(); - exit(1); + abort(); } } if (global_flags.interpolation_quality < 0 || global_flags.interpolation_quality > 4) { fprintf(stderr, "Interpolation quality must be 0, 1, 2, 3 or 4.\n"); usage(); - exit(1); + abort(); } if (global_flags.cue_in_point_padding_seconds < 0.0 || global_flags.cue_out_point_padding_seconds < 0.0) { fprintf(stderr, "Cue point padding cannot be negative.\n"); usage(); - exit(1); + abort(); } } diff --git a/futatabi/flow.cpp b/futatabi/flow.cpp index 90317da..8ae7bfc 100644 --- a/futatabi/flow.cpp +++ b/futatabi/flow.cpp @@ -83,7 +83,7 @@ GLuint compile_shader(const string &shader_src, GLenum type) } fprintf(stderr, "Failed to compile shader:\n%s\n", src_with_lines.c_str()); - exit(1); + abort(); } return obj; @@ -101,7 +101,7 @@ GLuint link_program(GLuint vs_obj, GLuint fs_obj) GLchar error_log[1024] = { 0 }; glGetProgramInfoLog(program, 1024, nullptr, error_log); fprintf(stderr, "Error linking program: %s\n", error_log); - exit(1); + abort(); } return program; } diff --git a/futatabi/flow_main.cpp b/futatabi/flow_main.cpp index ef481a0..ef3b5bf 100644 --- a/futatabi/flow_main.cpp +++ b/futatabi/flow_main.cpp @@ -54,7 +54,7 @@ GLuint load_texture(const char *filename, unsigned *width_ret, unsigned *height_ SDL_Surface *surf = IMG_Load(filename); if (surf == nullptr) { fprintf(stderr, "IMG_Load(%s): %s\n", filename, IMG_GetError()); - exit(1); + abort(); } // For whatever reason, SDL doesn't support converting to YUV surfaces @@ -62,7 +62,7 @@ GLuint load_texture(const char *filename, unsigned *width_ret, unsigned *height_ SDL_Surface *rgb_surf = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_RGBA32, /*flags=*/0); if (rgb_surf == nullptr) { fprintf(stderr, "SDL_ConvertSurfaceFormat(%s): %s\n", filename, SDL_GetError()); - exit(1); + abort(); } SDL_FreeSurface(surf); @@ -234,7 +234,7 @@ void compute_flow_only(int argc, char **argv, int optind) if (width1 != width2 || height1 != height2) { fprintf(stderr, "Image dimensions don't match (%dx%d versus %dx%d)\n", width1, height1, width2, height2); - exit(1); + abort(); } // Move them into an array texture, since that's how the rest of the code @@ -298,7 +298,7 @@ void compute_flow_only(int argc, char **argv, int optind) if (width != width1 || height != height1) { fprintf(stderr, "%s: Image dimensions don't match (%dx%d versus %dx%d)\n", filename0, width, height, width1, height1); - exit(1); + abort(); } glCopyImageSubData(tex0, GL_TEXTURE_2D, 0, 0, 0, 0, image_tex, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width1, height1, 1); glDeleteTextures(1, &tex0); @@ -307,7 +307,7 @@ void compute_flow_only(int argc, char **argv, int optind) if (width != width1 || height != height1) { fprintf(stderr, "%s: Image dimensions don't match (%dx%d versus %dx%d)\n", filename1, width, height, width1, height1); - exit(1); + abort(); } glCopyImageSubData(tex1, GL_TEXTURE_2D, 0, 0, 0, 0, image_tex, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 1, width1, height1, 1); glDeleteTextures(1, &tex1); @@ -347,7 +347,7 @@ void interpolate_image(int argc, char **argv, int optind) if (width1 != width2 || height1 != height2) { fprintf(stderr, "Image dimensions don't match (%dx%d versus %dx%d)\n", width1, height1, width2, height2); - exit(1); + abort(); } // Move them into an array texture, since that's how the rest of the code @@ -462,13 +462,13 @@ int main(int argc, char **argv) break; default: fprintf(stderr, "Unknown option '%s'\n", argv[option_index]); - exit(1); + abort(); }; } if (SDL_Init(SDL_INIT_EVERYTHING) == -1) { fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError()); - exit(1); + abort(); } SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); diff --git a/futatabi/frame_on_disk.cpp b/futatabi/frame_on_disk.cpp index c3e3b4d..971cafd 100644 --- a/futatabi/frame_on_disk.cpp +++ b/futatabi/frame_on_disk.cpp @@ -66,7 +66,7 @@ string FrameReader::read_frame(FrameOnDisk frame) fd = open(filename.c_str(), O_RDONLY); if (fd == -1) { perror(filename.c_str()); - exit(1); + abort(); } // We want readahead. (Ignore errors.) @@ -83,7 +83,7 @@ string FrameReader::read_frame(FrameOnDisk frame) int ret = pread(fd, &str[offset], frame.size - offset, frame.offset + offset); if (ret <= 0) { perror("pread"); - exit(1); + abort(); } offset += ret; diff --git a/futatabi/jpeg_frame_view.cpp b/futatabi/jpeg_frame_view.cpp index d35964c..198affd 100644 --- a/futatabi/jpeg_frame_view.cpp +++ b/futatabi/jpeg_frame_view.cpp @@ -127,7 +127,7 @@ shared_ptr decode_jpeg(const string &jpeg) dinfo.comp_info[0].h_samp_factor, dinfo.comp_info[0].v_samp_factor, dinfo.comp_info[1].h_samp_factor, dinfo.comp_info[1].v_samp_factor, dinfo.comp_info[2].h_samp_factor, dinfo.comp_info[2].v_samp_factor); - exit(1); + abort(); } dinfo.raw_data_out = true; diff --git a/futatabi/main.cpp b/futatabi/main.cpp index 4c54d33..e6556d3 100644 --- a/futatabi/main.cpp +++ b/futatabi/main.cpp @@ -84,7 +84,7 @@ FrameOnDisk write_frame(int stream_idx, int64_t pts, const uint8_t *data, size_t FILE *fp = fopen(filename, "wb"); if (fp == nullptr) { perror(filename); - exit(1); + abort(); } lock_guard lock(frame_mu); @@ -109,26 +109,26 @@ FrameOnDisk write_frame(int stream_idx, int64_t pts, const uint8_t *data, size_t string serialized; if (!hdr.SerializeToString(&serialized)) { fprintf(stderr, "Frame header serialization failed.\n"); - exit(1); + abort(); } uint32_t len = htonl(serialized.size()); if (fwrite(frame_magic, frame_magic_len, 1, file.fp) != 1) { perror("fwrite"); - exit(1); + abort(); } if (fwrite(&len, sizeof(len), 1, file.fp) != 1) { perror("fwrite"); - exit(1); + abort(); } if (fwrite(serialized.data(), serialized.size(), 1, file.fp) != 1) { perror("fwrite"); - exit(1); + abort(); } off_t offset = ftell(file.fp); if (fwrite(data, size, 1, file.fp) != 1) { perror("fwrite"); - exit(1); + abort(); } fflush(file.fp); // No fsync(), though. We can accept losing a few frames. global_disk_space_estimator->report_write(filename, 8 + sizeof(len) + serialized.size() + size, pts); @@ -151,7 +151,7 @@ FrameOnDisk write_frame(int stream_idx, int64_t pts, const uint8_t *data, size_t // Start a new file next time. if (fclose(file.fp) != 0) { perror("fclose"); - exit(1); + abort(); } open_frame_files.erase(stream_idx); @@ -199,7 +199,7 @@ int main(int argc, char **argv) global_flags.stream_source = argv[optind]; } else { usage(); - exit(1); + abort(); } string frame_dir = global_flags.working_directory + "/frames"; @@ -208,7 +208,7 @@ int main(int argc, char **argv) fprintf(stderr, "%s does not exist, creating it.\n", frame_dir.c_str()); } else if (errno != EEXIST) { perror(global_flags.working_directory.c_str()); - exit(1); + abort(); } avformat_network_init(); @@ -237,7 +237,7 @@ int main(int argc, char **argv) global_share_widget = new QGLWidget(); if (!global_share_widget->isValid()) { fprintf(stderr, "Failed to initialize OpenGL. Futatabi needs at least OpenGL 4.5 to function properly.\n"); - exit(1); + abort(); } // Initialize Movit. @@ -246,7 +246,7 @@ int main(int argc, char **argv) QOpenGLContext *context = create_context(surface); if (!make_current(context, surface)) { printf("oops\n"); - exit(1); + abort(); } CHECK(movit::init_movit(MOVIT_SHADER_DIR, movit::MOVIT_DEBUG_OFF)); delete_context(context); @@ -284,7 +284,7 @@ void load_frame_file(const char *filename, const string &basename, unsigned file struct stat st; if (stat(filename, &st) == -1) { perror(filename); - exit(1); + abort(); } vector all_frames = db->load_frame_file(basename, st.st_size, filename_idx); @@ -302,7 +302,7 @@ void load_frame_file(const char *filename, const string &basename, unsigned file FILE *fp = fopen(filename, "rb"); if (fp == nullptr) { perror(filename); - exit(1); + abort(); } size_t magic_offset = 0; @@ -412,7 +412,7 @@ void load_existing_frames() if (de == nullptr) { if (errno != 0) { perror("readdir"); - exit(1); + abort(); } break; } @@ -424,7 +424,7 @@ void load_existing_frames() } if (progress.wasCanceled()) { - exit(1); + abort(); } } closedir(dir); @@ -442,7 +442,7 @@ void load_existing_frames() load_frame_file(frame_filenames[i].c_str(), frame_basenames[i], i, &db); progress.setValue(i + 3); if (progress.wasCanceled()) { - exit(1); + abort(); } } diff --git a/futatabi/mainwindow.cpp b/futatabi/mainwindow.cpp index 05ea582..dfc2ea5 100644 --- a/futatabi/mainwindow.cpp +++ b/futatabi/mainwindow.cpp @@ -289,7 +289,7 @@ MainWindow::MainWindow() if (!load_midi_mapping_from_file(global_flags.midi_mapping_filename, &midi_mapping)) { fprintf(stderr, "Couldn't load MIDI mapping '%s'; exiting.\n", global_flags.midi_mapping_filename.c_str()); - exit(1); + abort(); } midi_mapper.set_midi_mapping(midi_mapping); } diff --git a/futatabi/player.cpp b/futatabi/player.cpp index 687afd0..611f0ab 100644 --- a/futatabi/player.cpp +++ b/futatabi/player.cpp @@ -35,7 +35,7 @@ void Player::thread_func(AVFormatContext *file_avctx) QOpenGLContext *context = create_context(surface); if (!make_current(context, surface)) { printf("oops\n"); - exit(1); + abort(); } check_error(); diff --git a/futatabi/vaapi_jpeg_decoder.cpp b/futatabi/vaapi_jpeg_decoder.cpp index 1d0f771c..d18a873 100644 --- a/futatabi/vaapi_jpeg_decoder.cpp +++ b/futatabi/vaapi_jpeg_decoder.cpp @@ -41,7 +41,7 @@ static mutex va_resources_mutex; #define CHECK_VASTATUS(va_status, func) \ if (va_status != VA_STATUS_SUCCESS) { \ fprintf(stderr, "%s:%d (%s) failed with %d\n", __func__, __LINE__, func, va_status); \ - exit(1); \ + abort(); \ } #define CHECK_VASTATUS_RET(va_status, func) \ diff --git a/futatabi/video_stream.cpp b/futatabi/video_stream.cpp index 290168e..4b0336c 100644 --- a/futatabi/video_stream.cpp +++ b/futatabi/video_stream.cpp @@ -600,7 +600,7 @@ void VideoStream::encode_thread_func() bool ok = make_current(context, surface); if (!ok) { fprintf(stderr, "Video stream couldn't get an OpenGL context\n"); - exit(1); + abort(); } while (!should_quit) { diff --git a/futatabi/vis.cpp b/futatabi/vis.cpp index c67a0cc..5585f6a 100644 --- a/futatabi/vis.cpp +++ b/futatabi/vis.cpp @@ -12,7 +12,7 @@ int main(int argc, char **argv) { if (argc != 3) { fprintf(stderr, "Usage: ./vis input.flo out.ppm\n"); - exit(1); + abort(); } Flow flow = read_flow(argv[1]); diff --git a/nageru/alsa_output.cpp b/nageru/alsa_output.cpp index 7dd1024..bc2c89c 100644 --- a/nageru/alsa_output.cpp +++ b/nageru/alsa_output.cpp @@ -14,7 +14,7 @@ void die_on_error(const char *func_name, int err) { if (err < 0) { fprintf(stderr, "%s: %s\n", func_name, snd_strerror(err)); - exit(1); + abort(); } } @@ -74,7 +74,7 @@ try_again: ret = 0; } else if (ret < 0) { fprintf(stderr, "error: snd_pcm_writei() returned '%s'\n", snd_strerror(ret)); - exit(1); + abort(); } else if (ret > 0) { buffer.erase(buffer.begin(), buffer.begin() + ret * num_channels); } diff --git a/nageru/alsa_pool.cpp b/nageru/alsa_pool.cpp index 978f236..bdff5af 100644 --- a/nageru/alsa_pool.cpp +++ b/nageru/alsa_pool.cpp @@ -44,7 +44,7 @@ ALSAPool::~ALSAPool() const uint64_t one = 1; if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) { perror("write(should_quit_fd)"); - exit(1); + abort(); } inotify_thread.join(); diff --git a/nageru/analyzer.cpp b/nageru/analyzer.cpp index bdb80bc..b08af19 100644 --- a/nageru/analyzer.cpp +++ b/nageru/analyzer.cpp @@ -41,7 +41,7 @@ Analyzer::Analyzer() context = create_context(surface); if (!make_current(context, surface)) { printf("oops\n"); - exit(1); + abort(); } grab_timer.setSingleShot(true); @@ -96,7 +96,7 @@ void Analyzer::mixer_shutting_down() if (!make_current(context, surface)) { printf("oops\n"); - exit(1); + abort(); } glDeleteBuffers(1, &pbo); check_error(); @@ -111,7 +111,7 @@ void Analyzer::grab_clicked() if (!make_current(context, surface)) { printf("oops\n"); - exit(1); + abort(); } Mixer::DisplayFrame frame; diff --git a/nageru/audio_encoder.cpp b/nageru/audio_encoder.cpp index a2ab14b..0f7f9aa 100644 --- a/nageru/audio_encoder.cpp +++ b/nageru/audio_encoder.cpp @@ -32,7 +32,7 @@ AudioEncoder::AudioEncoder(const string &codec_name, int bit_rate, const AVOutpu AVCodec *codec = avcodec_find_encoder_by_name(codec_name.c_str()); if (codec == nullptr) { fprintf(stderr, "ERROR: Could not find codec '%s'\n", codec_name.c_str()); - exit(1); + abort(); } ctx = avcodec_alloc_context3(codec); @@ -47,7 +47,7 @@ AudioEncoder::AudioEncoder(const string &codec_name, int bit_rate, const AVOutpu } if (avcodec_open2(ctx, codec, NULL) < 0) { fprintf(stderr, "Could not open codec '%s'\n", codec_name.c_str()); - exit(1); + abort(); } resampler = swr_alloc_set_opts(nullptr, @@ -61,12 +61,12 @@ AudioEncoder::AudioEncoder(const string &codec_name, int bit_rate, const AVOutpu /*log_ctx=*/nullptr); if (resampler == nullptr) { fprintf(stderr, "Allocating resampler failed.\n"); - exit(1); + abort(); } if (swr_init(resampler) < 0) { fprintf(stderr, "Could not open resample context.\n"); - exit(1); + abort(); } audio_frame = av_frame_alloc(); @@ -116,18 +116,18 @@ void AudioEncoder::encode_audio_one_frame(const float *audio, size_t num_samples if (av_samples_alloc(audio_frame->data, nullptr, 2, num_samples, ctx->sample_fmt, 0) < 0) { fprintf(stderr, "Could not allocate %zu samples.\n", num_samples); - exit(1); + abort(); } if (swr_convert(resampler, audio_frame->data, num_samples, reinterpret_cast(&audio), num_samples) < 0) { fprintf(stderr, "Audio conversion failed.\n"); - exit(1); + abort(); } int err = avcodec_send_frame(ctx, audio_frame); if (err < 0) { fprintf(stderr, "avcodec_send_frame() failed with error %d\n", err); - exit(1); + abort(); } for ( ;; ) { // Termination condition within loop. @@ -147,7 +147,7 @@ void AudioEncoder::encode_audio_one_frame(const float *audio, size_t num_samples break; } else { fprintf(stderr, "avcodec_receive_frame() failed with error %d\n", err); - exit(1); + abort(); } } @@ -183,7 +183,7 @@ void AudioEncoder::encode_last_audio() break; } else { fprintf(stderr, "avcodec_receive_frame() failed with error %d\n", err); - exit(1); + abort(); } } } diff --git a/nageru/audio_mixer.cpp b/nageru/audio_mixer.cpp index 891fb22..9b588d7 100644 --- a/nageru/audio_mixer.cpp +++ b/nageru/audio_mixer.cpp @@ -206,7 +206,7 @@ AudioMixer::AudioMixer(unsigned num_capture_cards, unsigned num_ffmpeg_inputs) &new_input_mapping)) { fprintf(stderr, "Failed to load input mapping from '%s', exiting.\n", global_flags.input_mapping_filename.c_str()); - exit(1); + abort(); } set_input_mapping(new_input_mapping); } else { diff --git a/nageru/chroma_subsampler.cpp b/nageru/chroma_subsampler.cpp index 14cb4d2..ff9d919 100644 --- a/nageru/chroma_subsampler.cpp +++ b/nageru/chroma_subsampler.cpp @@ -140,7 +140,7 @@ ChromaSubsampler::ChromaSubsampler(ResourcePool *resource_pool) GLchar error_log[1024] = {0}; glGetProgramInfoLog(v210_program_num, 1024, nullptr, error_log); fprintf(stderr, "Error linking program: %s\n", error_log); - exit(1); + abort(); } v210_in_y_pos = glGetUniformLocation(v210_program_num, "in_y"); diff --git a/nageru/decklink_capture.cpp b/nageru/decklink_capture.cpp index f7016dc..ab5e1ec 100644 --- a/nageru/decklink_capture.cpp +++ b/nageru/decklink_capture.cpp @@ -63,20 +63,20 @@ DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index) if (card->QueryInterface(IID_IDeckLinkInput, (void**)&input) != S_OK) { fprintf(stderr, "Card %d has no inputs\n", card_index); - exit(1); + abort(); } IDeckLinkAttributes *attr; if (card->QueryInterface(IID_IDeckLinkAttributes, (void**)&attr) != S_OK) { fprintf(stderr, "Card %d has no attributes\n", card_index); - exit(1); + abort(); } // Get the list of available video inputs. int64_t video_input_mask; if (attr->GetInt(BMDDeckLinkVideoInputConnections, &video_input_mask) != S_OK) { fprintf(stderr, "Failed to enumerate video inputs for card %d\n", card_index); - exit(1); + abort(); } const vector> video_input_types = { { bmdVideoConnectionSDI, "SDI" }, @@ -96,7 +96,7 @@ DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index) int64_t audio_input_mask; if (attr->GetInt(BMDDeckLinkAudioInputConnections, &audio_input_mask) != S_OK) { fprintf(stderr, "Failed to enumerate audio inputs for card %d\n", card_index); - exit(1); + abort(); } const vector> audio_input_types = { { bmdAudioConnectionEmbedded, "Embedded" }, @@ -134,7 +134,7 @@ DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index) /* Set up the video and audio sources. */ if (card->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) != S_OK) { fprintf(stderr, "Failed to get configuration interface for card %d\n", card_index); - exit(1); + abort(); } BMDVideoConnection connection = pick_default_video_connection(card, BMDDeckLinkVideoInputConnections, card_index); @@ -145,7 +145,7 @@ DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index) IDeckLinkDisplayModeIterator *mode_it; if (input->GetDisplayModeIterator(&mode_it) != S_OK) { fprintf(stderr, "Failed to enumerate display modes for card %d\n", card_index); - exit(1); + abort(); } video_modes = summarize_video_modes(mode_it, card_index); @@ -198,7 +198,7 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFormatChanged( } if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) { fprintf(stderr, "Could not get new frame rate\n"); - exit(1); + abort(); } field_dominance = display_mode->GetFieldDominance(); return S_OK; @@ -326,16 +326,16 @@ void DeckLinkCapture::start_bm_capture() } if (input->EnableVideoInput(current_video_mode, pixel_format_to_bmd(current_pixel_format), supports_autodetect ? bmdVideoInputEnableFormatDetection : 0) != S_OK) { fprintf(stderr, "Failed to set video mode 0x%04x for card %d\n", current_video_mode, card_index); - exit(1); + abort(); } if (input->EnableAudioInput(48000, bmdAudioSampleType32bitInteger, 2) != S_OK) { fprintf(stderr, "Failed to enable audio input for card %d\n", card_index); - exit(1); + abort(); } if (input->StartStreams() != S_OK) { fprintf(stderr, "StartStreams failed\n"); - exit(1); + abort(); } running = true; } @@ -348,7 +348,7 @@ void DeckLinkCapture::stop_dequeue_thread() HRESULT result = input->StopStreams(); if (result != S_OK) { fprintf(stderr, "StopStreams failed with error 0x%x\n", result); - exit(1); + abort(); } // We could call DisableVideoInput() and DisableAudioInput() here, @@ -363,11 +363,11 @@ void DeckLinkCapture::set_video_mode(uint32_t video_mode_id) if (running) { if (input->PauseStreams() != S_OK) { fprintf(stderr, "PauseStreams failed\n"); - exit(1); + abort(); } if (input->FlushStreams() != S_OK) { fprintf(stderr, "FlushStreams failed\n"); - exit(1); + abort(); } } @@ -376,7 +376,7 @@ void DeckLinkCapture::set_video_mode(uint32_t video_mode_id) if (running) { if (input->StartStreams() != S_OK) { fprintf(stderr, "StartStreams failed\n"); - exit(1); + abort(); } } } @@ -393,17 +393,17 @@ void DeckLinkCapture::set_video_mode_no_restart(uint32_t video_mode_id) IDeckLinkDisplayMode *display_mode; if (input->DoesSupportVideoMode(video_mode_id, pixel_format_to_bmd(current_pixel_format), /*flags=*/0, &support, &display_mode)) { fprintf(stderr, "Failed to query display mode for card %d\n", card_index); - exit(1); + abort(); } if (support == bmdDisplayModeNotSupported) { fprintf(stderr, "Card %d does not support display mode\n", card_index); - exit(1); + abort(); } if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) { fprintf(stderr, "Could not get frame rate for card %d\n", card_index); - exit(1); + abort(); } field_dominance = display_mode->GetFieldDominance(); @@ -411,7 +411,7 @@ void DeckLinkCapture::set_video_mode_no_restart(uint32_t video_mode_id) if (running) { if (input->EnableVideoInput(video_mode_id, pixel_format_to_bmd(current_pixel_format), supports_autodetect ? bmdVideoInputEnableFormatDetection : 0) != S_OK) { fprintf(stderr, "Failed to set video mode 0x%04x for card %d\n", video_mode_id, card_index); - exit(1); + abort(); } } @@ -422,7 +422,7 @@ void DeckLinkCapture::set_video_input(uint32_t video_input_id) { if (config->SetInt(bmdDeckLinkConfigVideoInputConnection, video_input_id) != S_OK) { fprintf(stderr, "Failed to set video input connection for card %d\n", card_index); - exit(1); + abort(); } current_video_input = video_input_id; @@ -432,7 +432,7 @@ void DeckLinkCapture::set_audio_input(uint32_t audio_input_id) { if (config->SetInt(bmdDeckLinkConfigAudioInputConnection, audio_input_id) != S_OK) { fprintf(stderr, "Failed to set audio input connection for card %d\n", card_index); - exit(1); + abort(); } current_audio_input = audio_input_id; diff --git a/nageru/decklink_output.cpp b/nageru/decklink_output.cpp index e370029..f6826b5 100644 --- a/nageru/decklink_output.cpp +++ b/nageru/decklink_output.cpp @@ -130,7 +130,7 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts) if (video_modes.empty()) { fprintf(stderr, "ERROR: No matching output modes for %dx%d found\n", width, height); - exit(1); + abort(); } should_quit.unquit(); @@ -141,19 +141,19 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts) IDeckLinkConfiguration *config = nullptr; if (output->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) != S_OK) { fprintf(stderr, "Failed to get configuration interface for output card\n"); - exit(1); + abort(); } if (config->SetFlag(bmdDeckLinkConfigLowLatencyVideoOutput, true) != S_OK) { fprintf(stderr, "Failed to set low latency output\n"); - exit(1); + abort(); } if (config->SetInt(bmdDeckLinkConfigVideoOutputConnection, video_connection) != S_OK) { fprintf(stderr, "Failed to set video output connection for card %u\n", card_index); - exit(1); + abort(); } if (config->SetFlag(bmdDeckLinkConfigUse1080pNotPsF, true) != S_OK) { fprintf(stderr, "Failed to set PsF flag for card\n"); - exit(1); + abort(); } if (config->SetFlag(bmdDeckLinkConfigSMPTELevelAOutput, true) != S_OK) { // This affects at least some no-name SDI->HDMI converters. @@ -167,12 +167,12 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts) if (output->DoesSupportVideoMode(mode, pixel_format, bmdVideoOutputFlagDefault, &support, &display_mode) != S_OK) { fprintf(stderr, "Couldn't ask for format support\n"); - exit(1); + abort(); } if (support == bmdDisplayModeNotSupported) { fprintf(stderr, "Requested display mode not supported\n"); - exit(1); + abort(); } current_mode_flags = display_mode->GetFlags(); @@ -181,7 +181,7 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts) BMDTimeScale time_scale; if (display_mode->GetFrameRate(&time_value, &time_scale) != S_OK) { fprintf(stderr, "Couldn't get frame rate\n"); - exit(1); + abort(); } metric_decklink_output_width_pixels = width; @@ -196,20 +196,20 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts) HRESULT result = output->EnableVideoOutput(mode, bmdVideoOutputFlagDefault); if (result != S_OK) { fprintf(stderr, "Couldn't enable output with error 0x%x\n", result); - exit(1); + abort(); } if (output->SetScheduledFrameCompletionCallback(this) != S_OK) { fprintf(stderr, "Couldn't set callback\n"); - exit(1); + abort(); } assert(OUTPUT_FREQUENCY == 48000); if (output->EnableAudioOutput(bmdAudioSampleRate48kHz, bmdAudioSampleType32bitInteger, 2, bmdAudioOutputStreamTimestamped) != S_OK) { fprintf(stderr, "Couldn't enable audio output\n"); - exit(1); + abort(); } if (output->BeginAudioPreroll() != S_OK) { fprintf(stderr, "Couldn't begin audio preroll\n"); - exit(1); + abort(); } present_thread = thread([this]{ @@ -218,7 +218,7 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts) if (!make_current(context, this->surface)) { printf("display=%p surface=%p context=%p curr=%p err=%d\n", eglGetCurrentDisplay(), this->surface, context, eglGetCurrentContext(), eglGetError()); - exit(1); + abort(); } present_thread_func(); delete_context(context); @@ -366,11 +366,11 @@ void DeckLinkOutput::wait_for_frame(int64_t pts, int *dropped_frames, int64_t *f if (!playback_started) { if (output->EndAudioPreroll() != S_OK) { fprintf(stderr, "Could not end audio preroll\n"); - exit(1); // TODO + abort(); // TODO } if (output->StartScheduledPlayback(base_pts, TIMEBASE, 1.0) != S_OK) { fprintf(stderr, "Could not start playback\n"); - exit(1); // TODO + abort(); // TODO } playback_started = true; } diff --git a/nageru/decklink_util.cpp b/nageru/decklink_util.cpp index 4b701ab..33a7933 100644 --- a/nageru/decklink_util.cpp +++ b/nageru/decklink_util.cpp @@ -33,7 +33,7 @@ map summarize_video_modes(IDeckLinkDisplayModeIterator *mod BMDTimeValue frame_rate_den; if (mode_ptr->GetFrameRate(&frame_rate_den, &frame_rate_num) != S_OK) { fprintf(stderr, "Could not get frame rate for mode '%s' on card %d\n", mode.name.c_str(), card_index); - exit(1); + abort(); } mode.frame_rate_num = frame_rate_num; mode.frame_rate_den = frame_rate_den; @@ -56,7 +56,7 @@ BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAtt IDeckLinkAttributes *attr; if (card->QueryInterface(IID_IDeckLinkAttributes, (void**)&attr) != S_OK) { fprintf(stderr, "Card %u has no attributes\n", card_index); - exit(1); + abort(); } int64_t connection_mask; @@ -66,7 +66,7 @@ BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAtt } else { fprintf(stderr, "Failed to enumerate video outputs for card %u\n", card_index); } - exit(1); + abort(); } attr->Release(); if (connection_mask == 0) { @@ -75,7 +75,7 @@ BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAtt } else { fprintf(stderr, "Card %u has no output connections\n", card_index); } - exit(1); + abort(); } if ((connection_mask & bmdVideoConnectionHDMI) && diff --git a/nageru/ffmpeg_capture.cpp b/nageru/ffmpeg_capture.cpp index b4fec06..17448c4 100644 --- a/nageru/ffmpeg_capture.cpp +++ b/nageru/ffmpeg_capture.cpp @@ -793,12 +793,12 @@ void FFmpegCapture::convert_audio(const AVFrame *audio_avframe, FrameAllocator:: if (resampler == nullptr) { fprintf(stderr, "Allocating resampler failed.\n"); - exit(1); + abort(); } if (swr_init(resampler) < 0) { fprintf(stderr, "Could not open resample context.\n"); - exit(1); + abort(); } last_src_format = AVSampleFormat(audio_avframe->format); @@ -815,7 +815,7 @@ void FFmpegCapture::convert_audio(const AVFrame *audio_avframe, FrameAllocator:: const_cast(audio_avframe->data), audio_avframe->nb_samples); if (out_samples < 0) { fprintf(stderr, "Audio conversion failed.\n"); - exit(1); + abort(); } audio_frame->len += out_samples * bytes_per_sample; diff --git a/nageru/ffmpeg_util.cpp b/nageru/ffmpeg_util.cpp index e348d0a..9a74ca1 100644 --- a/nageru/ffmpeg_util.cpp +++ b/nageru/ffmpeg_util.cpp @@ -58,7 +58,7 @@ string search_for_file_or_die(const string &filename) if (pathname.empty()) { fprintf(stderr, "Couldn't find %s in any directory in --theme-dirs, exiting.\n", filename.c_str()); - exit(1); + abort(); } return pathname; } diff --git a/nageru/flags.cpp b/nageru/flags.cpp index bdb9821..b025076 100644 --- a/nageru/flags.cpp +++ b/nageru/flags.cpp @@ -87,7 +87,7 @@ map parse_mjpeg_export_cards(char *optarg) } if (range_end < range_begin) { fprintf(stderr, "ERROR: Invalid range %u-%u in --mjpeg-export-cards=\n", range_begin, range_end); - exit(1); + abort(); } if (range_end >= unsigned(global_flags.num_cards)) { // There are situations where we could possibly want to @@ -96,12 +96,12 @@ map parse_mjpeg_export_cards(char *optarg) // require more functionality the the JPEG encoder. fprintf(stderr, "ERROR: Asked for (zero-indexed) card %u in --mjpeg-export-cards=, but there are only %u cards\n", range_end, global_flags.num_cards); - exit(1); + abort(); } for (unsigned card_idx = range_begin; card_idx <= range_end; ++card_idx) { if (ret.count(card_idx)) { fprintf(stderr, "ERROR: Card %u was given twice in --mjpeg-export-cards=\n", card_idx); - exit(1); + abort(); } ret[card_idx] = stream_idx++; } @@ -317,7 +317,7 @@ void parse_flags(Program program, int argc, char * const argv[]) char *ptr = strchr(optarg, ','); if (ptr == nullptr) { fprintf(stderr, "ERROR: Invalid argument '%s' to --map-signal (needs a signal and a card number, separated by comma)\n", optarg); - exit(1); + abort(); } *ptr = '\0'; const int signal_num = atoi(optarg); @@ -325,7 +325,7 @@ void parse_flags(Program program, int argc, char * const argv[]) if (global_flags.default_stream_mapping.count(signal_num)) { fprintf(stderr, "ERROR: Signal %d already mapped to card %d\n", signal_num, global_flags.default_stream_mapping[signal_num]); - exit(1); + abort(); } global_flags.default_stream_mapping[signal_num] = card_num; break; @@ -489,13 +489,13 @@ void parse_flags(Program program, int argc, char * const argv[]) char *ptr = strchr(optarg, ','); if (ptr == nullptr) { fprintf(stderr, "ERROR: Invalid argument '%s' to --input-ycbcr-interpretation (needs a card and an interpretation, separated by comma)\n", optarg); - exit(1); + abort(); } *ptr = '\0'; const int card_num = atoi(optarg); if (card_num < 0 || card_num >= MAX_VIDEO_CARDS) { fprintf(stderr, "ERROR: Invalid card number %d\n", card_num); - exit(1); + abort(); } YCbCrInterpretation interpretation; @@ -510,7 +510,7 @@ void parse_flags(Program program, int argc, char * const argv[]) interpretation.full_range = false; } else { fprintf(stderr, "ERROR: Invalid Y'CbCr range '%s' (must be “full” or “limited”)\n", range); - exit(1); + abort(); } } @@ -524,11 +524,11 @@ void parse_flags(Program program, int argc, char * const argv[]) interpretation.ycbcr_coefficients_auto = true; if (interpretation.full_range) { fprintf(stderr, "ERROR: Cannot use “auto” Y'CbCr coefficients with full range\n"); - exit(1); + abort(); } } else { fprintf(stderr, "ERROR: Invalid Y'CbCr coefficients '%s' (must be “rec601”, “rec709” or “auto”)\n", interpretation_str); - exit(1); + abort(); } global_flags.ycbcr_interpretation[card_num] = interpretation; break; @@ -539,7 +539,7 @@ void parse_flags(Program program, int argc, char * const argv[]) case OPTION_MJPEG_EXPORT_CARDS: { if (card_to_mjpeg_stream_export_set) { fprintf(stderr, "ERROR: --mjpeg-export-cards given twice\n"); - exit(1); + abort(); } global_flags.card_to_mjpeg_stream_export = parse_mjpeg_export_cards(optarg); card_to_mjpeg_stream_export_set = true; @@ -552,28 +552,28 @@ void parse_flags(Program program, int argc, char * const argv[]) fprintf(stderr, "Unknown option '%s'\n", argv[option_index]); fprintf(stderr, "\n"); usage(program); - exit(1); + abort(); } } if (global_flags.uncompressed_video_to_http && global_flags.x264_video_to_http) { fprintf(stderr, "ERROR: --http-uncompressed-video and --http-x264-video are mutually incompatible\n"); - exit(1); + abort(); } if (global_flags.num_cards <= 0) { fprintf(stderr, "ERROR: --num-cards must be at least 1\n"); - exit(1); + abort(); } if (global_flags.output_card < -1 || global_flags.output_card >= global_flags.num_cards) { fprintf(stderr, "ERROR: --output-card points to a nonexistant card\n"); - exit(1); + abort(); } if (!global_flags.transcode_audio && global_flags.stream_audio_codec_name.empty()) { fprintf(stderr, "ERROR: If not transcoding audio, you must specify ahead-of-time what audio codec is in use\n"); fprintf(stderr, " (using --http-audio-codec).\n"); - exit(1); + abort(); } if (global_flags.x264_speedcontrol) { if (!global_flags.x264_preset.empty() && global_flags.x264_preset != "faster") { @@ -594,14 +594,14 @@ void parse_flags(Program program, int argc, char * const argv[]) if (global_flags.width <= 0 || (global_flags.width % 8) != 0 || global_flags.height <= 0 || (global_flags.height % 8) != 0) { fprintf(stderr, "ERROR: --width and --height must be positive integers divisible by 8\n"); - exit(1); + abort(); } for (pair mapping : global_flags.default_stream_mapping) { if (mapping.second >= global_flags.num_cards) { fprintf(stderr, "ERROR: Signal %d mapped to card %d, which doesn't exist (try adjusting --num-cards)\n", mapping.first, mapping.second); - exit(1); + abort(); } } @@ -633,22 +633,22 @@ void parse_flags(Program program, int argc, char * const argv[]) global_flags.ycbcr_auto_coefficients = false; } else { fprintf(stderr, "ERROR: --output-ycbcr-coefficients must be “rec601”, “rec709” or “auto”\n"); - exit(1); + abort(); } if (global_flags.output_buffer_frames < 0.0f) { // Actually, even zero probably won't make sense; there is some internal // delay to the card. fprintf(stderr, "ERROR: --output-buffer-frames can't be negative.\n"); - exit(1); + abort(); } if (global_flags.output_slop_frames < 0.0f) { fprintf(stderr, "ERROR: --output-slop-frames can't be negative.\n"); - exit(1); + abort(); } if (global_flags.max_input_queue_frames < 1) { fprintf(stderr, "ERROR: --max-input-queue-frames must be at least 1.\n"); - exit(1); + abort(); } if (global_flags.max_input_queue_frames > 10) { fprintf(stderr, "WARNING: --max-input-queue-frames has little effect over 10.\n"); @@ -657,7 +657,7 @@ void parse_flags(Program program, int argc, char * const argv[]) if (!isinf(global_flags.x264_crf)) { // CRF mode is selected. if (global_flags.x264_bitrate != -1) { fprintf(stderr, "ERROR: --x264-bitrate and --x264-crf are mutually incompatible.\n"); - exit(1); + abort(); } if (global_flags.x264_vbv_max_bitrate != -1 && global_flags.x264_vbv_buffer_size != -1) { fprintf(stderr, "WARNING: VBV settings are ignored with --x264-crf.\n"); diff --git a/nageru/image_input.cpp b/nageru/image_input.cpp index 4b6840b..08ef3b9 100644 --- a/nageru/image_input.cpp +++ b/nageru/image_input.cpp @@ -47,7 +47,7 @@ ImageInput::ImageInput(const string &filename) { if (current_image == nullptr) { // Could happen even though search_for_file() returned. fprintf(stderr, "Couldn't load image, exiting.\n"); - exit(1); + abort(); } set_width(current_image->width); set_height(current_image->height); diff --git a/nageru/kaeru.cpp b/nageru/kaeru.cpp index 7a058e4..32b497d 100644 --- a/nageru/kaeru.cpp +++ b/nageru/kaeru.cpp @@ -173,7 +173,7 @@ int main(int argc, char *argv[]) parse_flags(PROGRAM_KAERU, argc, argv); if (optind + 1 != argc) { usage(PROGRAM_KAERU); - exit(1); + abort(); } global_flags.num_cards = 1; // For latency metrics. diff --git a/nageru/main.cpp b/nageru/main.cpp index 410a6c4..b546375 100644 --- a/nageru/main.cpp +++ b/nageru/main.cpp @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) global_share_widget = new QGLWidget(); if (!global_share_widget->isValid()) { fprintf(stderr, "Failed to initialize OpenGL. Nageru needs at least OpenGL 3.1 to function properly.\n"); - exit(1); + abort(); } MainWindow mainWindow; diff --git a/nageru/mainwindow.cpp b/nageru/mainwindow.cpp index 96552a5..91234ce 100644 --- a/nageru/mainwindow.cpp +++ b/nageru/mainwindow.cpp @@ -281,7 +281,7 @@ MainWindow::MainWindow() if (!load_midi_mapping_from_file(global_flags.midi_mapping_filename, &midi_mapping)) { fprintf(stderr, "Couldn't load MIDI mapping '%s'; exiting.\n", global_flags.midi_mapping_filename.c_str()); - ::exit(1); + ::abort(); } midi_mapper.set_midi_mapping(midi_mapping); } diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index 32c1984..c91857e 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -432,7 +432,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) for (unsigned video_card_index = 0; video_card_index < video_inputs.size(); ++card_index, ++video_card_index) { if (card_index >= MAX_VIDEO_CARDS) { fprintf(stderr, "ERROR: Not enough card slots available for the videos the theme requested.\n"); - exit(1); + abort(); } configure_card(card_index, video_inputs[video_card_index], CardType::FFMPEG_INPUT, /*output=*/nullptr); video_inputs[video_card_index]->set_card_index(card_index); @@ -445,7 +445,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) for (unsigned html_card_index = 0; html_card_index < html_inputs.size(); ++card_index, ++html_card_index) { if (card_index >= MAX_VIDEO_CARDS) { fprintf(stderr, "ERROR: Not enough card slots available for the HTML inputs the theme requested.\n"); - exit(1); + abort(); } configure_card(card_index, html_inputs[html_card_index], CardType::CEF_INPUT, /*output=*/nullptr); html_inputs[html_card_index]->set_card_index(card_index); @@ -466,7 +466,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) if (!v210Converter::has_hardware_support()) { fprintf(stderr, "ERROR: --ten-bit-input requires support for OpenGL compute shaders\n"); fprintf(stderr, " (OpenGL 4.3, or GL_ARB_compute_shader + GL_ARB_shader_image_load_store).\n"); - exit(1); + abort(); } v210_converter.reset(new v210Converter()); @@ -483,7 +483,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) if (!v210Converter::has_hardware_support()) { fprintf(stderr, "ERROR: --ten-bit-output requires support for OpenGL compute shaders\n"); fprintf(stderr, " (OpenGL 4.3, or GL_ARB_compute_shader + GL_ARB_shader_image_load_store).\n"); - exit(1); + abort(); } } @@ -998,7 +998,7 @@ void Mixer::thread_func() QOpenGLContext *context = create_context(mixer_surface); if (!make_current(context, mixer_surface)) { printf("oops\n"); - exit(1); + abort(); } // Start the actual capture. (We don't want to do it before we're actually ready diff --git a/nageru/mjpeg_encoder.cpp b/nageru/mjpeg_encoder.cpp index 24aa0eb..46bb94c 100644 --- a/nageru/mjpeg_encoder.cpp +++ b/nageru/mjpeg_encoder.cpp @@ -131,7 +131,7 @@ MJPEGEncoder::MJPEGEncoder(HTTPD *httpd, const string &va_display) AVStream *stream = avformat_new_stream(avctx.get(), nullptr); if (stream == nullptr) { fprintf(stderr, "avformat_new_stream() failed\n"); - exit(1); + abort(); } stream->time_base = AVRational{ 1, TIMEBASE }; stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; @@ -159,7 +159,7 @@ MJPEGEncoder::MJPEGEncoder(HTTPD *httpd, const string &va_display) } if (avformat_write_header(avctx.get(), &options) < 0) { fprintf(stderr, "avformat_write_header() failed\n"); - exit(1); + abort(); } // Initialize VA-API. @@ -367,7 +367,7 @@ void MJPEGEncoder::write_mjpeg_packet(int64_t pts, unsigned card_index, const ui if (av_write_frame(avctx.get(), &pkt) < 0) { fprintf(stderr, "av_write_frame() failed\n"); - exit(1); + abort(); } } diff --git a/nageru/quicksync_encoder.cpp b/nageru/quicksync_encoder.cpp index 4883554..9dc603b 100644 --- a/nageru/quicksync_encoder.cpp +++ b/nageru/quicksync_encoder.cpp @@ -80,7 +80,7 @@ std::atomic metric_quick_sync_stalled_frames{0}; #define CHECK_VASTATUS(va_status, func) \ if (va_status != VA_STATUS_SUCCESS) { \ fprintf(stderr, "%s:%d (%s) failed with %d\n", __func__, __LINE__, func, va_status); \ - exit(1); \ + abort(); \ } #undef BUFFER_OFFSET @@ -822,7 +822,7 @@ int QuickSyncEncoderImpl::init_va(const string &va_display) va_dpy = try_open_va(va_display, &h264_profile, &error); if (va_dpy == nullptr) { fprintf(stderr, "error: %s\n", error.c_str()); - exit(1); + abort(); } if (!va_dpy->can_use_zerocopy) { use_zerocopy = false; @@ -860,7 +860,7 @@ int QuickSyncEncoderImpl::init_va(const string &va_display) /* check the interested configattrib */ if ((attrib[VAConfigAttribRTFormat].value & VA_RT_FORMAT_YUV420) == 0) { printf("Not find desired YUV420 RT format\n"); - exit(1); + abort(); } else { config_attrib[config_attrib_num].type = VAConfigAttribRTFormat; config_attrib[config_attrib_num].value = VA_RT_FORMAT_YUV420; @@ -870,7 +870,7 @@ int QuickSyncEncoderImpl::init_va(const string &va_display) if (attrib[VAConfigAttribRateControl].value != VA_ATTRIB_NOT_SUPPORTED) { if (!(attrib[VAConfigAttribRateControl].value & VA_RC_CQP)) { fprintf(stderr, "ERROR: VA-API encoder does not support CQP mode.\n"); - exit(1); + abort(); } config_attrib[config_attrib_num].type = VAConfigAttribRateControl; @@ -1564,7 +1564,7 @@ QuickSyncEncoderImpl::QuickSyncEncoderImpl(const std::string &filename, Resource if (!make_current(context, this->surface)) { printf("display=%p surface=%p context=%p curr=%p err=%d\n", eglGetCurrentDisplay(), this->surface, context, eglGetCurrentContext(), eglGetError()); - exit(1); + abort(); } encode_thread_func(); delete_context(context); @@ -1804,7 +1804,7 @@ void QuickSyncEncoderImpl::open_output_file(const std::string &filename) if (ret < 0) { char tmp[AV_ERROR_MAX_STRING_SIZE]; fprintf(stderr, "%s: avio_open2() failed: %s\n", filename.c_str(), av_make_error_string(tmp, sizeof(tmp), ret)); - exit(1); + abort(); } string video_extradata; // FIXME: See other comment about global headers. @@ -2179,5 +2179,5 @@ string QuickSyncEncoder::get_usable_va_display() fprintf(stderr, "to expose Quick Sync. Alternatively, you can use --record-x264-video\n"); fprintf(stderr, "to use software instead of hardware H.264 encoding, at the expense\n"); fprintf(stderr, "of increased CPU usage and possibly bit rate.\n"); - exit(1); + abort(); } diff --git a/nageru/theme.cpp b/nageru/theme.cpp index ead38fa..ed99e5f 100644 --- a/nageru/theme.cpp +++ b/nageru/theme.cpp @@ -455,7 +455,7 @@ int HTMLInput_new(lua_State* L) #else fprintf(stderr, "This version of Nageru has been compiled without CEF support.\n"); fprintf(stderr, "HTMLInput is not available.\n"); - exit(1); + abort(); #endif } @@ -1079,7 +1079,7 @@ int call_num_channels(lua_State *L) if (lua_pcall(L, 0, 1, 0) != 0) { fprintf(stderr, "error running function `num_channels': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } int num_channels = luaL_checknumber(L, 1); @@ -1142,7 +1142,7 @@ Theme::Theme(const string &filename, const vector &search_dirs, Resource for (const string &error : errors) { fprintf(stderr, "%s\n", error.c_str()); } - exit(1); + abort(); } assert(lua_gettop(L) == 0); @@ -1183,7 +1183,7 @@ Theme::Theme(const string &filename, const vector &search_dirs, Resource luaL_unref(L, LUA_REGISTRYINDEX, theme_code_ref); if (lua_pcall(L, 0, 0, 0)) { fprintf(stderr, "Error when running %s: %s\n", path.c_str(), lua_tostring(L, -1)); - exit(1); + abort(); } assert(lua_gettop(L) == 0); @@ -1251,19 +1251,19 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he if (lua_pcall(L, 5, 2, 0) != 0) { fprintf(stderr, "error running function `get_chain': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } EffectChain *effect_chain = (EffectChain *)luaL_testudata(L, -2, "EffectChain"); if (effect_chain == nullptr) { fprintf(stderr, "get_chain() for chain number %d did not return an EffectChain\n", num); - exit(1); + abort(); } chain.chain = effect_chain; if (!lua_isfunction(L, -1)) { fprintf(stderr, "Argument #-1 should be a function\n"); - exit(1); + abort(); } lua_pushvalue(L, -1); shared_ptr funcref(new LuaRefWithDeleter(&m, L, luaL_ref(L, LUA_REGISTRYINDEX))); @@ -1280,7 +1280,7 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he lua_rawgeti(L, LUA_REGISTRYINDEX, funcref->get()); if (lua_pcall(L, 0, 0, 0) != 0) { fprintf(stderr, "error running chain setup callback: %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } assert(lua_gettop(L) == 0); @@ -1321,12 +1321,12 @@ string Theme::get_channel_name(unsigned channel) lua_pushnumber(L, channel); if (lua_pcall(L, 1, 1, 0) != 0) { fprintf(stderr, "error running function `channel_name': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } const char *ret = lua_tostring(L, -1); if (ret == nullptr) { fprintf(stderr, "function `channel_name' returned nil for channel %d\n", channel); - exit(1); + abort(); } string retstr = ret; @@ -1342,7 +1342,7 @@ int Theme::get_channel_signal(unsigned channel) lua_pushnumber(L, channel); if (lua_pcall(L, 1, 1, 0) != 0) { fprintf(stderr, "error running function `channel_signal': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } int ret = luaL_checknumber(L, 1); @@ -1358,13 +1358,13 @@ std::string Theme::get_channel_color(unsigned channel) lua_pushnumber(L, channel); if (lua_pcall(L, 1, 1, 0) != 0) { fprintf(stderr, "error running function `channel_color': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } const char *ret = lua_tostring(L, -1); if (ret == nullptr) { fprintf(stderr, "function `channel_color' returned nil for channel %d\n", channel); - exit(1); + abort(); } string retstr = ret; @@ -1380,7 +1380,7 @@ bool Theme::get_supports_set_wb(unsigned channel) lua_pushnumber(L, channel); if (lua_pcall(L, 1, 1, 0) != 0) { fprintf(stderr, "error running function `supports_set_wb': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } bool ret = checkbool(L, -1); @@ -1399,7 +1399,7 @@ void Theme::set_wb(unsigned channel, double r, double g, double b) lua_pushnumber(L, b); if (lua_pcall(L, 4, 0, 0) != 0) { fprintf(stderr, "error running function `set_wb': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } assert(lua_gettop(L) == 0); @@ -1412,7 +1412,7 @@ vector Theme::get_transition_names(float t) lua_pushnumber(L, t); if (lua_pcall(L, 1, 1, 0) != 0) { fprintf(stderr, "error running function `get_transitions': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } vector ret; @@ -1477,7 +1477,7 @@ void Theme::transition_clicked(int transition_num, float t) if (lua_pcall(L, 2, 0, 0) != 0) { fprintf(stderr, "error running function `transition_clicked': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } assert(lua_gettop(L) == 0); } @@ -1490,7 +1490,7 @@ void Theme::channel_clicked(int preview_num) if (lua_pcall(L, 1, 0, 0) != 0) { fprintf(stderr, "error running function `channel_clicked': %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } assert(lua_gettop(L) == 0); } @@ -1530,6 +1530,6 @@ void Theme::theme_menu_entry_clicked(int lua_ref) lua_rawgeti(L, LUA_REGISTRYINDEX, lua_ref); if (lua_pcall(L, 0, 0, 0) != 0) { fprintf(stderr, "error running menu callback: %s\n", lua_tostring(L, -1)); - exit(1); + abort(); } } diff --git a/nageru/v210_converter.cpp b/nageru/v210_converter.cpp index d10920b..269126b 100644 --- a/nageru/v210_converter.cpp +++ b/nageru/v210_converter.cpp @@ -113,7 +113,7 @@ void main() GLchar error_log[1024] = {0}; glGetProgramInfoLog(shader.glsl_program_num, 1024, nullptr, error_log); fprintf(stderr, "Error linking program: %s\n", error_log); - exit(1); + abort(); } shader.max_cbcr_x_pos = glGetUniformLocation(shader.glsl_program_num, "max_cbcr_x"); diff --git a/nageru/x264_dynamic.cpp b/nageru/x264_dynamic.cpp index f8b63ce..3ed1811 100644 --- a/nageru/x264_dynamic.cpp +++ b/nageru/x264_dynamic.cpp @@ -63,7 +63,7 @@ X264Dynamic load_x264_for_bit_depth(unsigned depth) if (x264_dir.empty()) { fprintf(stderr, "ERROR: Requested %d-bit x264, but is not linked to such an x264, and could not find one.\n", depth); - exit(1); + abort(); } string x264_10b_string = x264_dir + "/x264-10bit" + x264_suffix; @@ -71,7 +71,7 @@ X264Dynamic load_x264_for_bit_depth(unsigned depth) if (x264_dlhandle == nullptr) { fprintf(stderr, "ERROR: Requested %d-bit x264, but is not linked to such an x264, and %s would not load.\n", depth, x264_10b_string.c_str()); - exit(1); + abort(); } dyn.handle = x264_dlhandle; diff --git a/nageru/x264_encoder.cpp b/nageru/x264_encoder.cpp index b98d6fd..d938393 100644 --- a/nageru/x264_encoder.cpp +++ b/nageru/x264_encoder.cpp @@ -232,7 +232,7 @@ void X264Encoder::init_x264() x264 = dyn.x264_encoder_open(¶m); if (x264 == nullptr) { fprintf(stderr, "ERROR: x264 initialization failed.\n"); - exit(1); + abort(); } if (global_flags.x264_speedcontrol) { diff --git a/shared/bin2h.cpp b/shared/bin2h.cpp index a396afe..80c2651 100644 --- a/shared/bin2h.cpp +++ b/shared/bin2h.cpp @@ -20,13 +20,13 @@ int main(int argc, char **argv) FILE *infp = fopen(argv[1], "rb"); if (infp == nullptr) { perror(argv[1]); - exit(1); + abort(); } FILE *outfp = fopen(argv[3], "w"); if (outfp == nullptr) { perror(argv[3]); - exit(1); + abort(); } fprintf(outfp, "// Generated by bin2h.cpp from %s. Do not edit by hand.\n", argv[1]); diff --git a/shared/context.cpp b/shared/context.cpp index 0b17bfa..6784571 100644 --- a/shared/context.cpp +++ b/shared/context.cpp @@ -24,7 +24,7 @@ QSurface *create_surface() surface->create(); if (!surface->isValid()) { fprintf(stderr, "ERROR: surface not valid!\n"); - exit(1); + abort(); } return surface; } @@ -36,7 +36,7 @@ QSurface *create_surface(const QSurfaceFormat &format) surface->create(); if (!surface->isValid()) { fprintf(stderr, "ERROR: surface not valid!\n"); - exit(1); + abort(); } return surface; } diff --git a/shared/midi_device.cpp b/shared/midi_device.cpp index 9d77e21..ab84fda 100644 --- a/shared/midi_device.cpp +++ b/shared/midi_device.cpp @@ -21,7 +21,7 @@ MIDIDevice::~MIDIDevice() const uint64_t one = 1; if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) { perror("write(should_quit_fd)"); - exit(1); + abort(); } midi_thread.join(); close(should_quit_fd); diff --git a/shared/mux.cpp b/shared/mux.cpp index e122e2b..adec53d 100644 --- a/shared/mux.cpp +++ b/shared/mux.cpp @@ -53,7 +53,7 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const AVStream *avstream_video = avformat_new_stream(avctx, nullptr); if (avstream_video == nullptr) { fprintf(stderr, "avformat_new_stream() failed\n"); - exit(1); + abort(); } avstream_video->time_base = AVRational{1, time_base}; avstream_video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; @@ -94,12 +94,12 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const AVStream *avstream_audio = avformat_new_stream(avctx, nullptr); if (avstream_audio == nullptr) { fprintf(stderr, "avformat_new_stream() failed\n"); - exit(1); + abort(); } avstream_audio->time_base = AVRational{1, time_base}; if (avcodec_parameters_copy(avstream_audio->codecpar, audio_codecpar) < 0) { fprintf(stderr, "avcodec_parameters_copy() failed\n"); - exit(1); + abort(); } streams.push_back(avstream_audio); } @@ -108,7 +108,7 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const AVStream *avstream_subtitles = avformat_new_stream(avctx, nullptr); if (avstream_subtitles == nullptr) { fprintf(stderr, "avformat_new_stream() failed\n"); - exit(1); + abort(); } avstream_subtitles->time_base = AVRational{1, time_base}; avstream_subtitles->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; @@ -125,7 +125,7 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const } if (avformat_write_header(avctx, &options) < 0) { fprintf(stderr, "avformat_write_header() failed\n"); - exit(1); + abort(); } for (MuxMetrics *metric : metrics) { metric->metric_written_bytes += avctx->pb->pos; @@ -166,7 +166,7 @@ void Mux::add_packet(const AVPacket &pkt, int64_t pts, int64_t dts, AVRational t av_init_packet(&pkt_copy); if (av_packet_ref(&pkt_copy, &pkt) < 0) { fprintf(stderr, "av_copy_packet() failed\n"); - exit(1); + abort(); } if (stream_index_override != -1) { pkt_copy.stream_index = stream_index_override; diff --git a/shared/read_file.cpp b/shared/read_file.cpp index 4084654..77a23fd 100644 --- a/shared/read_file.cpp +++ b/shared/read_file.cpp @@ -17,25 +17,25 @@ string read_file(const string &filename, const unsigned char *start, const size_ } perror(filename.c_str()); - exit(1); + abort(); } int ret = fseek(fp, 0, SEEK_END); if (ret == -1) { perror("fseek(SEEK_END)"); - exit(1); + abort(); } int disk_size = ftell(fp); if (disk_size == -1) { perror("ftell"); - exit(1); + abort(); } ret = fseek(fp, 0, SEEK_SET); if (ret == -1) { perror("fseek(SEEK_SET)"); - exit(1); + abort(); } string str; @@ -43,12 +43,12 @@ string read_file(const string &filename, const unsigned char *start, const size_ ret = fread(&str[0], disk_size, 1, fp); if (ret == -1) { perror("fread"); - exit(1); + abort(); } if (ret == 0) { fprintf(stderr, "Short read when trying to read %d bytes from %s\n", disk_size, filename.c_str()); - exit(1); + abort(); } fclose(fp); -- 2.39.2