libcamera: media_device: Minor cleanup in findInterface()
Do not compare an usigned int with -1 to avoid going through cast. Also align function parameters and long assignement lines while at there. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
4863d44104
commit
4e5a93da83
1 changed files with 8 additions and 9 deletions
|
@ -379,13 +379,14 @@ void MediaDevice::clear()
|
||||||
* \return A pointer to the interface if found, or nullptr otherwise
|
* \return A pointer to the interface if found, or nullptr otherwise
|
||||||
*/
|
*/
|
||||||
struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topology &topology,
|
struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topology &topology,
|
||||||
unsigned int entityId)
|
unsigned int entityId)
|
||||||
{
|
{
|
||||||
struct media_v2_link *links = reinterpret_cast<struct media_v2_link *>
|
struct media_v2_link *links = reinterpret_cast<struct media_v2_link *>
|
||||||
(topology.ptr_links);
|
(topology.ptr_links);
|
||||||
unsigned int ifaceId = -1;
|
unsigned int ifaceId;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < topology.num_links; ++i) {
|
for (i = 0; i < topology.num_links; ++i) {
|
||||||
/* Search for the interface to entity link. */
|
/* Search for the interface to entity link. */
|
||||||
if (links[i].sink_id != entityId)
|
if (links[i].sink_id != entityId)
|
||||||
continue;
|
continue;
|
||||||
|
@ -397,14 +398,12 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo
|
||||||
ifaceId = links[i].source_id;
|
ifaceId = links[i].source_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (i == topology.num_links)
|
||||||
if (ifaceId == static_cast<unsigned int>(-1))
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
struct media_v2_interface *ifaces = reinterpret_cast<struct media_v2_interface *>
|
struct media_v2_interface *ifaces = reinterpret_cast<struct media_v2_interface *>
|
||||||
(topology.ptr_interfaces);
|
(topology.ptr_interfaces);
|
||||||
|
for (i = 0; i < topology.num_interfaces; ++i) {
|
||||||
for (unsigned int i = 0; i < topology.num_interfaces; ++i) {
|
|
||||||
if (ifaces[i].id == ifaceId)
|
if (ifaces[i].id == ifaceId)
|
||||||
return &ifaces[i];
|
return &ifaces[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue