mirror of
https://github.com/lbgos/rift-s-linux.git
synced 2026-10-27 17:00:58 +01:00
xrt: address easy clang-tidy android fixes
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2756>
This commit is contained in:
1 parent
d77d53217e
commit
c2ddab59dc
9 files changed
+26
-9
No files matched your search
@@ -72,10 +72,7 @@ namespace org::freedesktop::monado::auxiliary {
|
||||
jfloat *refreshRates =
|
||||
(jfloat *)jni::env()->GetFloatArrayElements((jfloatArray)refreshRateArray.getHandle(), 0);
|
||||
jsize length = jni::env()->GetArrayLength((jfloatArray)refreshRateArray.getHandle());
|
||||
std::vector<float> refreshRateVector;
|
||||
for (int i = 0; i < length; i++) {
|
||||
refreshRateVector.push_back(refreshRates[i]);
|
||||
}
|
||||
std::vector<float> refreshRateVector(refreshRates, refreshRates + length);
|
||||
return refreshRateVector;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ ogl_import_from_native(struct xrt_image_native *natives,
|
||||
// Function is disabled for AHardwareBuffer, glImportMemoryFdEXT requires an actual FD and requires more work
|
||||
// to handle AHardwareBuffer.
|
||||
return false;
|
||||
#endif
|
||||
#else
|
||||
|
||||
// Setup fields.
|
||||
results->width = info->width;
|
||||
@@ -167,4 +167,5 @@ ogl_import_from_native(struct xrt_image_native *natives,
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
@@ -131,7 +131,7 @@ is_experimental_vendor(std::string_view vendor)
|
||||
* Returns an ExtensionSortKey for comparison.
|
||||
*/
|
||||
static ExtensionSortKey
|
||||
get_extension_sort_key(std::string_view name)
|
||||
get_extension_sort_key(const std::string_view name)
|
||||
{
|
||||
// Find the first underscore to separate API prefix (e.g., "VK", "XR")
|
||||
size_t first_underscore = name.find('_');
|
||||
@@ -269,7 +269,7 @@ ExtensionListBuilder::sortForExtensions()
|
||||
}
|
||||
|
||||
// Sort using our custom comparison function that works with std::string
|
||||
auto cmp = [](const std::string &a, const std::string &b) {
|
||||
auto cmp = [](const std::string_view a, const std::string_view b) {
|
||||
return get_extension_sort_key(a) < get_extension_sort_key(b);
|
||||
};
|
||||
std::sort(strings.begin(), strings.end(), cmp);
|
||||
|
||||
@@ -356,6 +356,11 @@ compositor_request_display_refresh_rate(struct xrt_compositor *xc, float display
|
||||
// Note that this will just increment the reference count, rather than actually load it again,
|
||||
// since we are linked for other symbols too.
|
||||
void *android_handle = dlopen("libandroid.so", RTLD_NOW);
|
||||
if (android_handle == NULL) {
|
||||
U_LOG_E("failed to open libandroid.so");
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
PF_SETFRAMERATE set_frame_rate = (PF_SETFRAMERATE)dlsym(android_handle, "ANativeWindow_setFrameRate");
|
||||
if (!set_frame_rate) {
|
||||
U_LOG_E("ANativeWindow_setFrameRate not found");
|
||||
|
||||
@@ -487,6 +487,10 @@ cemu_devices_create(struct xrt_device *head, struct xrt_device *hands, struct xr
|
||||
struct cemu_device *cemud[2];
|
||||
|
||||
struct cemu_system *system = U_TYPED_CALLOC(struct cemu_system);
|
||||
if (system == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
system->in_hand = hands;
|
||||
system->in_head = head;
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ socket_close(r_socket_t id)
|
||||
static inline r_socket_t
|
||||
socket_create(void)
|
||||
{
|
||||
return socket(AF_INET, SOCK_STREAM, 0);
|
||||
return socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
@@ -248,7 +248,11 @@ do_accept(struct r_hub *r)
|
||||
}
|
||||
|
||||
socklen_t addr_length = (socklen_t)sizeof(addr);
|
||||
#ifdef SOCK_CLOEXEC
|
||||
ret = accept4(r->accept_fd, (struct sockaddr *)&addr, &addr_length, SOCK_CLOEXEC);
|
||||
#else
|
||||
ret = accept(r->accept_fd, (struct sockaddr *)&addr, &addr_length);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
R_ERROR(r, "accept: " R_SOCKET_FMT, ret);
|
||||
return ret;
|
||||
|
||||
@@ -44,7 +44,7 @@ static int
|
||||
init_pipe(struct ipc_server_mainloop *ml)
|
||||
{
|
||||
int pipefd[2];
|
||||
int ret = pipe(pipefd);
|
||||
int ret = pipe2(pipefd, O_CLOEXEC);
|
||||
if (ret < 0) {
|
||||
U_LOG_E("pipe2() failed '%i'", ret);
|
||||
return ret;
|
||||
|
||||
@@ -256,6 +256,10 @@ get_brightness(struct ipc_connection *ipc_c, int device_id)
|
||||
int
|
||||
set_brightness(struct ipc_connection *ipc_c, int device_id, const char *value)
|
||||
{
|
||||
if (value == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const int length = strlen(value);
|
||||
if (length == 0) {
|
||||
return 1;
|
||||
|
||||
@@ -146,6 +146,8 @@ private:
|
||||
.window_title = "Monado Android Service",
|
||||
.open = U_DEBUG_GUI_OPEN_NEVER,
|
||||
},
|
||||
.exit_on_disconnect = false,
|
||||
.no_stdin = false,
|
||||
};
|
||||
|
||||
const struct ipc_server_callbacks callbacks = {
|
||||
|
||||
Reference in new issue
Block a user