summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-04-19 13:04:41 +0200
committerRémi Verschelde <rverschelde@gmail.com>2018-04-19 15:20:45 +0200
commitbf7ca623a65f25cc4ac7a3ca0d6635331ec07c25 (patch)
tree40f6fa11f7dd41fd51343af01e1e298a2f7fd859 /main
parent394e6d5ee1479d402892d6df75dddceeb967efcc (diff)
Fix Coverity reports of uninitialized scalar variable
Fixes most current reports on Coverity Scan of uninitialized scalar variable (CWE-457): https://cwe.mitre.org/data/definitions/457.html These happen most of the time (in our code) when instanciating structs without a constructor (or with an incomplete one), and later returning the instance. This is sometimes intended though, as some parameters are only used in some situations and should not be double-initialized for performance reasons (e.g. `constant` in ShaderLanguage::Token).
Diffstat (limited to 'main')
-rw-r--r--main/input_default.cpp4
-rw-r--r--main/input_default.h2
2 files changed, 2 insertions, 4 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 3c40be5082..de7f8ebb4d 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -194,8 +194,6 @@ void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_
Joypad js;
js.name = p_connected ? p_name : "";
js.uid = p_connected ? p_guid : "";
- js.mapping = -1;
- js.hat_current = 0;
if (p_connected) {
@@ -797,12 +795,12 @@ InputDefault::JoyEvent InputDefault::_find_to_event(String p_to) {
JoyEvent ret;
ret.type = -1;
+ ret.index = 0;
int i = 0;
while (buttons[i]) {
if (p_to == buttons[i]) {
- //printf("mapping button %s\n", buttons[i]);
ret.type = TYPE_BUTTON;
ret.index = i;
ret.value = 0;
diff --git a/main/input_default.h b/main/input_default.h
index 6dd88cd31e..8a65303df3 100644
--- a/main/input_default.h
+++ b/main/input_default.h
@@ -97,7 +97,6 @@ class InputDefault : public Input {
int hat_current;
Joypad() {
-
for (int i = 0; i < JOY_AXIS_MAX; i++) {
last_axis[i] = 0.0f;
@@ -110,6 +109,7 @@ class InputDefault : public Input {
last_hat = HAT_MASK_CENTER;
filter = 0.01f;
mapping = -1;
+ hat_current = 0;
}
};