Silent properly GCC format-truncation warnings in jansson
This commit is contained in:
@@ -40,9 +40,6 @@ platform = $(shell uname)
|
|||||||
|
|
||||||
CC= gcc
|
CC= gcc
|
||||||
CFLAGS= -O2 -Wall -Wno-unused-variable -Wno-unused-function
|
CFLAGS= -O2 -Wall -Wno-unused-variable -Wno-unused-function
|
||||||
ifneq ($(platform),Darwin)
|
|
||||||
CFLAGS += -Wno-format-truncation
|
|
||||||
endif
|
|
||||||
|
|
||||||
LDFLAGS= $(SYSLDFLAGS) $(libjansson_la_LDFLAGS)
|
LDFLAGS= $(SYSLDFLAGS) $(libjansson_la_LDFLAGS)
|
||||||
LIBS= $(SYSLIBS) $(MYLIBS)
|
LIBS= $(SYSLIBS) $(MYLIBS)
|
||||||
|
|||||||
@@ -111,7 +111,11 @@ static void error_set(json_error_t *error, const lex_t *lex,
|
|||||||
|
|
||||||
if (saved_text && saved_text[0]) {
|
if (saved_text && saved_text[0]) {
|
||||||
if (lex->saved_text.length <= 20) {
|
if (lex->saved_text.length <= 20) {
|
||||||
snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near '%s'", msg_text, saved_text);
|
int ret = snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near '%s'", msg_text, saved_text);
|
||||||
|
if (ret < 0) {
|
||||||
|
jsonp_error_set(error, line, col, pos, code, "%s", "internal snprint error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
||||||
result = msg_with_context;
|
result = msg_with_context;
|
||||||
}
|
}
|
||||||
@@ -124,7 +128,11 @@ static void error_set(json_error_t *error, const lex_t *lex,
|
|||||||
/* No context for UTF-8 decoding errors */
|
/* No context for UTF-8 decoding errors */
|
||||||
result = msg_text;
|
result = msg_text;
|
||||||
} else {
|
} else {
|
||||||
snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near end of file", msg_text);
|
int ret = snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near end of file", msg_text);
|
||||||
|
if (ret < 0) {
|
||||||
|
jsonp_error_set(error, line, col, pos, code, "%s", "internal snprint error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
||||||
result = msg_with_context;
|
result = msg_with_context;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user