Fix compiler warnings

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2019-02-02 01:58:41 +00:00
parent 465a968ddd
commit 0947148fcc
3 changed files with 15 additions and 3 deletions

View File

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