jlaitine commented on code in PR #8176:
URL: https://github.com/apache/nuttx/pull/8176#discussion_r1073475284
##########
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:
yes, but then you'd need to do something like (ssize_t)((uintptr_t)blk -
(uintptr_t)addr) . otherwise the sign of the calculation may be wrong (never
negative but overflown to large positive) as it is compared against unsigned.
and this format just looks even uglier (and relies on the fact(?) that
sizeof(ssize_t) == sizeof(uintptr_t). which is maybe so, but not by standard
(ssize_t just needs to be large enough to cover the whole address area, there
is no requirement for it to be exactly the same size... *if* it would be larger
this would fail still.... Just keeping pointers as pointers when doing pointer
arithmetic is IMHO cleanest, and then you can also trust that the result is
proper signed integer :)
--
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]