fix early break

This commit is contained in:
john30
2024-09-12 07:24:34 +02:00
parent 52c3060bbb
commit 59edf1a21f
+2 -5
View File
@@ -611,9 +611,6 @@ int resolveMdnsOneShot(const char* url, mdns_oneshot_t *result, mdns_oneshot_t *
if (!found && (!limitId.length() || limitId.compare(id) == 0)) { if (!found && (!limitId.length() || limitId.compare(id) == 0)) {
storeTo = result; storeTo = result;
found = true; found = true;
if (limitId.length()) {
break; // found the desired one, no need to wait for another
}
} else if (found && strcmp(id, result->id) == 0) { } else if (found && strcmp(id, result->id) == 0) {
// skip duplicate answer // skip duplicate answer
continue; continue;
@@ -632,8 +629,8 @@ int resolveMdnsOneShot(const char* url, mdns_oneshot_t *result, mdns_oneshot_t *
storeTo->address = validAddress; storeTo->address = validAddress;
strncpy(storeTo->id, id, sizeof(mdns_oneshot_t::id)); strncpy(storeTo->id, id, sizeof(mdns_oneshot_t::id));
strncpy(storeTo->proto, proto, sizeof(mdns_oneshot_t::proto)); strncpy(storeTo->proto, proto, sizeof(mdns_oneshot_t::proto));
if (found && moreRemain == 0) { if (found && (limitId.length() || !moreRemain)) {
break; break; // found the desired one or no more space left for others
} }
} }
} }