Screen preflet: fix usage of std::find()
Change-Id: I8689ea6baa408d07c715703e8f8bf8f29bf40f60 std::find() never returns NULL but the last element in case of failure Reviewed-on: https://review.haiku-os.org/c/haiku/+/5602 Reviewed-by: Máximo Castañeda <[email protected]> Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
33cf9d22ff
commit
2eaee4a7a1
@@ -381,9 +381,12 @@ ScreenMode::GetManufacturerFromID(const char* id) const
|
||||
// We assume the array is sorted
|
||||
const size_t numElements = sizeof(kPNPIDs) / sizeof(kPNPIDs[0]);
|
||||
const struct pnp_id key = { id, "dummy" };
|
||||
const pnp_id* element = std::find(kPNPIDs, kPNPIDs + numElements, key);
|
||||
if (element == NULL)
|
||||
const pnp_id* lastElement = kPNPIDs + numElements;
|
||||
const pnp_id* element = std::find(kPNPIDs, lastElement, key);
|
||||
if (element == lastElement) {
|
||||
// can't find the vendor code
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return element->manufacturer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user