diff options
author | Harry Cutts <hcutts@google.com> | 2024-03-12 16:55:59 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-03-13 13:08:47 +0000 |
commit | 8fa2ecca2f4a5f08f58d9a75dc712dcb1d8ba4c8 (patch) | |
tree | bc48d2af242716637423a6f891f2df48dfac63c1 | |
parent | 04226b4be33db372a735ccff4c10602c7d349a9f (diff) | |
download | libchrome-gestures-8fa2ecca2f4a5f08f58d9a75dc712dcb1d8ba4c8.tar.gz |
NonLinearity: don't try to load data if path unset
Previously, if no data file path was set in the gesture property, we'd
try to load a file called "None" (the default property value), and
(hopefully) that would fail. If there happened to be a file called
"None" in the current directory we'd try to load it as non-linearity
correction data. Otherwise, we'd log an error because of the file
loading failure even though we hadn't expected to find a data file.
BUG=b:314743031
TEST=unit tests; add the NonLinearityFilterInterpreter to the Touchpad2
stack in gestures.cc, add a log line when attempting to load a
file, and check the line doesn't appear a touchpad is connected
Change-Id: I010086adbf2b6ca69bda32c8c69fc00a239e5a20
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/gestures/+/5365863
Commit-Queue: Harry Cutts <hcutts@chromium.org>
Reviewed-by: Sean O'Brien <seobrien@chromium.org>
Tested-by: Harry Cutts <hcutts@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | src/non_linearity_filter_interpreter.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/non_linearity_filter_interpreter.cc b/src/non_linearity_filter_interpreter.cc index df0e765..d871ba0 100644 --- a/src/non_linearity_filter_interpreter.cc +++ b/src/non_linearity_filter_interpreter.cc @@ -4,6 +4,8 @@ #include "include/non_linearity_filter_interpreter.h" +#include <cstring> + #include <linux/in.h> namespace { @@ -20,7 +22,7 @@ NonLinearityFilterInterpreter::NonLinearityFilterInterpreter( : FilterInterpreter(nullptr, next, tracer, false), x_range_len_(0), y_range_len_(0), p_range_len_(0), enabled_(prop_reg, "Enable non-linearity correction", false), - data_location_(prop_reg, "Non-linearity correction data file", "None") { + data_location_(prop_reg, "Non-linearity correction data file", "") { InitName(); LoadData(); } @@ -67,6 +69,9 @@ bool NonLinearityFilterInterpreter::LoadRange(std::unique_ptr<double[]>& arr, } void NonLinearityFilterInterpreter::LoadData() { + if (strlen(data_location_.val_) == 0) { + return; + } FILE* data_fd = fopen(data_location_.val_, "rb"); if (!data_fd) { Log("Unable to open non-linearity filter data '%s'", data_location_.val_); |