jlaitine commented on code in PR #8026:
URL: https://github.com/apache/nuttx/pull/8026#discussion_r1061175458


##########
include/nuttx/mm/map.h:
##########
@@ -43,7 +49,11 @@ struct mm_map_entry_s
   off_t offset;
   int prot;
   int flags;
-  FAR void *priv;
+  union
+  {
+    FAR void *p;
+    int i;

Review Comment:
   we can, but shouldn't do.
   
   - for uintptr_t it is ok, but uintptr_t is not C89/90  (and is optional even 
in newer)
   - direct cast between int and void * is illegal in principle (different 
size, some compilers even warn about this: "cast from pointer to integer of 
different size")
   - it is much cleaner to type priv.p = ptr; and priv.i = i; than adding 
typecasts
   - using union is extendable to other types without breaking any existing 
functionality
   - most importantly, I like it like this ;)
   



-- 
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-unsubscr...@nuttx.apache.org

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

Reply via email to