GCC Code Coverage Report


Directory: src/gate/
File: src/gate/results.c
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 10 61 16.4%
Functions: 1 2 50.0%
Branches: 8 52 15.4%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/results.h"
30 #include "gate/debugging.h"
31 #include "gate/strings.h"
32 #include "gate/platforms.h"
33
34 13 char const* gate_result_text(gate_result_t resultcode)
35 {
36
8/48
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 2 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
13 switch (resultcode)
37 {
38 case GATE_RESULT_OK: return "Succeeded";
39 case GATE_RESULT_OK_PARTIAL: return "Partial success";
40
41 case GATE_RESULT_ERROR: return "Error";
42 5 case GATE_RESULT_FAILED: return "Operation failed";
43 1 case GATE_RESULT_CANCELED: return "Operation canceled";
44 case GATE_RESULT_INVALIDARG: return "Invalid argument";
45 case GATE_RESULT_ACCESSDENIED: return "Access denied";
46 case GATE_RESULT_PERMISSIONDENIED: return "Permission denied";
47 case GATE_RESULT_NOTDEFINED: return "Not defined";
48 case GATE_RESULT_NOTAVAILABLE: return "Not available";
49 case GATE_RESULT_NOTIMPLEMENTED: return "Not implemented";
50 case GATE_RESULT_NOMATCH: return "No match";
51 1 case GATE_RESULT_NOTSUPPORTED: return "Not supported";
52 case GATE_RESULT_NOTREQUIRED: return "Not required";
53 case GATE_RESULT_NOTREADY: return "Not ready";
54 case GATE_RESULT_SECURITYBREACH: return "Security breach";
55 case GATE_RESULT_ALREADYEXISTS: return "Already exists";
56 1 case GATE_RESULT_INVALIDSTATE: return "Invalid state";
57
58 /* RESOURCE ACCESS ERRORS */
59 case GATE_RESULT_OUTOFMEMORY: return "Out of memory";
60 case GATE_RESULT_OUTOFRESOURCES: return "Out of resources";
61 case GATE_RESULT_OUTOFBOUNDS: return "Out of bounds";
62 case GATE_RESULT_NULLPOINTER: return "Null pointer";
63 case GATE_RESULT_BADCAST: return "Bad cast";
64 case GATE_RESULT_ARITHMETICERROR: return "Arithmetic error";
65 case GATE_RESULT_OVERFLOW: return "Overflow";
66 case GATE_RESULT_UNDERFLOW: return "Underflow";
67 case GATE_RESULT_LOCKED: return "Resource locked";
68 1 case GATE_RESULT_TIMEOUT: return "Timeout reached";
69 case GATE_RESULT_BADADDRESS: return "Bad address";
70 case GATE_RESULT_BLOCKED: return "Resource blocked";
71
72 /* EXECUTION ERRORS */
73 case GATE_RESULT_EXECUTIONFAILED: return "Execution failed";
74 case GATE_RESULT_EXECUTIONINTERRUPTED: return "Execution interrupted";
75 2 case GATE_RESULT_CRITICALERROR: return "Critical error";
76 1 case GATE_RESULT_UNKNOWNEXCEPTION: return "Unknown exception";
77
78 /* DATA ERRORS */
79 case GATE_RESULT_INVALIDHEADER: return "Invalid header";
80 case GATE_RESULT_INVALIDDATA: return "Invalid data";
81 1 case GATE_RESULT_INVALIDCONTENT: return "Invalid content";
82 case GATE_RESULT_INCORRECTSIZE: return "Incorrect size";
83 case GATE_RESULT_INCORRECTTYPE: return "Incorrect type";
84 case GATE_RESULT_ENDOFSTREAM: return "End of stream";
85 case GATE_RESULT_INVALIDINPUT: return "Invalid input";
86 case GATE_RESULT_INVALIDOUTPUT: return "Invalid output";
87 case GATE_RESULT_NODATA: return "No data";
88
89 case GATE_RESULT_APPLICATIONERROR: return "Application error";
90 case GATE_RESULT_LOGICALERROR: return "Logical error";
91 case GATE_RESULT_USERERROR: return "User error";
92
93 case GATE_RESULT_UNKNOWNERROR: return "Unknown error";
94 }
95 return NULL;
96 }
97
98
99 void gate_panic(gate_result_t resultcode, char const* message)
100 {
101 char const* messages[4];
102 gate_size_t message_len = gate_str_length(message);
103 gate_size_t messages_count;
104
105 messages[0] = gate_result_text(resultcode);
106 if (message_len > 0)
107 {
108 messages[1] = ": ";
109 messages[2] = message;
110 messages_count = 3;
111 }
112 else
113 {
114 messages_count = 1;
115 }
116
117 gate_debug_trace_messages(messages, messages_count);
118 gate_platform_exit(GATE_RESULT_TO_EXITCODE(resultcode));
119 }
120