diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index 8cc91c8..f7aa943 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -557,8 +557,8 @@ static bool gl_init_blur(struct gl_data *gd, conv *const *const kernels) { char *shader_str = ccalloc(shader_len, char); auto real_shader_len = snprintf( shader_str, shader_len, FRAG_SHADER_BLUR, extension, shader_body, sum); - assert(real_shader_len >= 0); - assert((size_t)real_shader_len < shader_len); + CHECK(real_shader_len >= 0); + CHECK((size_t)real_shader_len < shader_len); free(shader_body); // Build program diff --git a/src/utils.h b/src/utils.h index 3256838..2b443c4 100644 --- a/src/utils.h +++ b/src/utils.h @@ -41,7 +41,6 @@ safe_isnan(double a) { assert(false); \ abort(); \ } while (0) - /// Same as assert, but evaluates the expression even in release builds #define CHECK(expr) \ do { \ @@ -51,17 +50,19 @@ safe_isnan(double a) { } while (0) // Some macros for checked cast +// Note these macros are not complete, as in, they won't work for every integer types. But +// they are good enough for compton. #define to_int_checked(val) \ ({ \ - int64_t tmp = (val); \ + int64_t tmp = (val); \ assert(tmp >= INT_MIN && tmp <= INT_MAX); \ (int)tmp; \ }) #define to_char_checked(val) \ ({ \ - int64_t tmp = (val); \ + int64_t tmp = (val); \ assert(tmp >= CHAR_MIN && tmp <= CHAR_MAX); \ (char)tmp; \ }) @@ -75,7 +76,7 @@ safe_isnan(double a) { #define to_i16_checked(val) \ ({ \ - int64_t tmp = (val); \ + int64_t tmp = (val); \ assert(tmp >= INT16_MIN && tmp <= INT16_MAX); \ (int16_t) tmp; \ }) @@ -83,9 +84,9 @@ safe_isnan(double a) { #define to_u32_checked(val) \ ({ \ auto tmp = (val); \ - int64_t max = UINT32_MAX; /* silence clang tautological comparison \ - warning*/ \ - assert(tmp >= 0 && tmp <= max); \ + int64_t max = UINT32_MAX; /* silence clang tautological \ + comparison warning*/ \ + CHECK(tmp >= 0 && tmp <= max); \ (uint32_t) tmp; \ }) /**