From 96361abd973cbccb0576aa200885cb0b176f3dcb Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 9 Jan 2019 12:28:56 +0100 Subject: [PATCH] FIX: supress gcc warnings like libjansson https://github.com/akheron/jansson/pull/423/files --- client/jansson/Makefile | 2 +- client/jansson/error.c | 2 +- client/jansson/load.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/jansson/Makefile b/client/jansson/Makefile index 7657e35f3..596c1778c 100644 --- a/client/jansson/Makefile +++ b/client/jansson/Makefile @@ -32,7 +32,7 @@ CMDOBJS = $(CFILES:%.c=%.o) CLEAN = $(CMDOBJS) CC= gcc -CFLAGS= -O2 -Wall -Wno-unused-variable -Wno-unused-function +CFLAGS= -O2 -Wall -Wno-unused-variable -Wno-unused-function -Wno-format-truncation LDFLAGS= $(SYSLDFLAGS) $(libjansson_la_LDFLAGS) LIBS= $(SYSLIBS) $(MYLIBS) DEFAULT_INCLUDES = -I. diff --git a/client/jansson/error.c b/client/jansson/error.c index f5da6b9b0..b94b3a3a1 100644 --- a/client/jansson/error.c +++ b/client/jansson/error.c @@ -25,7 +25,7 @@ void jsonp_error_set_source(json_error_t *error, const char *source) length = strlen(source); if(length < JSON_ERROR_SOURCE_LENGTH) - strncpy(error->source, source, length + 1); + strncpy(error->source, source, JSON_ERROR_SOURCE_LENGTH); else { size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; memcpy(error->source, "...", 3); diff --git a/client/jansson/load.c b/client/jansson/load.c index 9f73ea02c..2f123724e 100644 --- a/client/jansson/load.c +++ b/client/jansson/load.c @@ -89,7 +89,7 @@ static void error_set(json_error_t *error, const lex_t *lex, { va_list ap; char msg_text[JSON_ERROR_TEXT_LENGTH]; - char msg_with_context[JSON_ERROR_TEXT_LENGTH + 20]; + char msg_with_context[JSON_ERROR_TEXT_LENGTH]; int line = -1, col = -1; size_t pos = 0; @@ -115,7 +115,7 @@ static void error_set(json_error_t *error, const lex_t *lex, { if(lex->saved_text.length <= 20) { snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near '%s'", msg_text, saved_text); - msg_with_context[JSON_ERROR_TEXT_LENGTH + 20 - 1] = '\0'; + msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; result = msg_with_context; } } @@ -131,7 +131,7 @@ static void error_set(json_error_t *error, const lex_t *lex, } else { snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near end of file", msg_text); - msg_with_context[JSON_ERROR_TEXT_LENGTH + 20 - 1] = '\0'; + msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; result = msg_with_context; } }