diff --git a/src/box/alter.cc b/src/box/alter.cc index 3bd56feb9518523ad3b1de6ac5a0316a3ba582f4..e43830ca6b8c580ec4446a977639e3475f5911c1 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -950,10 +950,6 @@ class AlterSpaceLock { AlterSpaceLock(struct alter_space *alter) { if (registry == NULL) { registry = mh_i32_new(); - if (registry == NULL) { - tnt_raise(OutOfMemory, 0, "mh_i32_new", - "alter lock registry"); - } } space_id = alter->old_space->def->id; if (mh_i32_find(registry, space_id, NULL) != mh_end(registry)) { diff --git a/src/box/box.cc b/src/box/box.cc index 7b11d56d62c83be879a7af81a7da442f20c1c36d..e082e1a3dbfc0470918fb3cd51119037fd350575 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -3467,9 +3467,7 @@ box_init(void) * as a default session user when running triggers. */ session_init(); - - if (schema_module_init() != 0) - diag_raise(); + schema_module_init(); if (tuple_init(lua_hash) != 0) diag_raise(); diff --git a/src/box/coll_id_cache.c b/src/box/coll_id_cache.c index 22673efd063509b09df854dbcc8886f7c9a5eaa9..1b3a45cca52df4c9ad58530c19919afcaee485a4 100644 --- a/src/box/coll_id_cache.c +++ b/src/box/coll_id_cache.c @@ -38,23 +38,11 @@ static struct mh_strnptr_t *coll_cache_name = NULL; /** mhash table (id -> collation) */ static struct mh_i32ptr_t *coll_id_cache = NULL; -int +void coll_id_cache_init(void) { coll_id_cache = mh_i32ptr_new(); - if (coll_id_cache == NULL) { - diag_set(OutOfMemory, sizeof(*coll_id_cache), "malloc", - "coll_id_cache"); - return -1; - } coll_cache_name = mh_strnptr_new(); - if (coll_cache_name == NULL) { - diag_set(OutOfMemory, sizeof(*coll_cache_name), "malloc", - "coll_cache_name"); - mh_i32ptr_delete(coll_id_cache); - return -1; - } - return 0; } void diff --git a/src/box/coll_id_cache.h b/src/box/coll_id_cache.h index b959b2eb3ed6ef48943863f11b053acd358e2e23..d5325b6aee2279c333a8c1b3a37f760bcc02bcbd 100644 --- a/src/box/coll_id_cache.h +++ b/src/box/coll_id_cache.h @@ -40,9 +40,8 @@ struct coll_id; /** * Create global hash tables. - * @return - 0 on success, -1 on memory error. */ -int +void coll_id_cache_init(void); /** Delete global hash tables. */ diff --git a/src/box/func.c b/src/box/func.c index 04ae1b9580dc5aa2ac6911dcd1b96f5ee3538740..95a08b4af2ab03116ef034a12fdbbcf414615c6a 100644 --- a/src/box/func.c +++ b/src/box/func.c @@ -109,16 +109,10 @@ func_split_name(const char *str, struct func_name *name) /** Schema modules hash. */ static struct mh_strnptr_t *modules = NULL; -int +void schema_module_init(void) { modules = mh_strnptr_new(); - if (modules == NULL) { - diag_set(OutOfMemory, sizeof(*modules), "malloc", - "modules hash table"); - return -1; - } - return 0; } void diff --git a/src/box/func.h b/src/box/func.h index 987ca70dbf22c0a7438a09ba884ee27cfe36cefb..30e748dbbeca0f1e8436e8b3f1628328ab5941e5 100644 --- a/src/box/func.h +++ b/src/box/func.h @@ -74,7 +74,7 @@ struct func { /** * Initialize schema modules subsystem. */ -int +void schema_module_init(void); /** diff --git a/src/box/iproto.cc b/src/box/iproto.cc index 5d28422d71799e82cf8c2ffc8035c5b22069a261..9e73d7e327f95754d7bab53f5dcaa7c3e3eb7d88 100644 --- a/src/box/iproto.cc +++ b/src/box/iproto.cc @@ -1343,12 +1343,6 @@ iproto_connection_new(struct iproto_thread *iproto_thread, int fd) return NULL; } con->streams = mh_i64ptr_new(); - if (con->streams == NULL) { - diag_set(OutOfMemory, sizeof(*(con->streams)), - "mh_streams_new", "streams"); - mempool_free(&con->iproto_thread->iproto_connection_pool, con); - return NULL; - } con->iproto_thread = iproto_thread; con->input.data = con->output.data = con; con->loop = loop(); diff --git a/src/box/lua/lib.c b/src/box/lua/lib.c index fa44163e0bf310ff1c2812a31b9c6315bf6aa547..8ee6c328c472bb65cf94c0176b55a8d7b95c6d46 100644 --- a/src/box/lua/lib.c +++ b/src/box/lua/lib.c @@ -586,8 +586,6 @@ void box_lua_lib_init(struct lua_State *L) { func_hash = mh_strnptr_new(); - if (func_hash == NULL) - panic("box.lib: Can't allocate func hash table"); static const struct luaL_Reg top_methods[] = { { "load", lbox_module_load }, diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c index aaa058a1704e35e468c985e8e973572331f7776a..5393da09b7d0b66a839f52aa505b6c86c9896732 100644 --- a/src/box/lua/net_box.c +++ b/src/box/lua/net_box.c @@ -314,7 +314,7 @@ netbox_request_push_result(struct netbox_request *request, struct lua_State *L) return 1; } -static int +static void netbox_transport_create(struct netbox_transport *transport) { ibuf_create(&transport->send_buf, &cord()->slabc, NETBOX_READAHEAD); @@ -322,11 +322,6 @@ netbox_transport_create(struct netbox_transport *transport) fiber_cond_create(&transport->on_send_buf_empty); transport->next_sync = 1; transport->requests = mh_i64ptr_new(); - if (transport->requests == NULL) { - diag_set(OutOfMemory, 0, "mhash", "netbox_transport"); - return -1; - } - return 0; } static void @@ -1774,8 +1769,7 @@ netbox_new_transport(struct lua_State *L) { struct netbox_transport *transport = lua_newuserdata( L, sizeof(*transport)); - if (netbox_transport_create(transport) != 0) - luaT_error(L); + netbox_transport_create(transport); luaL_getmetatable(L, netbox_transport_typename); lua_setmetatable(L, -2); return 1; diff --git a/src/box/memtx_bitset.c b/src/box/memtx_bitset.c index 75ff8446fccb70e82d45530809b34561aa24c856..7275266fe222769b292255fc4b2ba103749c6fdf 100644 --- a/src/box/memtx_bitset.c +++ b/src/box/memtx_bitset.c @@ -548,8 +548,6 @@ memtx_bitset_index_new(struct memtx_engine *memtx, struct index_def *def) memtx_index_extent_alloc, memtx_index_extent_free, memtx); index->tuple_to_id = mh_bitset_index_new(); - if (index->tuple_to_id == NULL) - panic("failed to allocate memtx bitset index"); #endif /* #ifndef OLD_GOOD_BITSET */ tt_bitset_index_create(&index->index, realloc); diff --git a/src/box/memtx_tx.c b/src/box/memtx_tx.c index 18c6ebf5e01689c56be980a67b8fddb8a1470236..733a63bd61ddec95cdbfbdf7d2f49c0d8d5a191c 100644 --- a/src/box/memtx_tx.c +++ b/src/box/memtx_tx.c @@ -241,13 +241,9 @@ memtx_tx_manager_init() cord_slab_cache(), item_size); } txm.history = mh_history_new(); - if (txm.history == NULL) - panic("mh_history_new()"); mempool_create(&txm.point_hole_item_pool, cord_slab_cache(), sizeof(struct point_hole_item)); txm.point_holes = mh_point_holes_new(); - if (txm.point_holes == NULL) - panic("mh_history_new()"); mempool_create(&txm.gap_item_mempoool, cord_slab_cache(), sizeof(struct gap_item)); mempool_create(&txm.full_scan_item_mempool, @@ -2464,13 +2460,6 @@ memtx_tx_snapshot_cleaner_create(struct memtx_tx_snapshot_cleaner *cleaner, if (space == NULL || rlist_empty(&space->memtx_stories)) return 0; struct mh_snapshot_cleaner_t *ht = mh_snapshot_cleaner_new(); - if (ht == NULL) { - diag_set(OutOfMemory, sizeof(*ht), - index_name, "snapshot cleaner"); - free(ht); - return -1; - } - struct memtx_story *story; rlist_foreach_entry(story, &space->memtx_stories, in_space_stories) { struct tuple *tuple = story->tuple; diff --git a/src/box/module_cache.c b/src/box/module_cache.c index 7f81902bd19a16b75e6fe619102f8354db528f78..fc87e4434619b5e23ac3a0aa6c0311ec5e727e9c 100644 --- a/src/box/module_cache.c +++ b/src/box/module_cache.c @@ -474,14 +474,8 @@ module_free(void) module_cache = NULL; } -int +void module_init(void) { module_cache = mh_strnptr_new(); - if (module_cache == NULL) { - diag_set(OutOfMemory, sizeof(*module_cache), - "malloc", "module_cache"); - return -1; - } - return 0; } diff --git a/src/box/module_cache.h b/src/box/module_cache.h index 24fdf8d85cccd9fb8c4fdc6995269fa05d2b54d3..d767aec7622a725b444ec82340d1550441ba0b3b 100644 --- a/src/box/module_cache.h +++ b/src/box/module_cache.h @@ -193,7 +193,7 @@ void module_unref(struct module *m); /** Initialize modules subsystem. */ -int +void module_init(void); /** Free modules subsystem. */ diff --git a/src/box/session.cc b/src/box/session.cc index 7ba7235febe396f4547758ea0841e2ee76d55bf5..963ec1973d2f410c82d58fbcd7ae608a589d18c9 100644 --- a/src/box/session.cc +++ b/src/box/session.cc @@ -193,11 +193,6 @@ session_add_stmt_id(struct session *session, uint32_t id) { if (session->sql_stmts == NULL) { session->sql_stmts = mh_i32ptr_new(); - if (session->sql_stmts == NULL) { - diag_set(OutOfMemory, 0, "mh_i32ptr_new", - "session stmt hash"); - return -1; - } } return sql_session_stmt_hash_add_id(session->sql_stmts, id); } @@ -281,8 +276,6 @@ void session_init(void) { session_registry = mh_i64ptr_new(); - if (session_registry == NULL) - panic("out of memory"); mempool_create(&session_pool, &cord()->slabc, sizeof(struct session)); credentials_create(&admin_credentials, admin_user); session_settings_init(); diff --git a/src/box/space.c b/src/box/space.c index c6d6a630eed9ba557e97fad255a36a3f928f6b48..db53e4e6152210adad56bbd73b59e980a1889bbe 100644 --- a/src/box/space.c +++ b/src/box/space.c @@ -207,11 +207,6 @@ space_create(struct space *space, struct engine *engine, } } space->constraint_ids = mh_strnptr_new(); - if (space->constraint_ids == NULL) { - diag_set(OutOfMemory, sizeof(*space->constraint_ids), "malloc", - "constraint_ids"); - goto fail; - } rlist_create(&space->memtx_stories); return 0; diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 9009f9e4f227195333bb158cb86cce58dd6e540e..362793a8ed3df199f117bea0863f4b26f82a48d4 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -2358,8 +2358,6 @@ void sql_built_in_functions_cache_init(void) { built_in_functions = mh_strnptr_new(); - if (built_in_functions == NULL) - panic("Out of memory on creating SQL built-in functions hash"); for (uint32_t i = 0; i < nelem(dictionaries); ++i) built_in_func_put(&dictionaries[i]); diff --git a/src/box/sql_stmt_cache.c b/src/box/sql_stmt_cache.c index 66f7a7f8aa6e7250122ad90a8acb46bf3683c35b..3b4f82911d4b7b8256cd909cf57855859d9a80d6 100644 --- a/src/box/sql_stmt_cache.c +++ b/src/box/sql_stmt_cache.c @@ -42,8 +42,6 @@ void sql_stmt_cache_init(void) { sql_stmt_cache.hash = mh_i32ptr_new(); - if (sql_stmt_cache.hash == NULL) - panic("out of memory"); sql_stmt_cache.mem_quota = 0; sql_stmt_cache.mem_used = 0; rlist_create(&sql_stmt_cache.gc_queue); diff --git a/src/box/tuple.c b/src/box/tuple.c index 7174584b4c50f377cf85327eff72d7b87c092511..75e4416d1dc5e1b7aebbb73f3d656a22fdc75d6b 100644 --- a/src/box/tuple.c +++ b/src/box/tuple.c @@ -292,9 +292,7 @@ tuple_bigref_tuple_count() int tuple_init(field_name_hash_f hash) { - if (tuple_format_init() != 0) - return -1; - + tuple_format_init(); field_name_hash = hash; /* * Create a format for runtime tuples @@ -320,9 +318,7 @@ tuple_init(field_name_hash_f hash) tuple_uploaded_refs = mh_tuple_uploaded_refs_new(); - if (coll_id_cache_init() != 0) - return -1; - + coll_id_cache_init(); return 0; } diff --git a/src/box/tuple_dictionary.c b/src/box/tuple_dictionary.c index 25157efa829100b779f7be151fa571f70730cd07..a626a43f4e26e7d5015de17c03465ad4708c023a 100644 --- a/src/box/tuple_dictionary.c +++ b/src/box/tuple_dictionary.c @@ -145,11 +145,6 @@ tuple_dictionary_new(const struct field_def *fields, uint32_t field_count) goto err_memory; } dict->hash = mh_strnu32_new(); - if (dict->hash == NULL) { - diag_set(OutOfMemory, sizeof(*dict->hash), - "mh_strnu32_new", "dict->hash"); - goto err_hash; - } mh_strnu32_reserve(dict->hash, field_count, NULL); char *pos = (char *) dict->names + names_offset; for (uint32_t i = 0; i < field_count; ++i) { @@ -165,7 +160,6 @@ tuple_dictionary_new(const struct field_def *fields, uint32_t field_count) err_name: tuple_dictionary_delete_hash(dict->hash); -err_hash: free(dict->names); err_memory: free(dict); diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c index ad84f2d1de41918d03b3b9dc283e9e20c24b1f5d..80eed4b43455d4c040f09680156886f4aca627bf 100644 --- a/src/box/tuple_format.c +++ b/src/box/tuple_format.c @@ -649,12 +649,7 @@ tuple_format_alloc(struct key_def * const *keys, uint16_t key_count, "tuple format"); return NULL; } - if (json_tree_create(&format->fields) != 0) { - diag_set(OutOfMemory, 0, "json_lexer_create", - "tuple field tree"); - free(format); - return NULL; - } + json_tree_create(&format->fields); for (uint32_t fieldno = 0; fieldno < field_count; fieldno++) { struct tuple_field *field = tuple_field_new(); if (field == NULL) @@ -981,16 +976,10 @@ tuple_format_min_field_count(struct key_def * const *keys, uint16_t key_count, return min_field_count; } -int +void tuple_format_init() { tuple_formats_hash = mh_tuple_format_new(); - if (tuple_formats_hash == NULL) { - diag_set(OutOfMemory, sizeof(struct mh_tuple_format_t), "malloc", - "tuple format hash"); - return -1; - } - return 0; } /** Destroy tuple format subsystem and free resourses */ diff --git a/src/box/tuple_format.h b/src/box/tuple_format.h index c94bfc1ec5396389ccda0fc587e0996554ce334a..b6d912790c0906c96ac3a9aa03fd92fa1cd74ada 100644 --- a/src/box/tuple_format.h +++ b/src/box/tuple_format.h @@ -434,9 +434,8 @@ tuple_field_map_create(struct tuple_format *format, const char *tuple, /** * Initialize tuple format subsystem. - * @retval 0 on success, -1 otherwise. */ -int +void tuple_format_init(); diff --git a/src/box/vy_log.c b/src/box/vy_log.c index 8214b054e249557ccdc0109614f89282326335d6..cd608fc4501c4889d42475e1425ac6b5fcc731ff 100644 --- a/src/box/vy_log.c +++ b/src/box/vy_log.c @@ -2397,14 +2397,6 @@ vy_recovery_new_f(va_list ap) recovery->range_hash = mh_i64ptr_new(); recovery->run_hash = mh_i64ptr_new(); recovery->slice_hash = mh_i64ptr_new(); - if (recovery->index_id_hash == NULL || - recovery->lsm_hash == NULL || - recovery->range_hash == NULL || - recovery->run_hash == NULL || - recovery->slice_hash == NULL) { - diag_set(OutOfMemory, 0, "mh_i64ptr_new", "mh_i64ptr_t"); - goto fail_free; - } /* * We don't create a log file if there are no objects to diff --git a/src/lib/coll/coll.c b/src/lib/coll/coll.c index 9d528df193f22e75366006802b056265a06b273b..c94777a85de1d3394b550bcf28252ffcff69b9a2 100644 --- a/src/lib/coll/coll.c +++ b/src/lib/coll/coll.c @@ -423,8 +423,7 @@ coll_init(void) coll_cache = mh_coll_new(); icu_ucase_default_map = ucasemap_open("", 0, &err); icu_utf8_conv = ucnv_open("utf8", &err); - if (coll_cache == NULL || icu_ucase_default_map == NULL || - icu_utf8_conv == NULL) + if (icu_ucase_default_map == NULL || icu_utf8_conv == NULL) panic("Can not create system collations cache"); } diff --git a/src/lib/core/backtrace.cc b/src/lib/core/backtrace.cc index 85c1aaefd009e6d8fa4c0d34d170e97b4e4b322a..d6641347d2981532004445d1cf0b85d757b5221b 100644 --- a/src/lib/core/backtrace.cc +++ b/src/lib/core/backtrace.cc @@ -94,11 +94,6 @@ get_proc_name(unw_cursor_t *unw_cur, unw_word_t *offset, bool skip_cache) if (proc_cache == NULL) { region_create(&cache_region, &cord()->slabc); proc_cache = mh_i64ptr_new(); - if (proc_cache == NULL) { - unw_get_proc_name(unw_cur, proc_name, sizeof(proc_name), - offset); - goto error; - } } k = mh_i64ptr_find(proc_cache, ip, NULL); diff --git a/src/lib/json/json.c b/src/lib/json/json.c index c4aa1367e97730aa256f2692fa92e9ed755e0ee8..0cfb0bfeec366b51e10efacfc7dc1b28d4bda232 100644 --- a/src/lib/json/json.c +++ b/src/lib/json/json.c @@ -446,7 +446,7 @@ json_token_hash(struct json_token *token) return PMurHash32_Result(h, carry, data_size); } -int +void json_tree_create(struct json_tree *tree) { memset(tree, 0, sizeof(struct json_tree)); @@ -455,7 +455,6 @@ json_tree_create(struct json_tree *tree) tree->root.max_child_idx = -1; tree->root.sibling_idx = -1; tree->hash = mh_json_new(); - return tree->hash == NULL ? -1 : 0; } static void diff --git a/src/lib/json/json.h b/src/lib/json/json.h index 3218769a11f7a981086b1203f88cf6b81df1c0f9..9ea8eff2f2733064dc2c5d5eb1f27df6eb3b7f25 100644 --- a/src/lib/json/json.h +++ b/src/lib/json/json.h @@ -330,10 +330,8 @@ json_tree_snprint_path(char *buf, int size, const struct json_token *token, /** * Initialize a new empty JSON tree. - * - * Returns 0 on success, -1 on memory allocation error. */ -int +void json_tree_create(struct json_tree *tree); /** diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 3955c31309f793e4505fcc1273e407f93a47c8b8..98cafd160141da78492544b1ef2cfa45c06deda1 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -1907,12 +1907,6 @@ swim_new(uint64_t generation) } swim->initial_generation = generation; swim->members = mh_swim_table_new(); - if (swim->members == NULL) { - free(swim); - diag_set(OutOfMemory, sizeof(*swim->members), - "mh_swim_table_new", "members"); - return NULL; - } rlist_create(&swim->round_queue); swim_ev_timer_init(&swim->round_tick, swim_begin_step, 0, HEARTBEAT_RATE_DEFAULT); diff --git a/test/unit/json.c b/test/unit/json.c index 4d3423142a7b87bdf197245bf416fdd43d9742eb..5b2fad471535db6aed918912578e8f4d4b21e348 100644 --- a/test/unit/json.c +++ b/test/unit/json.c @@ -219,8 +219,7 @@ test_tree() plan(65); struct json_tree tree; - int rc = json_tree_create(&tree); - fail_if(rc != 0); + json_tree_create(&tree); struct test_struct records[7]; for (int i = 0; i < 6; i++) @@ -519,8 +518,7 @@ test_path_snprint() plan(9); struct json_tree tree; - int rc = json_tree_create(&tree); - fail_if(rc != 0); + json_tree_create(&tree); struct test_struct records[6]; const char *path = "[1][*][20][\"file\"][8]"; int path_len = strlen(path); @@ -533,7 +531,7 @@ test_path_snprint() char buf[64]; int bufsz = sizeof(buf); - rc = json_tree_snprint_path(buf, bufsz, &node->node, INDEX_BASE); + int rc = json_tree_snprint_path(buf, bufsz, &node->node, INDEX_BASE); is(rc, path_len, "full path - retval"); is(buf[path_len], '\0', "full path - terminating nul"); is(memcmp(buf, path, path_len), 0, "full path - output");