Skip to content
Snippets Groups Projects
Commit d0d2f517 authored by Dmitry Simonenko's avatar Dmitry Simonenko
Browse files

error-injection: review fixes

parent 9ae06afc
No related branches found
No related tags found
No related merge requests found
......@@ -49,13 +49,15 @@ struct errinj errinjs[errinj_enum_MAX] = {
* @return error injection handle state on success, false on error.
*/
bool
errinj_state(int id)
errinj_get(int id)
{
assert(id >= 0 && id < errinj_enum_MAX);
return errinjs[id].state;
}
static struct errinj *errinj_match(char *name) {
static struct errinj *
errinj_lookup(char *name)
{
int i;
for (i = 0 ; i < errinj_enum_MAX ; i++) {
if (strcmp(errinjs[i].name, name) == 0)
......@@ -72,9 +74,9 @@ static struct errinj *errinj_match(char *name) {
* @return error injection handle state on success, false on error.
*/
bool
errinj_state_byname(char *name)
errinj_get_byname(char *name)
{
struct errinj *ei = errinj_match(name);
struct errinj *ei = errinj_lookup(name);
if (ei == NULL)
return false;
return ei->state;
......@@ -105,7 +107,7 @@ errinj_set(int id, bool state)
bool
errinj_set_byname(char *name, bool state)
{
struct errinj *ei = errinj_match(name);
struct errinj *ei = errinj_lookup(name);
if (ei == NULL)
return false;
ei->state = state;
......
......@@ -42,8 +42,8 @@ struct errinj {
ENUM0(errinj_enum, ERRINJ_LIST);
extern struct errinj errinjs[];
bool errinj_state(int id);
bool errinj_state_byname(char *name);
bool errinj_get(int id);
bool errinj_get_byname(char *name);
void errinj_set(int id, bool state);
bool errinj_set_byname(char *name, bool state);
......@@ -56,15 +56,9 @@ void errinj_info(struct tbuf *out);
#else
#define ERROR_INJECT(ID) \
do { \
if (errinj_state(ID) == true) \
if (errinj_get(ID) == true) \
tnt_raise(ErrorInjection, :#ID); \
} while (0)
#define ERROR_INJECT_BYNAME(NAME) \
do { \
if (errinj_state_byname(NAME) == true) \
tnt_raise(ErrorInjection, :NAME); \
} while (0)
#endif
#endif /* TATRANTOOL_ERRINJ_H_INCLUDED */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment