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 13:48:04 UTC

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

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