Mark report_allocation_failure as noreturn
Silence an static analyzer warning Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
1c0770dc66
commit
311fa65840
49
src/utils.h
49
src/utils.h
@ -2,12 +2,12 @@
|
||||
// Copyright (c) 2018 Yuxuan Shui <yshuiv7@gmail.com>
|
||||
#pragma once
|
||||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "compiler.h"
|
||||
@ -24,7 +24,8 @@ __attribute__((optnone))
|
||||
#else
|
||||
__attribute__((optimize("-fno-fast-math")))
|
||||
#endif
|
||||
static inline bool safe_isnan(double a) {
|
||||
static inline bool
|
||||
safe_isnan(double a) {
|
||||
return isnan(a);
|
||||
}
|
||||
|
||||
@ -36,42 +37,39 @@ static inline bool safe_isnan(double a) {
|
||||
* @param max maximum value
|
||||
* @return normalized value
|
||||
*/
|
||||
static inline int attr_const
|
||||
normalize_i_range(int i, int min, int max) {
|
||||
if (i > max) return max;
|
||||
if (i < min) return min;
|
||||
static inline int attr_const normalize_i_range(int i, int min, int max) {
|
||||
if (i > max)
|
||||
return max;
|
||||
if (i < min)
|
||||
return min;
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the larger integer of two.
|
||||
*/
|
||||
static inline int attr_const
|
||||
max_i(int a, int b) {
|
||||
static inline int attr_const max_i(int a, int b) {
|
||||
return (a > b ? a : b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the smaller integer of two.
|
||||
*/
|
||||
static inline int attr_const
|
||||
min_i(int a, int b) {
|
||||
static inline int attr_const min_i(int a, int b) {
|
||||
return (a > b ? b : a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the larger long integer of two.
|
||||
*/
|
||||
static inline long attr_const
|
||||
max_l(long a, long b) {
|
||||
static inline long attr_const max_l(long a, long b) {
|
||||
return (a > b ? a : b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the smaller long integer of two.
|
||||
*/
|
||||
static inline long attr_const
|
||||
min_l(long a, long b) {
|
||||
static inline long attr_const min_l(long a, long b) {
|
||||
return (a > b ? b : a);
|
||||
}
|
||||
|
||||
@ -83,10 +81,11 @@ min_l(long a, long b) {
|
||||
* @param max maximum value
|
||||
* @return normalized value
|
||||
*/
|
||||
static inline double attr_const
|
||||
normalize_d_range(double d, double min, double max) {
|
||||
if (d > max) return max;
|
||||
if (d < min) return min;
|
||||
static inline double attr_const normalize_d_range(double d, double min, double max) {
|
||||
if (d > max)
|
||||
return max;
|
||||
if (d < min)
|
||||
return min;
|
||||
return d;
|
||||
}
|
||||
|
||||
@ -96,12 +95,12 @@ normalize_d_range(double d, double min, double max) {
|
||||
* @param d double value to normalize
|
||||
* @return normalized value
|
||||
*/
|
||||
static inline double attr_const
|
||||
normalize_d(double d) {
|
||||
static inline double attr_const normalize_d(double d) {
|
||||
return normalize_d_range(d, 0.0, 1.0);
|
||||
}
|
||||
|
||||
void report_allocation_failure(const char *func, const char *file, unsigned int line);
|
||||
void attr_noret report_allocation_failure(const char *func, const char *file,
|
||||
unsigned int line);
|
||||
|
||||
/**
|
||||
* @brief Quit if the passed-in pointer is empty.
|
||||
@ -183,3 +182,5 @@ typedef type name##_t; \
|
||||
type *name##_new(void); \
|
||||
void name##_ref(type *a); \
|
||||
void name##_unref(type **a);
|
||||
|
||||
// vim: set noet sw=8 ts=8 :
|
||||
|
Loading…
Reference in New Issue
Block a user