Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Coverity CID :208206] Unsigned compared against 0 in samples/sensor/fxos8700-hid/src/main.c #22643

Closed
zephyrbot opened this issue Feb 9, 2020 · 1 comment · Fixed by #23698
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/e089906b339aad4cd1b6589a3b6ce94782d93f54/samples/sensor/fxos8700-hid/src/main.c#L129

Category: Control flow issues
Function: callbacks_configure
Component: Samples
CID: 208206

Details:

123             return -ENXIO;
124         }
125    
126         gpio_pin_configure(gpio, pin,
127                    GPIO_INPUT | GPIO_INT_DEBOUNCE | flags);
128         *val = gpio_pin_get(gpio, pin);
>>>     CID 208206:  Control flow issues  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never true. "*val < 0U".
129         if (*val < 0) {
130             return *val;
131         }
132    
133         gpio_init_callback(callback, handler, BIT(pin));
134         gpio_add_callback(gpio, callback);

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v32951/p12996.

Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the CODEOWNERS file.

@zephyrbot zephyrbot added bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug labels Feb 9, 2020
ceolin pushed a commit to ceolin/zephyr that referenced this issue Mar 23, 2020
gpio_pin_get() returns a negative value in case of error and
callbacks_configure was assigning this value to an unsigned variable.

Fixes: zephyrproject-rtos#22643
Coverity CID :208206

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
@ceolin
Copy link
Member

ceolin commented Mar 23, 2020

Fixed by: #23698

ioannisg pushed a commit that referenced this issue Mar 25, 2020
gpio_pin_get() returns a negative value in case of error and
callbacks_configure was assigning this value to an unsigned variable.

Fixes: #22643
Coverity CID :208206

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
hakehuang pushed a commit to hakehuang/zephyr that referenced this issue Apr 30, 2020
gpio_pin_get() returns a negative value in case of error and
callbacks_configure was assigning this value to an unsigned variable.

Fixes: zephyrproject-rtos#22643
Coverity CID :208206

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants