easier fix for sanitization (by @velichkov)
diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c
index e9d6e87..5650368 100644
--- a/skeletons/INTEGER.c
+++ b/skeletons/INTEGER.c
@@ -791,25 +791,21 @@
#endif /* ASN_DISABLE_PER_SUPPORT */
+static intmax_t
+asn__integer_convert(const uint8_t *b, const uint8_t *end) {
+ uintmax_t value;
-/*
- * This function is only to get rid of Undefined Behavior Sanitizer warning.
- */
-static intmax_t CC_ATTR_NO_SANITIZE("shift-base")
-asn__safe_integer_convert_helper(const uint8_t *b, const uint8_t *end) {
- intmax_t value;
-
- /* Perform the sign initialization */
- /* Actually value = -(*b >> 7); gains nothing, yet unreadable! */
- if((*b >> 7)) {
- value = -1;
+ /* Perform the sign initialization */
+ /* Actually value = -(*b >> 7); gains nothing, yet unreadable! */
+ if((*b >> 7)) {
+ value = (uintmax_t)(-1);
} else {
value = 0;
}
/* Conversion engine */
- for(; b < end; b++) {
- value = (value << 8) | *b;
+ for(; b < end; b++) {
+ value = (value << 8) | *b;
}
return value;
@@ -862,7 +858,7 @@
return 0;
}
- *lptr = asn__safe_integer_convert_helper(b, end);
+ *lptr = asn__integer_convert(b, end);
return 0;
}
diff --git a/skeletons/NativeEnumerated_oer.c b/skeletons/NativeEnumerated_oer.c
index 9f564bc..f1eca86 100644
--- a/skeletons/NativeEnumerated_oer.c
+++ b/skeletons/NativeEnumerated_oer.c
@@ -9,18 +9,14 @@
#include <NativeEnumerated.h>
#include <errno.h>
-/*
- * This function is only to get rid of Undefined Behavior Sanitizer warning.
- */
-static intmax_t CC_ATTR_NO_SANITIZE("shift-base")
-asn__safe_nativeenumerated_convert_helper(const uint8_t *b,
- const uint8_t *end) {
- intmax_t value;
+static intmax_t
+asn__nativeenumerated_convert(const uint8_t *b, const uint8_t *end) {
+ uintmax_t value;
/* Perform the sign initialization */
/* Actually value = -(*b >> 7); gains nothing, yet unreadable! */
if((*b >> 7)) {
- value = -1;
+ value = (uintmax_t)(-1);
} else {
value = 0;
}
@@ -77,7 +73,7 @@
b++;
bend = b + length;
- value = asn__safe_nativeenumerated_convert_helper(b, bend);
+ value = asn__nativeenumerated_convert(b, bend);
if(value < 0) {
const asn_INTEGER_specifics_t *specs =
(const asn_INTEGER_specifics_t *)td->specifics;