misc: Replace uses of __builtin_*_overflow() with <misc/math_extras.h>.
Use the new math_extras functions instead of calling builtins directly.
Change a few local variables to size_t after checking that all uses of
the variable actually expects a size_t.
Signed-off-by: Jakob Olesen <jolesen@fb.com>
diff --git a/kernel/msg_q.c b/kernel/msg_q.c
index b796e74..1ab3fdc 100644
--- a/kernel/msg_q.c
+++ b/kernel/msg_q.c
@@ -18,6 +18,7 @@
#include <string.h>
#include <wait_q.h>
#include <misc/dlist.h>
+#include <misc/math_extras.h>
#include <init.h>
#include <syscall_handler.h>
#include <kernel_internal.h>
@@ -73,8 +74,7 @@
int ret;
size_t total_size;
- if (__builtin_umul_overflow((unsigned int)msg_size, max_msgs,
- (unsigned int *)&total_size)) {
+ if (size_mul_overflow(msg_size, max_msgs, &total_size)) {
ret = -EINVAL;
} else {
buffer = z_thread_malloc(total_size);