Silence a warning in release build

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-02-21 14:15:25 +00:00
parent 350933a054
commit e82bc0ca23
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
2 changed files with 18 additions and 10 deletions

View File

@ -820,8 +820,7 @@ void get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
// Fill default blur kernel
if (opt->blur_background && !opt->blur_kerns[0]) {
bool ret = parse_blur_kern_lst("3x3box", opt->blur_kerns, MAX_BLUR_PASS, &conv_kern_hasneg);
assert(ret);
CHECK(parse_blur_kern_lst("3x3box", opt->blur_kerns, MAX_BLUR_PASS, &conv_kern_hasneg));
}
if (opt->resize_damage < 0) {

View File

@ -1,15 +1,15 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2018 Yuxuan Shui <yshuiv7@gmail.com>
#pragma once
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include "compiler.h"
@ -32,10 +32,19 @@ safe_isnan(double a) {
/// Same as assert false, but make sure we abort _even in release builds_.
/// Silence compiler warning caused by release builds making some code paths reachable.
attr_noret static inline void BUG(void) {
assert(false);
abort();
}
#define BUG() \
do { \
assert(false); \
abort(); \
} while (0)
/// Same as assert, but evaluates the expression even in release builds
#define CHECK(expr) \
do { \
__auto_type __tmp = (expr); \
assert(__tmp); \
(void)__tmp; \
} while (0)
/**
* Normalize an int value to a specific range.
@ -111,8 +120,8 @@ static inline double attr_const normalize_d(double d) {
return normalize_d_range(d, 0.0, 1.0);
}
attr_noret void report_allocation_failure(const char *func, const char *file,
unsigned int line);
attr_noret void
report_allocation_failure(const char *func, const char *file, unsigned int line);
/**
* @brief Quit if the passed-in pointer is empty.