You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/04/11 10:29:42 UTC

[incubator-nuttx] 02/03: drivers/sensors/scd30: Fix invalid parameter check

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 3787a362bff25384216c7920ee2e46973210bd40
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Mon Apr 11 16:34:56 2022 +0900

    drivers/sensors/scd30: Fix invalid parameter check
    
    Fix invalid parameter check and redundant conditions.
---
 drivers/sensors/scd30.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/sensors/scd30.c b/drivers/sensors/scd30.c
index 352c669f6c..6c273a9643 100644
--- a/drivers/sensors/scd30.c
+++ b/drivers/sensors/scd30.c
@@ -835,7 +835,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
       case SNIOC_SET_INTERVAL:
         {
-          if (arg < 2 && arg > 1800)
+          if (arg < 2 || arg > 1800)
             {
               ret = -EINVAL;
               break;
@@ -851,7 +851,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
       case SNIOC_SET_TEMP_OFFSET:
         {
-          if (arg < 0 && arg > UINT16_MAX)
+          if (arg > UINT16_MAX)
             {
               ret = -EINVAL;
               break;
@@ -867,7 +867,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
       case SNIOC_SET_PRESSURE_COMP:
         {
-          if (arg != 0 && arg < 700 && arg > 1200)
+          if (arg != 0 && (arg < 700 || arg > 1200))
             {
               ret = -EINVAL;
               break;
@@ -891,7 +891,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
       case SNIOC_SET_ALTITUDE_COMP:
         {
-          if (arg < 0 && arg > UINT16_MAX)
+          if (arg > UINT16_MAX)
             {
               ret = -EINVAL;
               break;
@@ -908,7 +908,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
       case SNIOC_SET_FRC:
         {
-          if (arg < 0 && arg > UINT16_MAX)
+          if (arg > UINT16_MAX)
             {
               ret = -EINVAL;
               break;