jlaitine commented on code in PR #8176: URL: https://github.com/apache/nuttx/pull/8176#discussion_r1080851962
########## mm/mempool/mempool_multiple.c: ########## @@ -220,7 +220,7 @@ mempool_multiple_get_dict(FAR struct mempool_multiple_s *mpool, col = index - (row << mpool->dict_col_num_log2); if (mpool->dict[row] == NULL || mpool->dict[row][col].addr != addr || - blk - addr >= mpool->dict[row][col].size) + (FAR char *)blk - (FAR char *)addr >= mpool->dict[row][col].size) Review Comment: sure it would! Cleanest solution is always first cast the void * to the real target type ptr and then do arithmetic. This also gives the compiler the opportunity to know the maximum result size. intptr_t usage is IMHO useless almost always, and just think about it's bit size (it is minimum the same size of pointer + 1 bit). It also doesn't exist on all platforms (not sure if posix enfoces the existence though, not going to check it up now...). With pointers it is always safe and portable to do pointer arithmetic, but not on void * since by the standard you can't (obviously because of size of void). But if you don't know the target type, you always get the same result as gcc extension by casting to char *. So changing void * arithmetic by casting the pointers to char * doesn't change the existing functionality. -- 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