yamt commented on code in PR #5991:
URL: https://github.com/apache/incubator-nuttx/pull/5991#discussion_r844866636


##########
mm/mm_heap/mm_memalign.c:
##########
@@ -78,7 +79,9 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t 
alignment,
 
   if (alignment <= MM_MIN_CHUNK)
     {
-      return mm_malloc(heap, size);
+      ptr = mm_malloc(heap, size);
+      DEBUGASSERT(ptr == NULL || ((uintptr_t)ptr) % alignment == 0);
+      return ptr;

Review Comment:
   i know (void *)0 is guaranteed to be NULL.
   otoh, i'm not sure if (size_t)NULL is guaranteed to be 0.
   i feel it's simpler to check NULL.



##########
mm/mm_heap/mm_memalign.c:
##########
@@ -227,5 +230,7 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t 
alignment,
   kasan_unpoison((FAR void *)alignedchunk,
                  mm_malloc_size((FAR void *)alignedchunk));
 
-  return (FAR void *)alignedchunk;
+  ptr = (FAR void *)alignedchunk;
+  DEBUGASSERT(ptr == NULL || ((uintptr_t)ptr) % alignment == 0);
+  return ptr;

Review Comment:
   i applied this one as it can't be NULL here.



-- 
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