1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-07-24 01:29:00 +00:00

Use log_crit() instead of log_critical()

This change also removes the former log_critical and log_error macros.
This commit is contained in:
Peter Evans 2018-03-29 21:45:25 -05:00
parent 7ca099d0d0
commit d2047457e9
11 changed files with 41 additions and 44 deletions

View File

@ -28,9 +28,6 @@ extern void log_write(int, const char *, ...);
* Here we have a couple of convenience macros that abstracts the log
* level number.
*/
#define log_critical(...) log_write(0, __VA_ARGS__)
#define log_error(...) log_write(0, __VA_ARGS__)
#define log_alert(...) log_write(LOG_ALERT, __VA_ARGS__)
#define log_crit(...) log_write(LOG_CRIT, __VA_ARGS__)
#define log_debug(...) log_write(LOG_DEBUG, __VA_ARGS__)

View File

@ -80,14 +80,14 @@ apple2_create(int width, int height)
mach->main = vm_segment_create(APPLE2_MEMORY_SIZE);
if (mach->main == NULL) {
log_critical("Could not initialize main RAM!");
log_crit("Could not initialize main RAM!");
apple2_free(mach);
return NULL;
}
mach->cpu = mos6502_create(mach->main, mach->main);
if (mach->cpu == NULL) {
log_critical("Could not create CPU!");
log_crit("Could not create CPU!");
apple2_free(mach);
return NULL;
}
@ -96,7 +96,7 @@ apple2_create(int width, int height)
mach->rom = vm_segment_create(APPLE2_ROM_SIZE);
mach->aux = vm_segment_create(APPLE2_MEMORY_SIZE);
if (mach->rom == NULL || mach->aux == NULL) {
log_critical("Could not initialize ROM / AUX!");
log_crit("Could not initialize ROM / AUX!");
apple2_free(mach);
return NULL;
}
@ -106,7 +106,7 @@ apple2_create(int width, int height)
apple2_mem_map(mach, mach->aux);
if (apple2_mem_init_sys_rom(mach) != OK) {
log_critical("Could not initialize apple2 ROM");
log_crit("Could not initialize apple2 ROM");
apple2_free(mach);
return NULL;
}
@ -117,7 +117,7 @@ apple2_create(int width, int height)
mach->drive2 = apple2_dd_create();
if (mach->drive1 == NULL || mach->drive2 == NULL) {
log_critical("Could not create disk drives!");
log_crit("Could not create disk drives!");
apple2_free(mach);
return NULL;
}
@ -128,7 +128,7 @@ apple2_create(int width, int height)
// Let's build our screen abstraction!
mach->screen = vm_screen_create();
if (mach->screen == NULL) {
log_critical("Screen creation failed!");
log_crit("Screen creation failed!");
apple2_free(mach);
return NULL;
}
@ -137,7 +137,7 @@ apple2_create(int width, int height)
// graphics.
err = vm_screen_add_window(mach->screen, width, height);
if (err != OK) {
log_critical("Window creation failed!");
log_crit("Window creation failed!");
apple2_free(mach);
return NULL;
}
@ -161,7 +161,7 @@ apple2_create(int width, int height)
0x7f);
if (mach->sysfont == NULL || mach->invfont == NULL) {
apple2_free(mach);
log_critical("Could not initialize apple2: bad font");
log_crit("Could not initialize apple2: bad font");
return NULL;
}
@ -239,7 +239,7 @@ apple2_boot(apple2 *mach)
if (stream) {
err = apple2_dd_insert(mach->drive1, stream, DD_DOS33);
if (err != OK) {
log_critical("Unable to insert disk1 into drive");
log_crit("Unable to insert disk1 into drive");
return err;
}
}
@ -248,7 +248,7 @@ apple2_boot(apple2 *mach)
if (stream) {
err = apple2_dd_insert(mach->drive2, stream, DD_DOS33);
if (err != OK) {
log_critical("Unable to insert disk2 into drive");
log_crit("Unable to insert disk2 into drive");
return err;
}
}

View File

