Skip to content

Commit 1e312b6

Browse files
committed
get_libraries_for_class: early return
if no lib and on continue on ABI mismatch to reduce the complexity/indention
1 parent a26ac91 commit 1e312b6

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

src/lib_common.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author Martin Pulec <pulec@cesnet.cz>
44
*/
55
/*
6-
* Copyright (c) 2012-2025 CESNET
6+
* Copyright (c) 2012-2026 CESNET, zájmové sdružení právnických osob
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without
@@ -352,19 +352,21 @@ get_libraries_for_class(enum library_class cls, int abi_version,
352352
map<string, const void *> ret;
353353
auto& libraries = get_libmap();
354354
auto it = libraries.find(cls);
355-
if (it != libraries.end()) {
356-
for (auto && item : it->second) {
357-
if (abi_version == item.second.abi_version) {
358-
if (item.second.visibility_flag == 0 ||
359-
(include_flags &
360-
item.second.visibility_flag) != 0U) {
361-
ret[item.first] = item.second.data;
362-
}
363-
} else {
364-
LOG(LOG_LEVEL_WARNING) << "Module " << item.first << " ABI version mismatch (required " <<
365-
abi_version << ", have " << item.second.abi_version << ")\n";
366-
367-
}
355+
if (it == libraries.end()) { // no library of given class
356+
return ret;
357+
}
358+
for (auto &&item : it->second) {
359+
if (abi_version != item.second.abi_version) {
360+
MSG(WARNING,
361+
"Module %s ABI version mismatch (required %d, have "
362+
"%d)\n",
363+
item.first.c_str(), abi_version,
364+
item.second.abi_version);
365+
continue;
366+
}
367+
if (item.second.visibility_flag == 0 ||
368+
(include_flags & item.second.visibility_flag) != 0U) {
369+
ret[item.first] = item.second.data;
368370
}
369371
}
370372

0 commit comments

Comments
 (0)