mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-06 07:06:10 +00:00
util: Fix some truncation warnings, mostly by explicitly casting
This commit is contained in:
parent
5f8cb4e227
commit
d4d6a1a73f
|
@ -19,7 +19,8 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -325,6 +326,7 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs, size_t num_xdevs, int *hea
|
||||||
*head = XRT_DEVICE_ROLE_UNASSIGNED;
|
*head = XRT_DEVICE_ROLE_UNASSIGNED;
|
||||||
*left = XRT_DEVICE_ROLE_UNASSIGNED;
|
*left = XRT_DEVICE_ROLE_UNASSIGNED;
|
||||||
*right = XRT_DEVICE_ROLE_UNASSIGNED;
|
*right = XRT_DEVICE_ROLE_UNASSIGNED;
|
||||||
|
assert(num_xdevs < INT_MAX);
|
||||||
|
|
||||||
for (size_t i = 0; i < num_xdevs; i++) {
|
for (size_t i = 0; i < num_xdevs; i++) {
|
||||||
if (xdevs[i] == NULL) {
|
if (xdevs[i] == NULL) {
|
||||||
|
@ -334,26 +336,26 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs, size_t num_xdevs, int *hea
|
||||||
switch (xdevs[i]->device_type) {
|
switch (xdevs[i]->device_type) {
|
||||||
case XRT_DEVICE_TYPE_HMD:
|
case XRT_DEVICE_TYPE_HMD:
|
||||||
if (*head == XRT_DEVICE_ROLE_UNASSIGNED) {
|
if (*head == XRT_DEVICE_ROLE_UNASSIGNED) {
|
||||||
*head = i;
|
*head = (int)i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER:
|
case XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER:
|
||||||
try_move_assignment(xdevs, left, right);
|
try_move_assignment(xdevs, left, right);
|
||||||
if (*left == XRT_DEVICE_ROLE_UNASSIGNED) {
|
if (*left == XRT_DEVICE_ROLE_UNASSIGNED) {
|
||||||
*left = i;
|
*left = (int)i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER:
|
case XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER:
|
||||||
try_move_assignment(xdevs, right, left);
|
try_move_assignment(xdevs, right, left);
|
||||||
if (*right == XRT_DEVICE_ROLE_UNASSIGNED) {
|
if (*right == XRT_DEVICE_ROLE_UNASSIGNED) {
|
||||||
*right = i;
|
*right = (int)i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XRT_DEVICE_TYPE_ANY_HAND_CONTROLLER:
|
case XRT_DEVICE_TYPE_ANY_HAND_CONTROLLER:
|
||||||
if (*left == XRT_DEVICE_ROLE_UNASSIGNED) {
|
if (*left == XRT_DEVICE_ROLE_UNASSIGNED) {
|
||||||
*left = i;
|
*left = (int)i;
|
||||||
} else if (*right == XRT_DEVICE_ROLE_UNASSIGNED) {
|
} else if (*right == XRT_DEVICE_ROLE_UNASSIGNED) {
|
||||||
*right = i;
|
*right = (int)i;
|
||||||
} else {
|
} else {
|
||||||
//! @todo: do something with unassigend devices?
|
//! @todo: do something with unassigend devices?
|
||||||
}
|
}
|
||||||
|
@ -369,10 +371,10 @@ u_device_assign_xdev_roles(struct xrt_device **xdevs, size_t num_xdevs, int *hea
|
||||||
}
|
}
|
||||||
if (xdevs[i]->device_type == XRT_DEVICE_TYPE_HAND_TRACKER) {
|
if (xdevs[i]->device_type == XRT_DEVICE_TYPE_HAND_TRACKER) {
|
||||||
if (*left == XRT_DEVICE_ROLE_UNASSIGNED) {
|
if (*left == XRT_DEVICE_ROLE_UNASSIGNED) {
|
||||||
*left = i;
|
*left = (int)i;
|
||||||
}
|
}
|
||||||
if (*right == XRT_DEVICE_ROLE_UNASSIGNED) {
|
if (*right == XRT_DEVICE_ROLE_UNASSIGNED) {
|
||||||
*right = i;
|
*right = (int)i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ u_distortion_cardboard_calculate(const struct u_cardboard_distortion_arguments *
|
||||||
l_values.distortion_k[4] = args->distortion_k[4];
|
l_values.distortion_k[4] = args->distortion_k[4];
|
||||||
l_values.screen.size.x = args->screen.w_meters;
|
l_values.screen.size.x = args->screen.w_meters;
|
||||||
l_values.screen.size.y = args->screen.h_meters;
|
l_values.screen.size.y = args->screen.h_meters;
|
||||||
l_values.screen.offset.x = (args->screen.w_meters - args->inter_lens_distance_meters) / 2.0;
|
l_values.screen.offset.x = (args->screen.w_meters - args->inter_lens_distance_meters) / 2.0f;
|
||||||
l_values.screen.offset.y = args->lens_y_center_on_screen_meters;
|
l_values.screen.offset.y = args->lens_y_center_on_screen_meters;
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue