Assertions like this are a tool. They aid readabilityIt is not complexity but being explicit vs. implicit. The codingI don't agree with this characterization.+/* Verify the expression yields true, and fail at build time if possible */It will be much better for everyone if you don't obfuscate existing
+#define ipa_assert(dev, expr) \
+ do { \
+ if (__builtin_constant_p(expr)) \
+ compiletime_assert(expr, __ipa_failure_msg(expr)); \
+ else \
+ __ipa_assert_runtime(dev, expr); \
+ } while (0)
+
+/* Report an error if the given expression evaluates to false at runtime */
+#define ipa_assert_always(dev, expr) \
+ do { \
+ if (unlikely(!(expr))) { \
+ struct device *__dev = (dev); \
+ \
+ if (__dev) \
+ dev_err(__dev, __ipa_failure_msg(expr)); \
+ else \
+ pr_err(__ipa_failure_msg(expr)); \
+ } \
+ } while (0)
kernel primitives and don't hide constant vs. dynamic expressions.
Yes, there is some complexity in this one source file, where
ipa_assert() is defined. But as a result, callers are simple
one-line statements (similar to WARN_ON()).
style that has explicit flows will be always better than implicit
one. By adding your custom assert, you are hiding the flows and
makes unclear what can be evaluated at compilation and what can't.