Line |
Branch |
Exec |
Source |
1 |
|
|
#include "asar.h" |
2 |
|
|
#include <cassert> |
3 |
|
|
#include <cstdarg> |
4 |
|
|
|
5 |
|
|
#include "interface-shared.h" |
6 |
|
|
|
7 |
|
|
static int asar_num_errors = 0; |
8 |
|
|
|
9 |
|
|
struct asar_error_mapping |
10 |
|
|
{ |
11 |
|
|
asar_error_id errid; |
12 |
|
|
const char* name; |
13 |
|
|
const char* message; |
14 |
|
|
|
15 |
|
23250 |
asar_error_mapping(asar_error_id inerrid, const char* iname, const char* inmessage) |
16 |
|
23250 |
{ |
17 |
|
23250 |
++asar_num_errors; |
18 |
|
|
|
19 |
|
23250 |
errid = inerrid; |
20 |
|
23250 |
name = iname; |
21 |
|
23250 |
message = inmessage; |
22 |
|
|
|
23 |
|
|
// RPG Hacker: Sanity check. This makes sure that the order |
24 |
|
|
// of entries in asar_errors matches with the order of |
25 |
|
|
// constants in asar_error_id. This is important because |
26 |
|
|
// we access asar_errors as an array. |
27 |
|
|
// Would love to do this via static_assert(), but can't |
28 |
|
|
// think of a way to do so. |
29 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23250 times.
|
23250 |
assert(errid - error_id_start == asar_num_errors); |
30 |
|
23250 |
} |
31 |
|
|
}; |
32 |
|
|
|
33 |
|
|
// Keep in sync with asar_error_id. |
34 |
|
|
// Both, enum mapping and order, must match. |
35 |
|
|
#define ERR(name) error_id_ ## name, "E" #name |
36 |
|
|
static asar_error_mapping asar_errors[] = |
37 |
|
|
{ |
38 |
|
|
{ ERR(limit_reached), "Over %d errors detected. Aborting." }, |
39 |
|
|
{ ERR(werror), "One or more warnings was detected with werror on." }, |
40 |
|
|
|
41 |
|
|
{ ERR(buffer_too_small), "The given buffer is too small to contain the resulting ROM." }, |
42 |
|
|
{ ERR(params_null), "params passed to asar_patch_ex() is null." }, |
43 |
|
|
{ ERR(params_invalid_size), "Size of params passed to asar_patch_ex() is invalid." }, |
44 |
|
|
{ ERR(cmdl_define_invalid), "Invalid define name in %s: '%s'." }, |
45 |
|
|
{ ERR(cmdl_define_override), "%s '%s' overrides a previous define. Did you specify the same define twice?" }, |
46 |
|
|
{ ERR(create_rom_failed), "Couldn't create ROM." }, |
47 |
|
|
{ ERR(open_rom_failed), "Couldn't open ROM." }, |
48 |
|
|
{ ERR(open_rom_not_smw_extension), "Doesn't look like an SMW ROM. (Maybe its extension is wrong?)" }, |
49 |
|
|
{ ERR(open_rom_not_smw_header), "Doesn't look like an SMW ROM. (Maybe it's headered?)" }, |
50 |
|
|
{ ERR(stddefines_no_identifier), "stddefines.txt contains a line with a value, but no identifier." }, |
51 |
|
|
{ ERR(stddefine_after_closing_quote), "Broken std defines. (Something after closing quote)" }, |
52 |
|
|
|
53 |
|
|
{ ERR(failed_to_open_file), "Failed to open file '%s'." }, |
54 |
|
|
{ ERR(file_not_found), "File '%s' wasn't found." }, |
55 |
|
|
{ ERR(file_offset_out_of_bounds), "File offset %s out of bounds for file '%s'." }, |
56 |
|
|
|
57 |
|
|
{ ERR(mismatched_parentheses), "Mismatched parentheses." }, |
58 |
|
|
{ ERR(invalid_hex_value), "Invalid hex value." }, |
59 |
|
|
{ ERR(invalid_binary_value), "Invalid binary value." }, |
60 |
|
|
{ ERR(invalid_character), "Invalid character." }, |
61 |
|
|
{ ERR(string_literal_not_terminated), "String literal not terminated." }, |
62 |
|
|
{ ERR(malformed_function_call), "Malformed function call." }, |
63 |
|
|
{ ERR(invalid_number), "Invalid number." }, |
64 |
|
|
{ ERR(garbage_near_quoted_string), "Garbage near quoted string." }, |
65 |
|
|
{ ERR(mismatched_quotes), "Mismatched quotes." }, |
66 |
|
|
|
67 |
|
|
{ ERR(rom_too_short), "ROM is too short to have a title. (Expected '%s')" }, |
68 |
|
|
{ ERR(rom_title_incorrect), "ROM title is incorrect. Expected '%s', got '%s'." }, |
69 |
|
|
|
70 |
|
|
{ ERR(bank_border_crossed), "A bank border was crossed, SNES address $%06X." }, |
71 |
|
|
|
72 |
|
|
{ ERR(start_of_file), "This command may only be used at the start of a file." }, |
73 |
|
|
{ ERR(invalid_version_number), "Invalid version number." }, |
74 |
|
|
{ ERR(asar_too_old), "This version of Asar is too old for this patch." }, |
75 |
|
|
|
76 |
|
|
{ ERR(relative_branch_out_of_bounds), "Relative branch out of bounds. (Distance is %s)." }, |
77 |
|
|
{ ERR(snes_address_doesnt_map_to_rom), "SNES address %s doesn't map to ROM." }, |
78 |
|
|
{ ERR(snes_address_out_of_bounds), "SNES address %s out of bounds." }, |
79 |
|
|
{ ERR(invalid_tcall), "Invalid tcall." }, |
80 |
|
|
{ ERR(use_xplus), "Use (x+) instead." }, |
81 |
|
|
{ ERR(opcode_length_too_long), "Opcode length is too long." }, |
82 |
|
|
{ ERR(superfx_invalid_short_address), "Invalid short address parameter: $%s. (Must be even number and $0000-$01FE)" }, |
83 |
|
|
{ ERR(superfx_invalid_register), "Invalid register for opcode; valid range is %d-%d." }, |
84 |
|
|
{ ERR(invalid_opcode_length), "Invalid opcode length specification." }, |
85 |
|
|
{ ERR(invalid_mapper), "Invalid mapper." }, |
86 |
|
|
|
87 |
|
|
{ ERR(nan), "NaN encountered." }, |
88 |
|
|
{ ERR(division_by_zero), "Division by zero." }, |
89 |
|
|
{ ERR(modulo_by_zero), "Modulo by zero." }, |
90 |
|
|
{ ERR(unknown_operator), "Unknown operator." }, |
91 |
|
|
{ ERR(invalid_input), "Invalid input." }, |
92 |
|
|
|
93 |
|
|
{ ERR(invalid_function_name), "Invalid function name." }, |
94 |
|
|
{ ERR(function_not_found), "Function '%s' wasn't found." }, |
95 |
|
|
{ ERR(function_redefined), "Function '%s' redefined." }, |
96 |
|
|
{ ERR(broken_function_declaration), "Broken function declaration." }, |
97 |
|
|
{ ERR(wrong_num_parameters), "Wrong number of parameters to function." }, |
98 |
|
|
{ ERR(invalid_param_name), "Invalid parameter name." }, |
99 |
|
|
|
100 |
|
|
{ ERR(invalid_label_name), "Invalid label name." }, |
101 |
|
|
{ ERR(label_not_found), "Label '%s' wasn't found." }, |
102 |
|
|
{ ERR(label_redefined), "Label '%s' redefined." }, |
103 |
|
|
{ ERR(broken_label_definition), "Broken label definition." }, |
104 |
|
|
{ ERR(label_cross_assignment), "Setting labels to other non-static labels is not valid." }, |
105 |
|
|
{ ERR(macro_label_outside_of_macro), "Macro label outside of a macro." }, |
106 |
|
|
|
107 |
|
|
{ ERR(invalid_namespace_name), "Invalid namespace name." }, |
108 |
|
|
{ ERR(invalid_namespace_use), "Invalid use of namespace command." }, |
109 |
|
|
|
110 |
|
|
{ ERR(invalid_struct_name), "Invalid struct name." }, |
111 |
|
|
{ ERR(struct_not_found), "Struct '%s' wasn't found." }, |
112 |
|
|
{ ERR(struct_redefined), "Struct '%s' redefined." }, |
113 |
|
|
{ ERR(struct_invalid_parent_name), "Invalid parent name." }, |
114 |
|
|
{ ERR(invalid_label_missing_closer), "Invalid label name, missing array closer." }, |
115 |
|
|
{ ERR(invalid_subscript), "Invalid array subscript after first scope resolution." }, |
116 |
|
|
{ ERR(label_missing_parent), "This label has no parent." }, |
117 |
|
|
{ ERR(struct_without_endstruct), "struct without matching endstruct." }, |
118 |
|
|
{ ERR(nested_struct), "Can not nest structs." }, |
119 |
|
|
{ ERR(missing_struct_params), "Missing struct parameters." }, |
120 |
|
|
{ ERR(too_many_struct_params), "Too many struct parameters." }, |
121 |
|
|
{ ERR(missing_extends), "Missing extends keyword." }, |
122 |
|
|
{ ERR(invalid_endstruct_count), "Invalid endstruct parameter count." }, |
123 |
|
|
{ ERR(expected_align), "Expected align parameter." }, |
124 |
|
|
{ ERR(endstruct_without_struct), "endstruct can only be used in combination with struct." }, |
125 |
|
|
{ ERR(alignment_too_small), "Alignment must be >= 1." }, |
126 |
|
|
|
127 |
|
|
{ ERR(invalid_define_name), "Invalid define name." }, |
128 |
|
|
{ ERR(define_not_found), "Define '%s' wasn't found." }, |
129 |
|
|
{ ERR(broken_define_declaration), "Broken define declaration." }, |
130 |
|
|
{ ERR(overriding_builtin_define), "Trying to set define '%s', which is the name of a built-in define and thus can't be modified." }, |
131 |
|
|
{ ERR(define_label_math), "!Define #= Label is not allowed with non-static labels." }, |
132 |
|
|
{ ERR(mismatched_braces), "Mismatched braces." }, |
133 |
|
|
|
134 |
|
|
{ ERR(invalid_macro_name), "Invalid macro name." }, |
135 |
|
|
{ ERR(macro_not_found), "Macro '%s' wasn't found." }, |
136 |
|
|
{ ERR(macro_redefined), "Macro '%s' redefined. First defined at: %s:%d" }, |
137 |
|
|
{ ERR(broken_macro_declaration), "Broken macro declaration." }, |
138 |
|
|
{ ERR(invalid_macro_param_name), "Invalid macro parameter name." }, |
139 |
|
|
{ ERR(macro_param_not_found), "Macro parameter '%s' wasn't found.%s" }, |
140 |
|
|
{ ERR(macro_param_redefined), "Macro parameter '%s' redefined" }, |
141 |
|
|
{ ERR(broken_macro_usage), "Broken macro usage." }, |
142 |
|
|
{ ERR(macro_wrong_num_params), "Wrong number of parameters to macro." }, |
143 |
|
|
{ ERR(misplaced_endmacro), "Misplaced endmacro." }, |
144 |
|
|
{ ERR(unclosed_macro), "Unclosed macro: '%s'." }, |
145 |
|
|
|
146 |
|
|
{ ERR(label_in_conditional), "Non-static label in %s command." }, |
147 |
|
|
{ ERR(misplaced_elseif), "Misplaced elseif." }, |
148 |
|
|
{ ERR(elseif_in_while), "Can't use elseif in a while loop." }, |
149 |
|
|
{ ERR(misplaced_endif), "Misplaced endif." }, |
150 |
|
|
{ ERR(misplaced_else), "Misplaced else." }, |
151 |
|
|
{ ERR(else_in_while_loop), "Can't use else in a while loop." }, |
152 |
|
|
{ ERR(unclosed_if), "Unclosed if statement." }, |
153 |
|
|
|
154 |
|
|
{ ERR(unknown_command), "Unknown command." }, |
155 |
|
|
|
156 |
|
|
{ ERR(broken_incbin), "Broken incbin command." }, |
157 |
|
|
{ ERR(recursion_limit), "Recursion limit reached." }, |
158 |
|
|
{ ERR(cant_be_main_file), "This file may not be used as the main file.%s" }, |
159 |
|
|
{ ERR(no_labels_here), "Can't use non-static labels here." }, |
160 |
|
|
|
161 |
|
|
{ ERR(invalid_freespace_request), "Invalid freespace request." }, |
162 |
|
|
{ ERR(static_freespace_autoclean), "A static freespace must be targeted by at least one autoclean." }, |
163 |
|
|
{ ERR(static_freespace_growing), "A static freespace may not grow." }, |
164 |
|
|
{ ERR(no_freespace_in_mapped_banks), "No freespace found in the mapped banks. (Requested size: %s)" }, |
165 |
|
|
{ ERR(no_freespace), "No freespace found. (Requested size: %s)" }, |
166 |
|
|
|
167 |
|
|
{ ERR(prot_not_at_freespace_start), "PROT must be used at the start of a freespace block." }, |
168 |
|
|
{ ERR(prot_too_many_entries), "Too many entries to PROT." }, |
169 |
|
|
|
170 |
|
|
{ ERR(autoclean_in_freespace), "autoclean used in freespace." }, |
171 |
|
|
{ ERR(autoclean_label_at_freespace_end), "Don't autoclean a label at the end of a freespace block, you'll remove some stuff you're not supposed to remove." }, |
172 |
|
|
{ ERR(broken_autoclean), "Broken autoclean command." }, |
173 |
|
|
|
174 |
|
|
{ ERR(pulltable_without_table), "Using pulltable when there is no table on the stack yet." }, |
175 |
|
|
|
176 |
|
|
{ ERR(pad_in_freespace), "pad does not make sense in a freespaced code." }, |
177 |
|
|
|
178 |
|
|
{ ERR(org_label_forward), "org Label is only valid for labels earlier in the patch." }, |
179 |
|
|
|
180 |
|
|
{ ERR(base_label_invalid), "base Label is not valid." }, |
181 |
|
|
|
182 |
|
|
{ ERR(pushpc_without_pullpc), "pushpc without matching pullpc." }, |
183 |
|
|
{ ERR(pullpc_without_pushpc), "pullpc without matching pushpc." }, |
184 |
|
|
{ ERR(pullpc_different_arch), "pullpc in another architecture than the pushpc." }, |
185 |
|
|
{ ERR(pullbase_without_pushbase), "pullbase without matching pushbase." }, |
186 |
|
|
|
187 |
|
|
{ ERR(invalid_check), "Invalid check command." }, |
188 |
|
|
|
189 |
|
|
{ ERR(assertion_failed), "Assertion failed%s" }, |
190 |
|
|
|
191 |
|
|
{ ERR(error_command), "error command%s" }, |
192 |
|
|
|
193 |
|
|
{ ERR(invalid_print_function_syntax), "Invalid printable string syntax." }, |
194 |
|
|
{ ERR(unknown_variable), "Unknown variable." }, |
195 |
|
|
|
196 |
|
|
{ ERR(pushwarnings_without_pullwarnings), "warnings push without matching warnings pull." }, |
197 |
|
|
{ ERR(pullwarnings_without_pushwarnings), "warnings pull without matching warnings push." }, |
198 |
|
|
|
199 |
|
|
{ ERR(failed_to_open_file_access_denied), "Failed to open file '%s'. Access denied." }, |
200 |
|
|
{ ERR(failed_to_open_not_regular_file), "Failed to open file '%s'. Not a regular file (did you try to use a directory?)" }, |
201 |
|
|
|
202 |
|
|
{ ERR(bad_dp_base), "The dp base should be page aligned (i.e. a multiple of 256)"}, |
203 |
|
|
{ ERR(bad_dp_optimize), "Bad dp optimize value %s, expected: [none, ram, always]"}, |
204 |
|
|
{ ERR(bad_address_optimize), "Bad dp optimize value %s, expected: [default, ram, mirrors]"}, |
205 |
|
|
{ ERR(bad_optimize), "Bad optimize value %s, expected: [dp, address]"}, |
206 |
|
|
|
207 |
|
|
{ ERR(require_parameter), "Missing required function parameter"}, |
208 |
|
|
{ ERR(expected_parameter), "Not enough parameters in calling of function %s"}, |
209 |
|
|
{ ERR(unexpected_parameter), "Too many parameters in calling of function %s"}, |
210 |
|
|
{ ERR(duplicate_param_name), "Duplicated parameter name: %s in creation of function %s"}, |
211 |
|
|
|
212 |
|
|
{ ERR(invalid_alignment), "Invalid alignment. Expected a power of 2." }, |
213 |
|
|
{ ERR(alignment_too_big), "Requested alignment too large." }, |
214 |
|
|
|
215 |
|
|
{ ERR(negative_shift), "Bitshift amount is negative." }, |
216 |
|
|
|
217 |
|
|
{ ERR(macro_not_varadic), "Invalid use of %s, active macro is not variadic." }, |
218 |
|
|
{ ERR(vararg_sizeof_nomacro), "Invalid use of sizeof(...), no active macro." }, |
219 |
|
|
{ ERR(macro_wrong_min_params), "Variadic macro call with too few parameters" }, |
220 |
|
|
{ ERR(vararg_out_of_bounds), "Variadic macro parameter requested is out of bounds." }, |
221 |
|
|
{ ERR(vararg_must_be_last), "Variadic macro parameter must be the last parameter." }, |
222 |
|
|
{ ERR(invalid_global_label), "Global label definition contains an invalid label [%s]."}, |
223 |
|
|
|
224 |
|
|
{ ERR(spc700_addr_out_of_range), "Address %s out of range for instruction, valid range is 0000-1FFF" }, |
225 |
|
|
{ ERR(label_ambiguous), "Label (%s) location is ambiguous due to straddling optimization border." }, |
226 |
|
|
|
227 |
|
|
{ ERR(feature_unavaliable_in_spcblock), "This feature may not be used while an spcblock is active" }, |
228 |
|
|
{ ERR(endspcblock_without_spcblock), "Use of endspcblock without matching spcblock" }, |
229 |
|
|
{ ERR(missing_endspcblock), "Use of endspcblock without matching spcblock" }, |
230 |
|
|
{ ERR(spcblock_inside_struct), "Can not start an spcblock while a struct is still open" }, |
231 |
|
|
{ ERR(spcblock_too_few_args), "Too few args passed to spcblock" }, |
232 |
|
|
{ ERR(spcblock_too_many_args), "Too many args passed to spcblock" }, |
233 |
|
|
{ ERR(unknown_spcblock_type), "Unknown spcblock format" }, |
234 |
|
|
{ ERR(custom_spcblock_missing_macro), "Custom spcblock types must refer to a valid macro" }, |
235 |
|
|
{ ERR(spcblock_macro_doesnt_exist), "Macro specified to custom spcblock was not found"}, |
236 |
|
|
{ ERR(extra_spcblock_arg_for_type), "Only custom spcblock type takes a fourth argument" }, |
237 |
|
|
{ ERR(spcblock_macro_must_be_varadic), "Custom spcblock macros must be variadic" }, |
238 |
|
|
{ ERR(spcblock_macro_invalid_static_args), "Custom spcblock macros must have three static arguments" }, |
239 |
|
|
{ ERR(spcblock_custom_types_incomplete), "Custom spcblock types are not yet supported. One day." }, |
240 |
|
|
{ ERR(invalid_endspcblock_arg), "Invalid argument to endspcblock: \"%s\"" }, |
241 |
|
|
{ ERR(unknown_endspcblock_format), "Unsupported endspcblock format. Currently supported formats are \"endspcblock\" and \"endspcblock execute [label]\"" }, |
242 |
|
|
{ ERR(internal_error), "An internal error occured (%s). This is a bug in Asar, please report it at https://github.com/RPGHacker/asar/issues, along with a patch that reproduces it if possible." }, |
243 |
|
|
|
244 |
|
|
{ ERR(pushns_without_pullns), "pushns without matching pullns." }, |
245 |
|
|
{ ERR(pullns_without_pushns), "pullns without matching pushns." }, |
246 |
|
|
|
247 |
|
|
{ ERR(label_forward), "The use of forward labels is not allowed in this context." }, |
248 |
|
|
{ ERR(undefined_char), "'%s' is not defined in the character table" }, |
249 |
|
|
|
250 |
|
|
{ ERR(invalid_utf8), "Invalid text encoding detected. Asar expects UTF-8-encoded text. Please re-save this file in a text editor of choice using UTF-8 encoding." }, |
251 |
|
|
{ ERR(cmdl_utf16_to_utf8_failed), "UTF-16 to UTF-8 string conversion failed: %s." }, |
252 |
|
|
|
253 |
|
|
{ ERR(broken_command), "Broken %s command. %s" }, |
254 |
|
|
|
255 |
|
|
{ ERR(oob), "Operation out of bounds: Requested index %d for object of size %d" }, |
256 |
|
|
|
257 |
|
|
{ ERR(unclosed_vararg), "Variadic macro parameter wasn't closed properly." }, |
258 |
|
|
{ ERR(invalid_vararg), "Trying to use variadic macro parameter syntax to resolve a non variadic argument." }, |
259 |
|
|
|
260 |
|
|
{ ERR(invalid_depth_resolve), "Invalid %s resolution depth: Trying to backwards-resolve a %s using %i '^', but current scope only supports up to %i '^'." }, |
261 |
|
|
|
262 |
|
|
{ ERR(platform_paths), "Platform-specific paths aren'supported. Please use platform-independent paths (use / instead of \\)." }, |
263 |
|
|
|
264 |
|
|
{ ERR(bad_single_line_for), "Single-line for loop not allowed here." }, |
265 |
|
|
{ ERR(broken_for_loop), "Broken for loop command: %s" }, |
266 |
|
|
|
267 |
|
|
{ ERR(missing_org), "Missing org or freespace command." }, |
268 |
|
|
|
269 |
|
|
{ ERR(unclosed_block_comment), "Unclosed block comment." }, |
270 |
|
|
|
271 |
|
|
{ ERR(bad_addr_mode), "This addressing mode is not valid for this instruction." }, |
272 |
|
|
{ ERR(bad_access_width), "This addressing mode can accept %s arguments, but the provided argument is %d-bit." }, |
273 |
|
|
{ ERR(label_before_if), "Labels are not allowed before \"%s\" commands. Suggestion: move the label to a separate line." }, |
274 |
|
|
}; |
275 |
|
|
// RPG Hacker: Sanity check. This makes sure that the element count of asar_error |
276 |
|
|
// matches with the number of constants in asar_error_id. This is important, because |
277 |
|
|
// we are going to access asar_warnings as an array. |
278 |
|
|
static_assert(sizeof(asar_errors) / sizeof(asar_errors[0]) == error_id_count, "asar_errors and asar_error_id are not in sync"); |
279 |
|
|
|
280 |
|
|
template<typename t> |
281 |
|
2690 |
void asar_error_template(asar_error_id errid, int whichpass, const char* message) |
282 |
|
|
{ |
283 |
|
|
try |
284 |
|
|
{ |
285 |
1/2
✓ Branch 0 taken 1345 times.
✗ Branch 1 not taken.
|
2690 |
error_interface((int)errid, whichpass, message); |
286 |
|
|
t err; |
287 |
|
2690 |
throw err; |
288 |
|
|
} |
289 |
2/2
✓ Branch 0 taken 622 times.
✓ Branch 1 taken 108 times.
|
1460 |
catch (errnull&) {} |
290 |
|
216 |
} |
291 |
|
|
|
292 |
|
|
#if !defined(__clang__) |
293 |
|
|
void(*shutupgcc1)(asar_error_id, int, const char*) = asar_error_template<errnull>; |
294 |
|
|
void(*shutupgcc2)(asar_error_id, int, const char*) = asar_error_template<errblock>; |
295 |
|
|
void(*shutupgcc3)(asar_error_id, int, const char*) = asar_error_template<errline>; |
296 |
|
|
void(*shutupgcc4)(asar_error_id, int, const char*) = asar_error_template<errfatal>; |
297 |
|
|
#endif |
298 |
|
|
|
299 |
|
1345 |
void asar_throw_error(int whichpass, asar_error_type type, asar_error_id errid, ...) |
300 |
|
|
{ |
301 |
2/4
✓ Branch 0 taken 676 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✗ Branch 3 not taken.
|
676 |
assert(errid > error_id_start && errid < error_id_end); |
302 |
|
|
|
303 |
|
1345 |
const asar_error_mapping& error = asar_errors[errid - error_id_start - 1]; |
304 |
|
|
|
305 |
|
|
char error_buffer[1024]; |
306 |
|
|
va_list args; |
307 |
|
1345 |
va_start(args, errid); |
308 |
|
|
|
309 |
|
|
#if defined(__clang__) |
310 |
|
|
# pragma clang diagnostic push |
311 |
|
|
// "format string is not a literal". |
312 |
|
|
// The pointer we're passing here should always point to a string literal, |
313 |
|
|
// thus, I think, we can safely ignore this here. |
314 |
|
|
# pragma clang diagnostic ignored "-Wformat-nonliteral" |
315 |
|
|
#endif |
316 |
|
|
|
317 |
|
1345 |
vsnprintf(error_buffer, sizeof(error_buffer), error.message, args); |
318 |
|
|
|
319 |
|
|
#if defined(__clang__) |
320 |
|
|
# pragma clang diagnostic pop |
321 |
|
|
#endif |
322 |
|
|
|
323 |
|
1345 |
va_end(args); |
324 |
|
|
|
325 |
4/4
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 1105 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 24 times.
|
1345 |
switch (type) |
326 |
|
|
{ |
327 |
|
108 |
case error_type_null: |
328 |
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
108 |
asar_error_template<errnull>(errid, whichpass, error_buffer); |
329 |
|
54 |
break; |
330 |
|
1105 |
case error_type_block: |
331 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
|
1105 |
asar_error_template<errblock>(errid, whichpass, error_buffer); |
332 |
|
✗ |
break; |
333 |
|
108 |
case error_type_line: |
334 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
|
108 |
asar_error_template<errline>(errid, whichpass, error_buffer); |
335 |
|
✗ |
break; |
336 |
|
24 |
case error_type_fatal: |
337 |
|
|
default: |
338 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
24 |
asar_error_template<errfatal>(errid, whichpass, error_buffer); |
339 |
|
✗ |
break; |
340 |
|
|
} |
341 |
|
108 |
} |
342 |
|
|
|
343 |
|
954 |
const char* get_error_name(asar_error_id errid) |
344 |
|
|
{ |
345 |
2/4
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 479 times.
✗ Branch 3 not taken.
|
479 |
assert(errid > error_id_start && errid < error_id_end); |
346 |
|
|
|
347 |
|
954 |
const asar_error_mapping& error = asar_errors[errid - error_id_start - 1]; |
348 |
|
|
|
349 |
|
954 |
return error.name; |
350 |
|
|
} |
351 |
|
|
|