You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "acassis (via GitHub)" <gi...@apache.org> on 2023/06/23 13:11:50 UTC

[GitHub] [nuttx] acassis commented on a diff in pull request #9589: drivers/sensors/mpu60x0.c: add IOCTL support

acassis commented on code in PR #9589:
URL: https://github.com/apache/nuttx/pull/9589#discussion_r1239799806


##########
drivers/sensors/mpu60x0.c:
##########
@@ -620,6 +639,12 @@ static inline int __mpu_write_gyro_config(FAR struct mpu_dev_s *dev,
 static inline int __mpu_write_accel_config(FAR struct mpu_dev_s *dev,
                                            uint8_t afs_sel)
 {
+  if (afs_sel > 3)
+    {
+      snerr("Invalid AFS_SEL value\n");
+      return -EINVAL;
+    }
+
   uint8_t val = TO_BITFIELD(ACCEL_CONFIG__AFS_SEL, afs_sel);

Review Comment:
   Please define the variable "val" at the beginning of the function, otherwise it will fail when used with older microcontrollers that only have C89 compiler.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org