You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/07/02 09:33:55 UTC

[GitHub] [incubator-nuttx] GUIDINGLI opened a new pull request #4043: select: fix asan report error

GUIDINGLI opened a new pull request #4043:
URL: https://github.com/apache/incubator-nuttx/pull/4043


   
   ## Summary
   
   select: fix asan report error
   
   vfs/fs_select.c:116:25: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
   vfs/fs_select.c:153:22: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
   
   Change-Id: I2e32bb8a3db8ff5a5955b83b382ac2fa5756122c
   Signed-off-by: ligd <li...@xiaomi.com>
   
   
   ## Impact
   
   ## Testing
   
   


-- 
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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4043: select: fix asan report error

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4043:
URL: https://github.com/apache/incubator-nuttx/pull/4043#discussion_r663384210



##########
File path: include/sys/select.h
##########
@@ -71,11 +71,11 @@
 /* Standard helper macros */
 
 #define FD_CLR(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(UINT32_C(1)<< _FD_BIT(fd)))

Review comment:
       ```suggestion
     ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(UINT32_C(1) << _FD_BIT(fd)))
   ```
   nit: missing whitespace




-- 
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



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #4043: select: fix asan report error

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #4043:
URL: https://github.com/apache/incubator-nuttx/pull/4043


   


-- 
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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4043: select: fix asan report error

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4043:
URL: https://github.com/apache/incubator-nuttx/pull/4043#discussion_r663054436



##########
File path: include/sys/select.h
##########
@@ -71,11 +71,11 @@
 /* Standard helper macros */
 
 #define FD_CLR(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1ul << _FD_BIT(fd)))

Review comment:
       ```suggestion
     ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(UINT32_C(1) << _FD_BIT(fd)))
   ```
   The suffix for the integer type is architecture-dependent.
   Since this is a common header, it is recommended to use the macros from `inttypes.h` for applying the proper suffix:




-- 
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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4043: select: fix asan report error

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4043:
URL: https://github.com/apache/incubator-nuttx/pull/4043#discussion_r663054436



##########
File path: include/sys/select.h
##########
@@ -71,11 +71,11 @@
 /* Standard helper macros */
 
 #define FD_CLR(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1ul << _FD_BIT(fd)))

Review comment:
       ```suggestion
     ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(UINT32_C(1) << _FD_BIT(fd)))
   ```
   The suffix for the integer type is architecture-dependent.
   Since this is a common header, it is recommended to use the macros from `inttypes.h` for applying the proper suffix.

##########
File path: include/sys/select.h
##########
@@ -71,11 +71,11 @@
 /* Standard helper macros */
 
 #define FD_CLR(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1ul << _FD_BIT(fd)))
 #define FD_SET(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (1ul << _FD_BIT(fd)))

Review comment:
       ```suggestion
     ((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (UINT32_C(1) << _FD_BIT(fd)))
   ```




-- 
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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4043: select: fix asan report error

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4043:
URL: https://github.com/apache/incubator-nuttx/pull/4043#discussion_r663054537



##########
File path: include/sys/select.h
##########
@@ -71,11 +71,11 @@
 /* Standard helper macros */
 
 #define FD_CLR(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1ul << _FD_BIT(fd)))
 #define FD_SET(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (1ul << _FD_BIT(fd)))

Review comment:
       ```suggestion
     ((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (UINT32_C(1)<< _FD_BIT(fd)))
   ```

##########
File path: include/sys/select.h
##########
@@ -71,11 +71,11 @@
 /* Standard helper macros */
 
 #define FD_CLR(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] &= ~(1ul << _FD_BIT(fd)))
 #define FD_SET(fd,set) \
-  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (1 << _FD_BIT(fd)))
+  ((((fd_set*)(set))->arr)[_FD_NDX(fd)] |= (1ul << _FD_BIT(fd)))
 #define FD_ISSET(fd,set) \
-  (((((fd_set*)(set))->arr)[_FD_NDX(fd)] & (1 << _FD_BIT(fd))) != 0)
+  (((((fd_set*)(set))->arr)[_FD_NDX(fd)] & (1ul << _FD_BIT(fd))) != 0)

Review comment:
       ```suggestion
     (((((fd_set*)(set))->arr)[_FD_NDX(fd)] & (UINT32_C(1) << _FD_BIT(fd))) != 0)
   ```




-- 
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



[GitHub] [incubator-nuttx] hartmannathan commented on pull request #4043: select: fix asan report error

Posted by GitBox <gi...@apache.org>.
hartmannathan commented on pull request #4043:
URL: https://github.com/apache/incubator-nuttx/pull/4043#issuecomment-873073166


   Gotta be really careful with those left shifts!!!
   
   For example, on 64-bit, the expression `(1 << 31)` doesn't give `0x0000000080000000` like you'd expect, it will give the following useless junk: `0xffffffff80000000` (due to sign extension).
   
   Thanks to all for fixing/reviewing.


-- 
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