Tidy up UBSan detection

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/common.h b/library/common.h
index 808d13d..49c5826 100644
--- a/library/common.h
+++ b/library/common.h
@@ -78,12 +78,17 @@
  *
  * This list is incomplete.
  */
+#if defined(__has_feature)
+#if __has_feature(undefined_behavior_sanitizer)
+#define MBEDTLS_HAVE_UBSAN
+#endif
+#endif
+
 #if (defined(__i386__) || defined(__amd64__) || defined( __x86_64__) \
     || defined(__ARM_FEATURE_UNALIGNED) \
     || defined(__aarch64__) \
     || defined(__ARM_ARCH_8__) || defined(__ARM_ARCH_8A__) || defined(__ARM_ARCH_8M__) \
-    || defined(__ARM_ARCH_7A__)) \
-    && (!(defined(__has_feature) && __has_feature(undefined_behavior_sanitizer)))
+    || defined(__ARM_ARCH_7A__)) && !defined(MBEDTLS_HAVE_UBSAN)
 #define MBEDTLS_ALLOW_UNALIGNED_ACCESS
 #endif