Fix compiler warnings
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
465a968ddd
commit
0947148fcc
|
@ -46,7 +46,8 @@ endif
|
|||
|
||||
add_global_arguments('-D_GNU_SOURCE', language: 'c')
|
||||
|
||||
warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow', 'implicit-fallthrough' ]
|
||||
warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow',
|
||||
'implicit-fallthrough', 'no-unknown-warning-option' ]
|
||||
foreach w : warns
|
||||
if cc.has_argument('-W'+w)
|
||||
add_global_arguments('-W'+w, language: 'c')
|
||||
|
|
|
@ -72,7 +72,7 @@ static attr_const const char *log_level_to_string(enum log_level level) {
|
|||
case LOG_LEVEL_WARN: return "WARN";
|
||||
case LOG_LEVEL_ERROR: return "ERROR";
|
||||
case LOG_LEVEL_FATAL: return "FATAL ERROR";
|
||||
default: assert(false);
|
||||
default: return "????";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ const char *terminal_colorize_begin(enum log_level level) {
|
|||
case LOG_LEVEL_WARN: return ANSI("33");
|
||||
case LOG_LEVEL_ERROR: return ANSI("31;1");
|
||||
case LOG_LEVEL_FATAL: return ANSI("30;103;1");
|
||||
default: assert(false);
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,15 @@
|
|||
#include "string_utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
|
||||
// gcc warns about legitimate strncpy in mstrjoin and mstrextend
|
||||
// strncpy(str, src1, len1) intentional truncates the null byte from src1.
|
||||
// strncpy(str+len1, src2, len2) uses bound depends on the source argument,
|
||||
// but str is allocated with len1+len2+1, so this strncpy can't overflow
|
||||
#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
|
||||
/**
|
||||
* Allocate the space and join two strings.
|
||||
*/
|
||||
|
@ -41,6 +50,8 @@ void mstrextend(char **psrc1, const char *src2) {
|
|||
(*psrc1)[len - 1] = '\0';
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
/// Parse a floating point number of form (+|-)?[0-9]*(\.[0-9]*)
|
||||
double strtod_simple(const char *src, const char **end) {
|
||||
double neg = 1;
|
||||
|
|
Loading…
Reference in New Issue