Line | Branch | Exec | Source |
---|---|---|---|
1 | /*********************************************************************************/ | ||
2 | /* Copyright 2009-2021 Barcelona Supercomputing Center */ | ||
3 | /* */ | ||
4 | /* This file is part of the DLB library. */ | ||
5 | /* */ | ||
6 | /* DLB is free software: you can redistribute it and/or modify */ | ||
7 | /* it under the terms of the GNU Lesser General Public License as published by */ | ||
8 | /* the Free Software Foundation, either version 3 of the License, or */ | ||
9 | /* (at your option) any later version. */ | ||
10 | /* */ | ||
11 | /* DLB is distributed in the hope that it will be useful, */ | ||
12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | ||
14 | /* GNU Lesser General Public License for more details. */ | ||
15 | /* */ | ||
16 | /* You should have received a copy of the GNU Lesser General Public License */ | ||
17 | /* along with DLB. If not, see <https://www.gnu.org/licenses/>. */ | ||
18 | /*********************************************************************************/ | ||
19 | |||
20 | #include "support/error.h" | ||
21 | |||
22 | #include "apis/dlb_errors.h" | ||
23 | #include "support/debug.h" | ||
24 | |||
25 | static const char* error_msg[] = { | ||
26 | "DLB_NOUPDT (2): The requested operation does not need any action", | ||
27 | "DLB_NOTED (1): The operation cannot be performed now, but it has been attended", | ||
28 | "DLB_SUCCESS (0): Success", | ||
29 | "DLB_ERR_UNKNOWN (-1): Unknown error", | ||
30 | "DLB_ERR_NOINIT (-2): DLB has not been initialized", | ||
31 | "DLB_ERR_INIT (-3): DLB is already initialized", | ||
32 | "DLB_ERR_DISBLD (-4): DLB is disabled", | ||
33 | "DLB_ERR_NOSHMEM (-5): DLB cannot find a shared memory", | ||
34 | "DLB_ERR_NOPROC (-6): DLB cannot find the requested process", | ||
35 | "DLB_ERR_PDIRTY (-7): DLB cannot update the target process, another operation still in process", | ||
36 | "DLB_ERR_PERM (-8): DLB cannot acquire the requested resource", | ||
37 | "DLB_ERR_TIMEOUT (-9): The operation has timed out", | ||
38 | "DLB_ERR_NOCBK (-10): The callback is not defined and cannot be invoked", | ||
39 | "DLB_ERR_NOENT (-11): The entry does not exist", | ||
40 | "DLB_ERR_NOCOMP (-12): The operation is not compatible with the configured DLB options", | ||
41 | "DLB_ERR_REQST (-13): DLB cannot take more requests for a specific resource", | ||
42 | "DLB_ERR_NOMEM (-14): DLB cannot allocate more processes into the shared memory", | ||
43 | "DLB_ERR_NOPOL (-15): The operation is not defined in the current policy", | ||
44 | "DLB_ERR_NOTALP (-16): TALP is not initialized", | ||
45 | "DLB_ERR_NOTALP (-17): LeWI is not initialized" | ||
46 | }; | ||
47 | |||
48 | 25 | const char* error_get_str(int errnum) { | |
49 |
4/4✓ Branch 0 taken 23 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 21 times.
|
25 | if (errnum >= _DLB_ERROR_UPPER_BOUND || errnum <= _DLB_ERROR_LOWER_BOUND) { |
50 | 4 | return "unknown errnum"; | |
51 | } | ||
52 | 21 | return error_msg[-errnum + _DLB_ERROR_UPPER_BOUND - 1]; | |
53 | } | ||
54 | |||
55 | /* Only for testing purposes */ | ||
56 | 1 | void error_check_num_messages(void) { | |
57 | 1 | int num_errors = _DLB_ERROR_UPPER_BOUND - _DLB_ERROR_LOWER_BOUND - 1; | |
58 | 1 | int num_error_msgs = sizeof(error_msg)/sizeof(error_msg[0]); | |
59 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | fatal_cond(num_errors != num_error_msgs, |
60 | "Number of errors: %d. Number of error messages: %d", | ||
61 | num_errors, | ||
62 | num_error_msgs); | ||
63 | 1 | } | |
64 |