xiaoxiang781216 commented on pull request #904:
URL: 
https://github.com/apache/incubator-nuttx-apps/pull/904#issuecomment-981732099


   > Looks like I'm late to the party but LGTM.
   > 
   > Just one question:
   > 
   > Are we sure we want to remove the typecast from the (void *) returned by 
malloc() to (FAR struct dhcpc_state_s *) in this call:
   > 
   > ```
   > -pdhcpc = (FAR struct dhcpc_state_s *)malloc(sizeof(struct dhcpc_state_s));
   > +pdhcpc = malloc(sizeof(struct dhcpc_state_s) + maclen - 1);
   > ```
   > 
   
   It's a normal practice to let compiler auto convert void * to type * in C:
   https://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc
   
   > Some compilers may warn about that.
   > 
   
   This implicit conversion is allowed by C standard. But, it forbid by C++.
   
   
   > Might also benefit from a comment explaining the `maclen - 1` such as:
   > 
   > ```
   > /* maclen - 1: First byte of maclen is included in the structure */
   > ```
   > 
   > So that someone in the future won't think it's a mistake.
   
   Yes, good suggestion.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to