Silence unused variable warning in release build

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-03-30 22:57:29 +00:00
parent 63dd16ebac
commit 0733f7540f
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
2 changed files with 10 additions and 9 deletions

View File

@ -557,8 +557,8 @@ static bool gl_init_blur(struct gl_data *gd, conv *const *const kernels) {
char *shader_str = ccalloc(shader_len, char); char *shader_str = ccalloc(shader_len, char);
auto real_shader_len = snprintf( auto real_shader_len = snprintf(
shader_str, shader_len, FRAG_SHADER_BLUR, extension, shader_body, sum); shader_str, shader_len, FRAG_SHADER_BLUR, extension, shader_body, sum);
assert(real_shader_len >= 0); CHECK(real_shader_len >= 0);
assert((size_t)real_shader_len < shader_len); CHECK((size_t)real_shader_len < shader_len);
free(shader_body); free(shader_body);
// Build program // Build program

View File

@ -41,7 +41,6 @@ safe_isnan(double a) {
assert(false); \ assert(false); \
abort(); \ abort(); \
} while (0) } while (0)
/// Same as assert, but evaluates the expression even in release builds /// Same as assert, but evaluates the expression even in release builds
#define CHECK(expr) \ #define CHECK(expr) \
do { \ do { \
@ -51,6 +50,8 @@ safe_isnan(double a) {
} while (0) } while (0)
// Some macros for checked cast // 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) \ #define to_int_checked(val) \
({ \ ({ \
@ -83,9 +84,9 @@ safe_isnan(double a) {
#define to_u32_checked(val) \ #define to_u32_checked(val) \
({ \ ({ \
auto tmp = (val); \ auto tmp = (val); \
int64_t max = UINT32_MAX; /* silence clang tautological comparison \ int64_t max = UINT32_MAX; /* silence clang tautological \
warning*/ \ comparison warning*/ \
assert(tmp >= 0 && tmp <= max); \ CHECK(tmp >= 0 && tmp <= max); \
(uint32_t) tmp; \ (uint32_t) tmp; \
}) })
/** /**