Skip to content

Commit 780806f

Browse files
wdfk-progmysterywolf
authored andcommitted
[rtdef] RT_IS_ALIGN marco add a null address exclusive
1 parent e36b97f commit 780806f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/rtdef.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,9 @@ typedef int (*init_fn_t)(void);
393393
* Return true(1) or false(0).
394394
* RT_IS_ALIGN(128, 4) is judging whether 128 aligns with 4.
395395
* The result is 1, which means 128 aligns with 4.
396+
* @note If the address is NULL, false(0) will be returned
396397
*/
397-
#define RT_IS_ALIGN(addr, align) (!(addr & (align - 1)))
398+
#define RT_IS_ALIGN(addr, align) ((!(addr & (align - 1))) && (addr != RT_NULL))
398399

399400
/**
400401
* @ingroup BasicDef

0 commit comments

Comments
 (0)