From 0174bce6892b7ab1cf8fcd6cce8a8cc784528231 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 17 Mar 2021 11:23:19 -0400 Subject: [PATCH] Fix #1195, Avoid implicit conversion from vsnprintf errors --- modules/evs/fsw/src/cfe_evs_utils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/evs/fsw/src/cfe_evs_utils.c b/modules/evs/fsw/src/cfe_evs_utils.c index de93e565f..d07c2b3e4 100644 --- a/modules/evs/fsw/src/cfe_evs_utils.c +++ b/modules/evs/fsw/src/cfe_evs_utils.c @@ -393,8 +393,11 @@ void EVS_GenerateEventTelemetry(EVS_AppData_t *AppDataPtr, uint16 EventID, uint1 ExpandedLength = vsnprintf((char *)LongEventTlm.Payload.Message, sizeof(LongEventTlm.Payload.Message), MsgSpec, ArgPtr); - /* Were any characters truncated in the buffer? */ - if (ExpandedLength >= sizeof(LongEventTlm.Payload.Message)) + /* + * If vsnprintf is bigger than message size, mark with truncation character + * Note negative returns (error from vsnprintf) willl just leave the message empty + */ + if (ExpandedLength >= (int)sizeof(LongEventTlm.Payload.Message)) { /* Mark character before zero terminator to indicate truncation */ LongEventTlm.Payload.Message[sizeof(LongEventTlm.Payload.Message) - 2] = CFE_EVS_MSG_TRUNCATED;