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);
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

View File

@ -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; \
})
/**