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 2020/02/10 06:12:57 UTC

[GitHub] [incubator-nuttx-apps] masayuki2009 opened a new pull request #62: examples: elf: Fix warnings when compiled for RISC-V 64bit

masayuki2009 opened a new pull request #62: examples: elf: Fix warnings when compiled for RISC-V 64bit
URL: https://github.com/apache/incubator-nuttx-apps/pull/62
 
 
   ### Summary
   
   - Fix warnings such as "warning: cast from pointer to integer of different size"
   
   ### Impact
   
   - This PR only affects apps/examples/elf.
   
   ### Testing
   
   - Tested with Sony Spresense (armv7-m 32bit) and K210 (RISC-V RV64GC)
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-nuttx-apps] patacongo commented on a change in pull request #62: examples: elf: Fix warnings when compiled for RISC-V 64bit

Posted by GitBox <gi...@apache.org>.
patacongo commented on a change in pull request #62: examples: elf: Fix warnings when compiled for RISC-V 64bit
URL: https://github.com/apache/incubator-nuttx-apps/pull/62#discussion_r377071705
 
 

 ##########
 File path: examples/elf/tests/pthread/pthread.c
 ##########
 @@ -82,16 +82,16 @@ enum exit_values_e
 
 void *child_start_routine(void *arg)
 {
-  printf("CHILD: started with arg=%d\n", (int)arg);
+  printf("CHILD: started with arg=%d\n", (intptr_t)arg);
 
 
 Review comment:
   This will cause warnings in some environments where there is type checking (like sim).  It can also cause parateter mismatches in other cases.
   
   For example, on 64-bit simulation, %d will expect an int argument and sizeof(int) == 32-bits.  But intprt_t will be 64-bits so the printf will be wrong and, in certain cases, can lead to a crash.
   
   My suggesting is to use the more complex cast (int)((intptr_t)arg).  That will both avoid the warning and assure that the value provided to printf is a proper integer type.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-nuttx-apps] patacongo commented on a change in pull request #62: examples: elf: Fix warnings when compiled for RISC-V 64bit

Posted by GitBox <gi...@apache.org>.
patacongo commented on a change in pull request #62: examples: elf: Fix warnings when compiled for RISC-V 64bit
URL: https://github.com/apache/incubator-nuttx-apps/pull/62#discussion_r377071705
 
 

 ##########
 File path: examples/elf/tests/pthread/pthread.c
 ##########
 @@ -82,16 +82,16 @@ enum exit_values_e
 
 void *child_start_routine(void *arg)
 {
-  printf("CHILD: started with arg=%d\n", (int)arg);
+  printf("CHILD: started with arg=%d\n", (intptr_t)arg);
 
 
 Review comment:
   This will cause warnings in some environments where there is type checking (like sim).  It can also cause parameter mismatches in other cases.
   
   For example, on 64-bit simulation, %d will expect an int argument and sizeof(int) == 32-bits.  But intptr_t will be 64-bits so the printf will be wrong.  In certain cases, this kind of size mismatch can lead to a crash.
   
   My suggesting is to use the more complex cast (int)((intptr_t)arg).  That will both avoid the warning and assure that the value provided to printf is a proper integer type.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-nuttx-apps] xiaoxiang781216 merged pull request #62: examples: elf: Fix warnings when compiled for RISC-V 64bit

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #62: examples: elf: Fix warnings when compiled for RISC-V 64bit
URL: https://github.com/apache/incubator-nuttx-apps/pull/62
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services