mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Refactor error reporting to simplify BSD-style err (#949)
This commit is contained in:
@@ -17,11 +17,10 @@
|
||||
#include "link/section.h"
|
||||
#include "link/symbol.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "linkdefs.h"
|
||||
#include "opmath.h"
|
||||
|
||||
#include "extern/err.h"
|
||||
|
||||
/*
|
||||
* This is an "empty"-type stack. Apart from the actual values, we also remember
|
||||
* whether the value is a placeholder inserted for error recovery. This allows
|
||||
@@ -43,7 +42,7 @@ static void initRPNStack(void)
|
||||
stack.values = malloc(sizeof(*stack.values) * stack.capacity);
|
||||
stack.errorFlags = malloc(sizeof(*stack.errorFlags) * stack.capacity);
|
||||
if (!stack.values || !stack.errorFlags)
|
||||
err(1, "Failed to init RPN stack");
|
||||
err("Failed to init RPN stack");
|
||||
}
|
||||
|
||||
static void clearRPNStack(void)
|
||||
@@ -57,7 +56,7 @@ static void pushRPN(int32_t value, bool comesFromError)
|
||||
static const size_t increase_factor = 2;
|
||||
|
||||
if (stack.capacity > SIZE_MAX / increase_factor)
|
||||
errx(1, "Overflow in RPN stack resize");
|
||||
errx("Overflow in RPN stack resize");
|
||||
|
||||
stack.capacity *= increase_factor;
|
||||
stack.values =
|
||||
@@ -70,7 +69,7 @@ static void pushRPN(int32_t value, bool comesFromError)
|
||||
* the overflow check above. Hence the stringent check below.
|
||||
*/
|
||||
if (!stack.values || !stack.errorFlags || !stack.capacity)
|
||||
err(1, "Failed to resize RPN stack");
|
||||
err("Failed to resize RPN stack");
|
||||
}
|
||||
|
||||
stack.values[stack.size] = value;
|
||||
|
||||
Reference in New Issue
Block a user