diff options
author | Ryan Beltran <ryanbeltran@chromium.org> | 2024-01-03 01:21:29 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-01-10 21:23:54 +0000 |
commit | 23b521c6af529a48b8d5d82833cfa2f31ab57219 (patch) | |
tree | e3476568a4062f21c589d60f4d8850a7887ec835 /src/prop_registry.cc | |
parent | b31ef0adcaff61c045e95158cb9720543b42b531 (diff) | |
download | libchrome-gestures-23b521c6af529a48b8d5d82833cfa2f31ab57219.tar.gz |
Fix findings of wvla-cxx-extension
This CL fixes occurances of the wvla-cxx-extension warning in
platform/gestures. This is a newly introduced warning in Clang and
existing occurances in ChromeOS break compatibility with future releases
of LLVM.
BUG=b:316021385
TEST=emerge-atlas chromeos-base/gestures
Change-Id: If0eb2999d8a5abc3a367dc1c863d53258804d721
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/gestures/+/5160432
Reviewed-by: Harry Cutts <hcutts@chromium.org>
Commit-Queue: Ryan Beltran <ryanbeltran@chromium.org>
Code-Coverage: Sean O'Brien <seobrien@chromium.org>
Tested-by: Ryan Beltran <ryanbeltran@chromium.org>
Diffstat (limited to 'src/prop_registry.cc')
-rw-r--r-- | src/prop_registry.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/prop_registry.cc b/src/prop_registry.cc index 283db9d..244ebf2 100644 --- a/src/prop_registry.cc +++ b/src/prop_registry.cc @@ -106,15 +106,17 @@ void BoolProperty::HandleGesturesPropWritten() { } void BoolArrayProperty::CreatePropImpl() { - GesturesPropBool orig_vals[count_]; - memcpy(orig_vals, vals_, sizeof(orig_vals)); + auto orig_vals = std::make_unique<GesturesPropBool[]>(count_); + + memcpy(orig_vals.get(), vals_, count_ * sizeof(GesturesPropBool)); gprop_ = parent_->PropProvider()->create_bool_fn( parent_->PropProviderData(), name(), vals_, count_, vals_); - if (delegate_ && memcmp(orig_vals, vals_, sizeof(orig_vals))) + if (delegate_ && memcmp(orig_vals.get(), vals_, + count_ * sizeof(GesturesPropBool))) delegate_->BoolArrayWasWritten(this); } @@ -182,15 +184,16 @@ void DoubleProperty::HandleGesturesPropWritten() { } void DoubleArrayProperty::CreatePropImpl() { - float orig_vals[count_]; - memcpy(orig_vals, vals_, sizeof(orig_vals)); + auto orig_vals = std::make_unique<float[]>(count_); + + memcpy(orig_vals.get(), vals_, count_ * sizeof(float)); gprop_ = parent_->PropProvider()->create_real_fn( parent_->PropProviderData(), name(), vals_, count_, vals_); - if (delegate_ && memcmp(orig_vals, vals_, sizeof(orig_vals))) + if (delegate_ && memcmp(orig_vals.get(), vals_, count_ * sizeof(float))) delegate_->DoubleArrayWasWritten(this); } @@ -263,15 +266,16 @@ void IntProperty::HandleGesturesPropWritten() { } void IntArrayProperty::CreatePropImpl() { - int orig_vals[count_]; - memcpy(orig_vals, vals_, sizeof(orig_vals)); + auto orig_vals = std::make_unique<int[]>(count_); + + memcpy(orig_vals.get(), vals_, count_ * sizeof(int)); gprop_ = parent_->PropProvider()->create_int_fn( parent_->PropProviderData(), name(), vals_, count_, vals_); - if (delegate_ && memcmp(orig_vals, vals_, sizeof(orig_vals))) + if (delegate_ && memcmp(orig_vals.get(), vals_, count_ * sizeof(int))) delegate_->IntArrayWasWritten(this); } |