OSDN Git Service

input: vl53L0: Fix uninitialized variables
authorJulian Liu <wlootlxt123@gmail.com>
Sat, 20 Jul 2019 08:36:28 +0000 (16:36 +0800)
committer0ranko0P <ranko0p@outlook.com>
Wed, 4 Dec 2019 17:17:34 +0000 (01:17 +0800)
commitc77f24f3b7c29cf2bd92eed3aa009e4fe910f47f
treec1569685fcb374b54f35ddfe4af9dd3b54c27543
parent261eabb8b6b0b53844f85709e9596551919afba8
input: vl53L0: Fix uninitialized variables

Clang warns:
drivers/input/misc/vl53L0/src/vl53l010_api.c:1425:3: error:
      variable 'Temp8' is used uninitialized whenever 'if' condition is false      [-Werror,-Wsometimes-uninitialized]
                VL53L010_GETARRAYPARAMETERFIELD(Dev, LimitChecksEnable,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:87:7: note: expanded
      from macro 'VL53L010_GETARRAYPARAMETERFIELD'
                if (Status == VL53L0_ERROR_NONE) { \
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:1427:24: note:
      uninitialized use occurs here
                *pLimitCheckEnable = Temp8;
                                     ^~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:1425:3: note: remove
      the 'if' if its condition is always true
                VL53L010_GETARRAYPARAMETERFIELD(Dev, LimitChecksEnable,
                ^
drivers/input/misc/vl53L0/src/vl53l010_api.c:87:3: note: expanded
      from macro 'VL53L010_GETARRAYPARAMETERFIELD'
                if (Status == VL53L0_ERROR_NONE) { \
                ^
drivers/input/misc/vl53L0/src/vl53l010_api.c:1418:15: note:
      initialize the variable 'Temp8' to silence this warning
        uint8_t Temp8;
                     ^
                      = '\0'
drivers/input/misc/vl53L0/src/vl53l010_api.c:3875:2: error:
      variable 'xTalkCompRate_mcps' is used uninitialized whenever 'if'
      condition is false [-Werror,-Wsometimes-uninitialized]
        VL53L010_GETPARAMETERFIELD(Dev, XTalkCompensationRateMegaCps,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:78:7: note: expanded
      from macro 'VL53L010_GETPARAMETERFIELD'
                if (Status == VL53L0_ERROR_NONE) { \
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:3882:23: note:
      uninitialized use occurs here
        xTalkCompRate_kcps = xTalkCompRate_mcps * 1000;
                             ^~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:3875:2: note: remove
      the 'if' if its condition is always true
        VL53L010_GETPARAMETERFIELD(Dev, XTalkCompensationRateMegaCps,
        ^
drivers/input/misc/vl53L0/src/vl53l010_api.c:78:3: note: expanded
      from macro 'VL53L010_GETPARAMETERFIELD'
                if (Status == VL53L0_ERROR_NONE) { \
                ^
drivers/input/misc/vl53L0/src/vl53l010_api.c:3844:35: note:
      initialize the variable 'xTalkCompRate_mcps' to silence this warning
        FixPoint1616_t xTalkCompRate_mcps;
                                         ^
                                          = 0
2 errors generated.
drivers/input/misc/vl53L0/src/vl53l010_api.c