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