diff --git a/core/admin.m b/core/admin.m index 4eaea8823a65b482d60a2f4d6c8434faaa09f8c6..62f58b46f83ff7253c019cfc7bad4e80ec9a7080 100644 --- a/core/admin.m +++ b/core/admin.m @@ -206,11 +206,11 @@ case 6: } goto st0; tr13: -#line 247 "core/admin.rl" +#line 246 "core/admin.rl" {slab_validate(); ok(out);} goto st135; tr20: -#line 235 "core/admin.rl" +#line 234 "core/admin.rl" {return 0;} goto st135; tr25: @@ -227,7 +227,7 @@ tr25: } goto st135; tr36: -#line 221 "core/admin.rl" +#line 220 "core/admin.rl" {strend = p;} #line 167 "core/admin.rl" { @@ -247,7 +247,7 @@ tr43: } goto st135; tr67: -#line 245 "core/admin.rl" +#line 244 "core/admin.rl" {coredump(60); ok(out);} goto st135; tr76: @@ -266,32 +266,30 @@ tr76: } goto st135; tr98: -#line 231 "core/admin.rl" +#line 230 "core/admin.rl" { state = false; } #line 194 "core/admin.rl" { strstart[strend-strstart] = '\0'; - bool ret = errinj_set_byname(strstart, state); - if (ret) { - ok(out); - } else { + if (errinj_set_byname(strstart, state)) { tbuf_printf(err, "can't find error injection '%s'", strstart); fail(out, err); + } else { + ok(out); } } goto st135; tr101: -#line 230 "core/admin.rl" +#line 229 "core/admin.rl" { state = true; } #line 194 "core/admin.rl" { strstart[strend-strstart] = '\0'; - bool ret = errinj_set_byname(strstart, state); - if (ret) { - ok(out); - } else { + if (errinj_set_byname(strstart, state)) { tbuf_printf(err, "can't find error injection '%s'", strstart); fail(out, err); + } else { + ok(out); } } goto st135; @@ -316,11 +314,11 @@ tr117: } goto st135; tr131: -#line 238 "core/admin.rl" +#line 237 "core/admin.rl" {start(out); fiber_info(out); end(out);} goto st135; tr137: -#line 237 "core/admin.rl" +#line 236 "core/admin.rl" {start(out); tarantool_info(out); end(out);} goto st135; tr146: @@ -332,29 +330,29 @@ tr146: } goto st135; tr152: -#line 241 "core/admin.rl" +#line 240 "core/admin.rl" {start(out); palloc_stat(out); end(out);} goto st135; tr160: -#line 240 "core/admin.rl" +#line 239 "core/admin.rl" {start(out); slab_stat(out); end(out);} goto st135; tr164: -#line 242 "core/admin.rl" +#line 241 "core/admin.rl" {start(out); stat_print(out);end(out);} goto st135; st135: if ( ++p == pe ) goto _test_eof135; case 135: -#line 351 "core/admin.m" +#line 349 "core/admin.m" goto st0; tr14: -#line 247 "core/admin.rl" +#line 246 "core/admin.rl" {slab_validate(); ok(out);} goto st7; tr21: -#line 235 "core/admin.rl" +#line 234 "core/admin.rl" {return 0;} goto st7; tr26: @@ -371,7 +369,7 @@ tr26: } goto st7; tr37: -#line 221 "core/admin.rl" +#line 220 "core/admin.rl" {strend = p;} #line 167 "core/admin.rl" { @@ -391,7 +389,7 @@ tr44: } goto st7; tr68: -#line 245 "core/admin.rl" +#line 244 "core/admin.rl" {coredump(60); ok(out);} goto st7; tr77: @@ -410,32 +408,30 @@ tr77: } goto st7; tr99: -#line 231 "core/admin.rl" +#line 230 "core/admin.rl" { state = false; } #line 194 "core/admin.rl" { strstart[strend-strstart] = '\0'; - bool ret = errinj_set_byname(strstart, state); - if (ret) { - ok(out); - } else { + if (errinj_set_byname(strstart, state)) { tbuf_printf(err, "can't find error injection '%s'", strstart); fail(out, err); + } else { + ok(out); } } goto st7; tr102: -#line 230 "core/admin.rl" +#line 229 "core/admin.rl" { state = true; } #line 194 "core/admin.rl" { strstart[strend-strstart] = '\0'; - bool ret = errinj_set_byname(strstart, state); - if (ret) { - ok(out); - } else { + if (errinj_set_byname(strstart, state)) { tbuf_printf(err, "can't find error injection '%s'", strstart); fail(out, err); + } else { + ok(out); } } goto st7; @@ -460,11 +456,11 @@ tr118: } goto st7; tr132: -#line 238 "core/admin.rl" +#line 237 "core/admin.rl" {start(out); fiber_info(out); end(out);} goto st7; tr138: -#line 237 "core/admin.rl" +#line 236 "core/admin.rl" {start(out); tarantool_info(out); end(out);} goto st7; tr147: @@ -476,22 +472,22 @@ tr147: } goto st7; tr153: -#line 241 "core/admin.rl" +#line 240 "core/admin.rl" {start(out); palloc_stat(out); end(out);} goto st7; tr161: -#line 240 "core/admin.rl" +#line 239 "core/admin.rl" {start(out); slab_stat(out); end(out);} goto st7; tr165: -#line 242 "core/admin.rl" +#line 241 "core/admin.rl" {start(out); stat_print(out);end(out);} goto st7; st7: if ( ++p == pe ) goto _test_eof7; case 7: -#line 495 "core/admin.m" +#line 491 "core/admin.m" if ( (*p) == 10 ) goto st135; goto st0; @@ -644,28 +640,28 @@ case 23: } goto tr33; tr33: -#line 221 "core/admin.rl" +#line 220 "core/admin.rl" {strstart = p;} goto st24; st24: if ( ++p == pe ) goto _test_eof24; case 24: -#line 655 "core/admin.m" +#line 651 "core/admin.m" switch( (*p) ) { case 10: goto tr36; case 13: goto tr37; } goto st24; tr34: -#line 221 "core/admin.rl" +#line 220 "core/admin.rl" {strstart = p;} goto st25; st25: if ( ++p == pe ) goto _test_eof25; case 25: -#line 669 "core/admin.m" +#line 665 "core/admin.m" switch( (*p) ) { case 10: goto tr36; case 13: goto tr37; @@ -1115,28 +1111,28 @@ case 73: goto tr91; goto st0; tr91: -#line 229 "core/admin.rl" +#line 228 "core/admin.rl" { strstart = p; } goto st74; st74: if ( ++p == pe ) goto _test_eof74; case 74: -#line 1126 "core/admin.m" +#line 1122 "core/admin.m" if ( (*p) == 32 ) goto tr92; if ( 33 <= (*p) && (*p) <= 126 ) goto st74; goto st0; tr92: -#line 229 "core/admin.rl" +#line 228 "core/admin.rl" { strend = p; } goto st75; st75: if ( ++p == pe ) goto _test_eof75; case 75: -#line 1140 "core/admin.m" +#line 1136 "core/admin.m" switch( (*p) ) { case 32: goto st75; case 111: goto st76; @@ -1828,7 +1824,7 @@ case 134: _out: {} } -#line 253 "core/admin.rl" +#line 252 "core/admin.rl" tbuf_ltrim(fiber->rbuf, (void *)pe - (void *)fiber->rbuf->data); diff --git a/core/admin.rl b/core/admin.rl index fa40935328b288408ae6df90ab3f3471dbfe109e..79925f7e46840432b7bc082557afc393ee89e1c8 100644 --- a/core/admin.rl +++ b/core/admin.rl @@ -193,12 +193,11 @@ admin_dispatch(lua_State *L) action set_injection { strstart[strend-strstart] = '\0'; - bool ret = errinj_set_byname(strstart, state); - if (ret) { - ok(out); - } else { + if (errinj_set_byname(strstart, state)) { tbuf_printf(err, "can't find error injection '%s'", strstart); fail(out, err); + } else { + ok(out); } } diff --git a/core/errinj.m b/core/errinj.m index 4206659ab26cbcd1cffacb5b535e185c2a789199..cb553e7d83d1ed43df5aff4997a02e280266f9a7 100644 --- a/core/errinj.m +++ b/core/errinj.m @@ -41,10 +41,10 @@ struct errinj errinjs[errinj_enum_MAX] = { ERRINJ_LIST(ERRINJ_MEMBER) }; -static struct errinj* +static struct errinj * errinj_lookup(char *name) { - int i; + int i; for (i = 0 ; i < errinj_enum_MAX ; i++) { if (strcmp(errinjs[i].name, name) == 0) return &errinjs[i]; @@ -57,7 +57,7 @@ errinj_lookup(char *name) * * @param id error injection id. * - * @return error injection handle state on success, false on error. + * @return error injection handle state. */ bool errinj_get(int id) @@ -66,22 +66,6 @@ errinj_get(int id) return errinjs[id].state; } -/** - * Get state of the error injection handle by name. - * - * @param name error injection name. - * - * @return error injection handle state on success, false on error. - */ -bool -errinj_get_byname(char *name) -{ - struct errinj *ei = errinj_lookup(name); - if (ei == NULL) - return false; - return ei->state; -} - /** * Set state of the error injection handle by id. * @@ -102,16 +86,16 @@ errinj_set(int id, bool state) * @param name error injection name. * @param state error injection handle state. * - * @return true on success, false on error. + * @return 0 on success, -1 if injection was not found. */ -bool +int errinj_set_byname(char *name, bool state) { struct errinj *ei = errinj_lookup(name); if (ei == NULL) - return false; + return -1; ei->state = state; - return true; + return 0; } /** diff --git a/include/errinj.h b/include/errinj.h index cb2f48513e3dd1c9e38b023f824f6a4e27b6a516..0b1e16193320f7bab6e5e1857ce39d3ca4292002 100644 --- a/include/errinj.h +++ b/include/errinj.h @@ -43,10 +43,9 @@ ENUM0(errinj_enum, ERRINJ_LIST); extern struct errinj errinjs[]; 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); +int errinj_set_byname(char *name, bool state); void errinj_info(struct tbuf *out); diff --git a/mod/box/index.m b/mod/box/index.m index 5d55893aa4eb2e7d354a4c13e612509628d0f016..43a9d50615c120351f780f86f81378e0c14aac4f 100644 --- a/mod/box/index.m +++ b/mod/box/index.m @@ -361,6 +361,8 @@ hash_iterator_free(struct iterator *iterator) - (void) initIterator: (struct iterator *) iterator :(void *) key :(int) part_count { + (void) part_count; /* Silence gcc warning in release mode. */ + struct hash_iterator *it = hash_iterator(iterator); assert(part_count == 1); @@ -482,6 +484,7 @@ hash_iterator_free(struct iterator *iterator) - (void) initIterator: (struct iterator *) iterator :(void *) field :(int) part_count { + (void) part_count; /* Silence gcc warning in release mode. */ assert(iterator->next = hash_iterator_next); assert(part_count == 1); @@ -594,6 +597,7 @@ hash_iterator_free(struct iterator *iterator) - (void) initIterator: (struct iterator *) iterator :(void *) key :(int) part_count { + (void) part_count; /* Silence gcc warning in release mode. */ assert(iterator->next = hash_iterator_next); assert(part_count== 1); diff --git a/test/box/errinj.test b/test/box/errinj.test index d08a17cb4f3056f0b3cd0745ad7bc3a55cbcc61b..b1d65dfccce9d1fcaf15cf12fd9c79b3a07f4346 100644 --- a/test/box/errinj.test +++ b/test/box/errinj.test @@ -1,5 +1,5 @@ # encoding: tarantool -# +# import sys # clear statistics: server.stop()