@ -30,7 +30,7 @@ apple2_dd_create()
drive = malloc(sizeof(apple2dd));
if (drive == NULL) {
log_critical("Could not malloc space for apple2 disk drive");
log_crit("Could not malloc space for apple2 disk drive");
return NULL;
}
@ -120,18 +120,18 @@ apple2_dd_insert(apple2dd *drive, FILE *stream, int type)
int err;
if (stream == NULL) {
log_critical("File stream is null");
log_crit("File stream is null");
return ERR_BADFILE;
}
// How large is this data set? Let's get the stat info.
if (fstat(fileno(stream), &finfo)) {
log_critical("Couldn't inspect file stream: %s", strerror(errno));
log_crit("Couldn't inspect file stream: %s", strerror(errno));
return ERR_BADFILE;
}
if (finfo.st_size != _140K_) {
log_critical("Unexpected file format (file size = %d)", finfo.st_size);
log_crit("Unexpected file format (file size = %d)", finfo.st_size);
return ERR_BADFILE;
}
@ -145,7 +145,7 @@ apple2_dd_insert(apple2dd *drive, FILE *stream, int type)
// Read the data from the stream and write into the memory segment
err = vm_segment_fread(drive->image, stream, 0, finfo.st_size);
if (err != OK) {
log_critical("Could not read data into disk drive");
log_crit("Could not read data into disk drive");
return err;
}
@ -177,7 +177,7 @@ apple2_dd_encode(apple2dd *drive)
break;
default:
log_critical("Unknown image type");
log_crit("Unknown image type");
return ERR_INVALID;
}
@ -220,7 +220,7 @@ apple2_dd_decode(apple2dd *drive)
break;
default:
log_critical("Unknown image type");
log_crit("Unknown image type");
return ERR_INVALID;
}

View File

@ -110,7 +110,7 @@ apple2_mem_init_sys_rom(apple2 *mach)
err = vm_segment_copy_buf(mach->rom, sysrom,
0, 0, APPLE2_SYSROM_SIZE);
if (err != OK) {
log_critical("Could not copy apple2 system rom");
log_crit("Could not copy apple2 system rom");
return ERR_BADFILE;
}
@ -118,7 +118,7 @@ apple2_mem_init_sys_rom(apple2 *mach)
APPLE2_SYSROM_SIZE, 0,
APPLE2_PERIPHERAL_SIZE);
if (err != OK) {
log_critical("Could not copy apple2 peripheral rom");
log_crit("Could not copy apple2 peripheral rom");
return ERR_BADFILE;
}

View File

@ -164,7 +164,7 @@ mos6502_create(vm_segment *rmem, vm_segment *wmem)
cpu = malloc(sizeof(mos6502));
if (cpu == NULL) {
log_critical("Not enough memory to allocate mos6502");
log_crit("Not enough memory to allocate mos6502");
exit(1);
}

View File

