summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ryan Prichard <rprichard@google.com> 2023-08-31 00:00:47 -0700
committer Ryan Prichard <rprichard@google.com> 2023-09-01 13:00:43 -0700
commit5a8af506b234685a0749b5753ba205c06688f870 (patch)
treec7a07b2923c0fcb1d56541a85319ec97d6d0a2f9
parent385fe14c9bcda78677ca41cab8ea569cf5e3a4d2 (diff)
input: handle change in std::span::size type
The pre-standardized version of std::span in external/libcxx had a ptrdiff_t size, but the finalized std::span has a size_t size instead. Also, the std::span::index_type typedef is renamed to size_type. Use an old-style constructor call to implicitly coerce the size value to the proper type. Insert a cast to avoid a signedness comparison warning. Bug: b/175635923 Test: treehugger Change-Id: I96ccf6d5b54d4118b096f97c901073b4fc2f6f9f
-rw-r--r--libs/input/MotionPredictor.cpp5
-rw-r--r--libs/input/TfLiteMotionPredictor.cpp3
2 files changed, 4 insertions, 4 deletions
diff --git a/libs/input/MotionPredictor.cpp b/libs/input/MotionPredictor.cpp
index b5a5e720e9..c8d1da7b1f 100644
--- a/libs/input/MotionPredictor.cpp
+++ b/libs/input/MotionPredictor.cpp
@@ -181,7 +181,8 @@ std::unique_ptr<MotionEvent> MotionPredictor::predict(nsecs_t timestamp) {
int64_t predictionTime = mBuffers->lastTimestamp();
const int64_t futureTime = timestamp + mPredictionTimestampOffsetNanos;
- for (int i = 0; i < predictedR.size() && predictionTime <= futureTime; ++i) {
+ for (size_t i = 0; i < static_cast<size_t>(predictedR.size()) && predictionTime <= futureTime;
+ ++i) {
if (predictedR[i] < mModel->config().distanceNoiseFloor) {
// Stop predicting when the predicted output is below the model's noise floor.
//
@@ -198,7 +199,7 @@ std::unique_ptr<MotionEvent> MotionPredictor::predict(nsecs_t timestamp) {
const TfLiteMotionPredictorSample::Point predictedPoint =
convertPrediction(axisFrom, axisTo, predictedR[i], predictedPhi[i]);
- ALOGD_IF(isDebug(), "prediction %d: %f, %f", i, predictedPoint.x, predictedPoint.y);
+ ALOGD_IF(isDebug(), "prediction %zu: %f, %f", i, predictedPoint.x, predictedPoint.y);
PointerCoords coords;
coords.clear();
coords.setAxisValue(AMOTION_EVENT_AXIS_X, predictedPoint.x);
diff --git a/libs/input/TfLiteMotionPredictor.cpp b/libs/input/TfLiteMotionPredictor.cpp
index 5984b4d3b9..d17476e216 100644
--- a/libs/input/TfLiteMotionPredictor.cpp
+++ b/libs/input/TfLiteMotionPredictor.cpp
@@ -143,8 +143,7 @@ std::span<T> getTensorBuffer(typename std::conditional<std::is_const<T>::value,
tensor->name, TfLiteTypeGetName(tensor->type), TfLiteTypeGetName(type));
LOG_ALWAYS_FATAL_IF(!tensor->data.data);
- return {reinterpret_cast<T*>(tensor->data.data),
- static_cast<typename std::span<T>::index_type>(tensor->bytes / sizeof(T))};
+ return std::span<T>(reinterpret_cast<T*>(tensor->data.data), tensor->bytes / sizeof(T));
}
// Verifies that a tensor exists and has an underlying buffer of type T.