aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-06-11 19:12:43 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-06-11 19:12:43 +0300
commit56fb0b774a8e89be1cb7ab1e5f464bbedd19fb22 (patch)
tree880c85cdd9052ec5f2c93cbede2d7d083bd5cd7f /lib
parent426da8be0db33405b0cfe53108b65040623972f0 (diff)
downloadkmi-56fb0b774a8e89be1cb7ab1e5f464bbedd19fb22.tar.gz
kmi-56fb0b774a8e89be1cb7ab1e5f464bbedd19fb22.zip
fix ubsan warning in release mode
Diffstat (limited to 'lib')
-rw-r--r--lib/ubsan.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/ubsan.c b/lib/ubsan.c
index f296b7a..d3e363e 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -12,6 +12,9 @@
#include <apos/types.h>
#include <apos/debug.h>
+#if defined(DEBUG)
+/* ubsan is only sensible if we're in debug mode. */
+
/**
* Describes a source file location.
*/
@@ -163,7 +166,7 @@ inline static void print_location(const char *message,
*
* @param data Overflow information, generated by the compiler.
*/
-void __ubsan_handle_add_overflow(struct overflow_data *data)
+void __ubsan_handle_add_overflow(const struct overflow_data *data)
{
print_location("addition overflow", data->location);
}
@@ -173,7 +176,7 @@ void __ubsan_handle_add_overflow(struct overflow_data *data)
*
* @param data Overflow information, generated by the compiler.
*/
-void __ubsan_handle_sub_overflow(struct overflow_data *data)
+void __ubsan_handle_sub_overflow(const struct overflow_data *data)
{
print_location("subtraction overflow", data->location);
}
@@ -183,7 +186,7 @@ void __ubsan_handle_sub_overflow(struct overflow_data *data)
*
* @param data Overflow information, generated by the compiler.
*/
-void __ubsan_handle_mul_overflow(struct overflow_data *data)
+void __ubsan_handle_mul_overflow(const struct overflow_data *data)
{
print_location("multiplication overflow", data->location);
}
@@ -193,7 +196,7 @@ void __ubsan_handle_mul_overflow(struct overflow_data *data)
*
* @param data Overflow information, generated by the compiler.
*/
-void __ubsan_handle_divrem_overflow(struct overflow_data *data)
+void __ubsan_handle_divrem_overflow(const struct overflow_data *data)
{
print_location("division overflow", data->location);
}
@@ -203,7 +206,7 @@ void __ubsan_handle_divrem_overflow(struct overflow_data *data)
*
* @param data Overflow information, generated by the compiler.
*/
-void __ubsan_handle_negate_overflow(struct overflow_data *data)
+void __ubsan_handle_negate_overflow(const struct overflow_data *data)
{
print_location("negation overflow", data->location);
}
@@ -213,7 +216,7 @@ void __ubsan_handle_negate_overflow(struct overflow_data *data)
*
* @param data Overflow information, generated by the compiler.
*/
-void __ubsan_handle_pointer_overflow(struct overflow_data *data)
+void __ubsan_handle_pointer_overflow(const struct overflow_data *data)
{
print_location("pointer overflow", data->location);
}
@@ -223,8 +226,7 @@ void __ubsan_handle_pointer_overflow(struct overflow_data *data)
*
* @param data Out of bounds information, generated by the compiler.
*/
-void __ubsan_handle_shift_out_of_bounds(
- struct shift_out_of_bounds_data *data)
+void __ubsan_handle_shift_out_of_bounds(const struct shift_out_of_bounds_data *data)
{
print_location("shift out of bounds", data->location);
}
@@ -234,7 +236,7 @@ void __ubsan_handle_shift_out_of_bounds(
*
* @param data Load information, generated by the compiler.
*/
-void __ubsan_handle_load_invalid_value(struct invalid_value_data *data)
+void __ubsan_handle_load_invalid_value(const struct invalid_value_data *data)
{
print_location("invalid load value", data->location);
}
@@ -244,7 +246,7 @@ void __ubsan_handle_load_invalid_value(struct invalid_value_data *data)
*
* @param data Out of bounds information, generated by the compiler.
*/
-void __ubsan_handle_out_of_bounds(struct array_out_of_bounds_data *data)
+void __ubsan_handle_out_of_bounds(const struct array_out_of_bounds_data *data)
{
print_location("array out of bounds", data->location);
}
@@ -255,7 +257,7 @@ void __ubsan_handle_out_of_bounds(struct array_out_of_bounds_data *data)
* @param data Type mismatch information, generated by the compiler.
* @param ptr Pointer that caused a mismatch.
*/
-void __ubsan_handle_type_mismatch_v1(struct type_mismatch_v1_data *data,
+void __ubsan_handle_type_mismatch_v1(const struct type_mismatch_v1_data *data,
uintptr_t ptr)
{
if (!ptr) {
@@ -274,7 +276,7 @@ void __ubsan_handle_type_mismatch_v1(struct type_mismatch_v1_data *data,
*
* @param data VLA information, generated by the compiler.
*/
-void __ubsan_handle_vla_bound_not_positive(struct negative_vla_data *data)
+void __ubsan_handle_vla_bound_not_positive(const struct negative_vla_data *data)
{
print_location("variable-length argument is negative",
data->location);
@@ -285,7 +287,7 @@ void __ubsan_handle_vla_bound_not_positive(struct negative_vla_data *data)
*
* @param data Return information, generated by compiler.
*/
-void __ubsan_handle_nonnull_return(struct nonnull_return_data *data)
+void __ubsan_handle_nonnull_return(const struct nonnull_return_data *data)
{
print_location("non-null return is null", data->location);
}
@@ -295,7 +297,7 @@ void __ubsan_handle_nonnull_return(struct nonnull_return_data *data)
*
* @param data Argument information, generated by compiler.
*/
-void __ubsan_handle_nonnull_arg(struct nonnull_arg_data *data)
+void __ubsan_handle_nonnull_arg(const struct nonnull_arg_data *data)
{
print_location("non-null argument is null", data->location);
}
@@ -305,7 +307,7 @@ void __ubsan_handle_nonnull_arg(struct nonnull_arg_data *data)
*
* @param data Unreachable code information, generated by compiler.
*/
-void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
+void __ubsan_handle_builtin_unreachable(const struct unreachable_data *data)
{
print_location("unreachable code reached", data->location);
}
@@ -315,7 +317,9 @@ void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
*
* @param data Builtin information, generated by compiler.
*/
-void __ubsan_handle_invalid_builtin(struct invalid_builtin_data *data)
+void __ubsan_handle_invalid_builtin(const struct invalid_builtin_data *data)
{
print_location("invalid builtin", data->location);
}
+
+#endif