pacemaker  1.1.24-3850484742
Scalable High-Availability cluster resource manager
error.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012-2020 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 #ifndef CRM_ERROR__H
10 # define CRM_ERROR__H
11 # include <crm_config.h>
12 # include <assert.h>
13 
20 # define CRM_ASSERT(expr) do { \
21  if(__unlikely((expr) == FALSE)) { \
22  crm_abort(__FILE__, __FUNCTION__, __LINE__, #expr, TRUE, FALSE); \
23  abort(); /* Redundant but it makes analyzers like coverity and clang happy */ \
24  } \
25  } while(0)
26 
27 /*
28  * Function return codes
29  *
30  * Most Pacemaker API functions return an integer return code. There are two
31  * alternative interpretations. The legacy interpration is that the absolute
32  * value of the return code is either a system error number or a custom
33  * pcmk_err_* number. This is less than ideal because system error numbers are
34  * constrained only to the positive int range, so there's the possibility
35  * (though not noticed in the wild) that system errors and custom errors could
36  * collide. The new intepretation is that negative values are from the pcmk_rc_e
37  * enum, and positive values are system error numbers. Both use 0 for success.
38  *
39  * For system error codes, see:
40  * - /usr/include/asm-generic/errno.h
41  * - /usr/include/asm-generic/errno-base.h
42  */
43 
44 // Legacy custom return codes for Pacemaker API functions
45 # define pcmk_ok 0
46 # define PCMK_ERROR_OFFSET 190 /* Replacements on non-linux systems, see include/portability.h */
47 # define PCMK_CUSTOM_OFFSET 200 /* Purely custom codes */
48 # define pcmk_err_generic 201
49 # define pcmk_err_no_quorum 202
50 # define pcmk_err_schema_validation 203
51 # define pcmk_err_transform_failed 204
52 # define pcmk_err_old_data 205
53 # define pcmk_err_diff_failed 206
54 # define pcmk_err_diff_resync 207
55 # define pcmk_err_cib_modified 208
56 # define pcmk_err_cib_backup 209
57 # define pcmk_err_cib_save 210
58 # define pcmk_err_schema_unchanged 211
59 # define pcmk_err_cib_corrupt 212
60 # define pcmk_err_multiple 213
61 # define pcmk_err_node_unknown 214
62 # define pcmk_err_already 215
63 /* On HPPA 215 is ENOSYM (Unknown error 215), which hopefully never happens. */
64 #ifdef __hppa__
65 # define pcmk_err_bad_nvpair 250 /* 216 is ENOTSOCK */
66 # define pcmk_err_unknown_format 252 /* 217 is EDESTADDRREQ */
67 #else
68 # define pcmk_err_bad_nvpair 216
69 # define pcmk_err_unknown_format 217
70 #endif
71 # define pcmk_err_panic 255
72 
85 enum pcmk_rc_e {
86  /* When adding new values, use consecutively lower numbers, update the array
87  * in lib/common/logging.c and test with crm_error.
88  */
105  // Developers: Use a more specific code than pcmk_rc_error whenever possible
106  pcmk_rc_error = -1001,
107 
108  // Values -1 through -1000 reserved for caller use
109 
111 
112  // Positive values reserved for system error numbers
113 };
114 
115 const char *pcmk_rc_name(int rc);
116 const char *pcmk_rc_str(int rc);
117 int pcmk_rc2legacy(int rc);
118 int pcmk_legacy2rc(int legacy_rc);
119 const char *pcmk_strerror(int rc);
120 const char *pcmk_errorname(int rc);
121 const char *bz2_strerror(int rc);
122 
123 #endif
pcmk_rc_e
Return codes for Pacemaker API functions.
Definition: error.h:85
const char * pcmk_strerror(int rc)
Definition: logging.c:1017
int pcmk_legacy2rc(int legacy_rc)
Definition: logging.c:1363
const char * pcmk_rc_name(int rc)
Get a return code constant name as a string.
Definition: logging.c:1181
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition: logging.c:1335
const char * pcmk_errorname(int rc)
Definition: logging.c:992
const char * bz2_strerror(int rc)
Definition: logging.c:1390
int pcmk_rc2legacy(int rc)
Definition: logging.c:1351