Repository: xbmc/xbmc
File: xbmc/windowing/gbm/drm/DRMObject.cpp (C++)

Code before:
      continue;

    return std::make_optional<uint64_t>(prop->enums[j].value);
  }

  return {};
}

std::optional<uint64_t*> CDRMObject::GetRangePropertyLimits(std::string_view name)
{
  auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
                               [&name](const auto& prop) { return prop->name == name; });

  if (property == m_propsInfo.end())
    return {};

  auto prop = property->get();

  if (!static_cast<bool>(drm_property_type_is(prop, DRM_MODE_PROP_RANGE)))
    return {};

  if (prop->count_values != 2)
    return {};

  return prop->values;
}

bool CDRMObject::SetProperty(const std::string& name, uint64_t value)
{
  auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
                               [&name](const auto& prop) { return prop->name == name; });

  if (property != m_propsInfo.end())
  {
    int ret = drmModeObjectSetProperty(m_fd, m_id, m_type, property->get()->prop_id, value);
    if (ret == 0)
      return true;
  }

  return false;
}

bool CDRMObject::SupportsProperty(const std::string& name)
{
  auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
                               [&name](const auto& prop) { return prop->name == name; });

  if (property != m_propsInfo.end())
    return true;

  return false;

Review comment (suggestion):
I suggest to add a little more type safety:
```suggestion
std::optional<std::span<uint64_t, 2>> CDRMObject::GetRangePropertyLimits(std::string_view name)
{
  auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
                               [&name](const auto& prop) { return prop->name == name; });

  if (property == m_propsInfo.end())
    return {};

  auto prop = property->get();

  if (!static_cast<bool>(drm_property_type_is(prop, DRM_MODE_PROP_RANGE)))
    return {};

  if (prop->count_values != 2)
    return {};

  return std::make_optional<std::span<uint64_t, 2>>(prop->values, 2);
}
```

Code after:
      continue;

    return std::make_optional<uint64_t>(prop->enums[j].value);
  }

  return {};
}

std::optional<std::span<uint64_t, 2>> CDRMObject::GetRangePropertyLimits(std::string_view name)
{
  auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
                               [&name](const auto& prop) { return prop->name == name; });

  if (property == m_propsInfo.end())
    return {};

  auto prop = property->get();

  if (!static_cast<bool>(drm_property_type_is(prop, DRM_MODE_PROP_RANGE)))
    return {};

  if (prop->count_values != 2)
    return {};

  return std::make_optional<std::span<uint64_t, 2>>(prop->values, 2);
}

bool CDRMObject::SetProperty(const std::string& name, uint64_t value)
{
  auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
                               [&name](const auto& prop) { return prop->name == name; });

  if (property != m_propsInfo.end())
  {
    int ret = drmModeObjectSetProperty(m_fd, m_id, m_type, property->get()->prop_id, value);
    if (ret == 0)
      return true;
  }

  return false;
}

bool CDRMObject::SupportsProperty(const std::string& name)
{
  auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
                               [&name](const auto& prop) { return prop->name == name; });

  if (property != m_propsInfo.end())
    return true;

  return false;