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 <antiswen@yahoo.es> Reviewed-by: waddlesplash <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user