@ -17,7 +17,7 @@
*/
DEFINE_INST(bad)
{
log_critical("Invalid instruction: %2x @ %4x",
log_crit("Invalid instruction: %2x @ %4x",
mos6502_get(cpu, cpu->PC), cpu->PC);
exit(1);
}

View File

@ -49,7 +49,7 @@ objstore_init()
// If the copy didn't work out somehow...
if (!objstore_ready()) {
log_critical("Object store initialization failed with bad data");
log_crit("Object store initialization failed with bad data");
return ERR_BADFILE;
}

View File

@ -39,7 +39,7 @@ vm_bitfont_create(vm_screen *screen,
// function.
rw = SDL_RWFromConstMem(fontdata, fontsize);
if (rw == NULL) {
log_critical("Failed to create RWops from font data: %s",
log_crit("Failed to create RWops from font data: %s",
SDL_GetError());
return NULL;
}
@ -48,14 +48,14 @@ vm_bitfont_create(vm_screen *screen,
// of getting a bitmap from memory rather than loading from a file.
surf = SDL_LoadBMP_RW(rw, 0);
if (surf == NULL) {
log_critical("Failed to create bitmap from RWops: %s",
log_crit("Failed to create bitmap from RWops: %s",
SDL_GetError());
return NULL;
}
font = malloc(sizeof(vm_bitfont));
if (font == NULL) {
log_critical("Could not allocate memory for font");
log_crit("Could not allocate memory for font");
return NULL;
}
@ -131,7 +131,7 @@ vm_bitfont_render(vm_bitfont *font,
if (SDL_RenderCopy(screen->render, font->texture,
&src_rect, &dest_rect) < 0
) {
log_critical("Failed to render glyph: %s", SDL_GetError());
log_crit("Failed to render glyph: %s", SDL_GetError());
return ERR_GFXOP;
}
}

View File

@ -23,7 +23,7 @@ vm_reflect_create()
ref = malloc(sizeof(vm_reflect));
if (ref == NULL) {
log_critical("Could not allocate memory for vm_reflect");
log_crit("Could not allocate memory for vm_reflect");
return NULL;
}

View File

@ -28,7 +28,7 @@ int
vm_screen_init()
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
log_critical("Could not initialize video: %s", SDL_GetError());
log_crit("Could not initialize video: %s", SDL_GetError());
return ERR_GFXINIT;
}
@ -59,7 +59,7 @@ vm_screen_create()
screen = (vm_screen *)malloc(sizeof(vm_screen));
if (screen == NULL) {
log_critical("Failed to allocate vm_screen");
log_crit("Failed to allocate vm_screen");
exit(1);
}
@ -114,7 +114,7 @@ vm_screen_add_window(vm_screen *screen, int width, int height)
width, height, 0, &screen->window, &screen->render);
if (screen->window == NULL || screen->render == NULL) {
log_critical("Could not create window: %s", SDL_GetError());
log_crit("Could not create window: %s", SDL_GetError());
return ERR_GFXINIT;
}
#endif

View File

@ -41,14 +41,14 @@ vm_segment_create(size_t size)
// Ack! We couldn't get the memory we wanted. Let's bail.
if (segment == NULL) {
log_critical("Couldn't allocate enough space for vm_segment");
log_crit("Couldn't allocate enough space for vm_segment");
return NULL;
}
segment->memory = malloc(sizeof(vm_8bit) * size);
if (segment->memory == NULL) {
free(segment);
log_critical("Couldn't allocate enough space for vm_segment");
log_crit("Couldn't allocate enough space for vm_segment");
return NULL;
}
@ -58,14 +58,14 @@ vm_segment_create(size_t size)
segment->read_table = malloc(sizeof(vm_segment_read_fn) * size);
if (segment->read_table == NULL) {
log_critical("Couldn't allocate enough space for segment read_table");
log_crit("Couldn't allocate enough space for segment read_table");
vm_segment_free(segment);
return NULL;
}
segment->write_table = malloc(sizeof(vm_segment_write_fn) * size);
if (segment->write_table == NULL) {
log_critical("Couldn't allocate enough space for segment write_table");
log_crit("Couldn't allocate enough space for segment write_table");
vm_segment_free(segment);
return NULL;
}
@ -103,7 +103,7 @@ vm_segment_set(vm_segment *segment, size_t index, vm_8bit value)
{
// Some bounds checking.
if (!vm_segment_bounds_check(segment, index)) {
log_critical(
log_crit(
"Attempt to set segment index (%d) greater than bounds (%d)",
index,
segment->size);
@ -130,7 +130,7 @@ vm_8bit
vm_segment_get(vm_segment *segment, size_t index)
{
if (!vm_segment_bounds_check(segment, index)) {
log_critical(
log_crit(
"Attempt to get segment index (%d) greater than bounds (%d)",
index,
segment->size);
@ -178,7 +178,7 @@ vm_segment_copy(vm_segment *dest,
size_t length)
{
if (src_index + length > src->size) {
log_critical(
log_crit(
"Attempt to copy beyond bounds of vm_segment (%d + %d >= %d)",
src_index,
length,
@ -188,7 +188,7 @@ vm_segment_copy(vm_segment *dest,
}
if (dest_index + length > dest->size) {
log_critical(
log_crit(
"Attempt to copy beyond bounds of vm_segment (%d + %d >= %d)",
dest_index,
length,
@ -216,7 +216,7 @@ vm_segment_copy_buf(vm_segment *dest, const vm_8bit *src,
size_t destoff, size_t srcoff, size_t len)
{
if (destoff + len > dest->size) {
log_critical("Attempt to copy buffer out of bounds (%d + %d >= %d)",
log_crit("Attempt to copy buffer out of bounds (%d + %d >= %d)",
destoff, len, dest->size);
return ERR_OOB;
}
@ -280,7 +280,7 @@ vm_segment_fread(vm_segment *segment, FILE *stream, size_t offset, size_t len)
// count on just that to tell us something went wrong (especially if
// len was not a valid length for the file to begin with).
if (ferror(stream)) {
log_critical("Could not read file stream: %s\n", strerror(errno));
log_crit("Could not read file stream: %s\n", strerror(errno));
return ERR_BADFILE;
}
@ -298,7 +298,7 @@ vm_segment_fwrite(vm_segment *seg, FILE *stream, size_t off, size_t len)
fwrite(seg->memory + off, sizeof(vm_8bit), len, stream);
if (ferror(stream)) {
log_critical("Could not write to the file stream: %s", strerror(errno));
log_crit("Could not write to the file stream: %s", strerror(errno));
return ERR_BADFILE;
}