From daa62c1cb19287b2831fe6d121e915af3300ae72 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 16 Apr 2021 13:47:38 -0400 Subject: [PATCH] Fix #1349, remove unneeded CFE_ES_SYSLOG_APPEND macro Replace remaining uses of this internal macro with the CFE_ES_WriteToSysLog API. --- modules/es/fsw/src/cfe_es_cds.c | 14 +++++----- modules/es/fsw/src/cfe_es_cds_mempool.c | 34 ++++++++----------------- modules/es/fsw/src/cfe_es_log.h | 20 --------------- 3 files changed, 16 insertions(+), 52 deletions(-) diff --git a/modules/es/fsw/src/cfe_es_cds.c b/modules/es/fsw/src/cfe_es_cds.c index 9e6d58603..3cbd1db4c 100644 --- a/modules/es/fsw/src/cfe_es_cds.c +++ b/modules/es/fsw/src/cfe_es_cds.c @@ -885,10 +885,9 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) /* Report any errors incurred while freeing the CDS Memory Block */ if (Status != CFE_SUCCESS) { - CFE_ES_SysLog_snprintf( - LogMessage, sizeof(LogMessage), - "CFE_ES:DeleteCDS-Failed to free CDS Mem Block (Handle=0x%08lX)(Stat=0x%08X)\n", - (unsigned long)RegRecPtr->BlockOffset, (unsigned int)Status); + snprintf(LogMessage, sizeof(LogMessage), + "Failed to free CDS Mem Block (Handle=0x%08lX)(Stat=0x%08X)\n", + (unsigned long)RegRecPtr->BlockOffset, (unsigned int)Status); } else { @@ -899,9 +898,8 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) if (Status != CFE_SUCCESS) { - CFE_ES_SysLog_snprintf(LogMessage, sizeof(LogMessage), - "CFE_ES:DeleteCDS-Failed to update CDS Registry (Stat=0x%08X)\n", - (unsigned int)Status); + snprintf(LogMessage, sizeof(LogMessage), "Failed to update CDS Registry (Stat=0x%08X)\n", + (unsigned int)Status); } } } @@ -922,7 +920,7 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices) /* Output the message to syslog once the CDS registry resource is unlocked */ if (LogMessage[0] != 0) { - CFE_ES_SYSLOG_APPEND(LogMessage); + CFE_ES_WriteToSysLog("%s(): %s", __func__, LogMessage); } return Status; diff --git a/modules/es/fsw/src/cfe_es_cds_mempool.c b/modules/es/fsw/src/cfe_es_cds_mempool.c index 4f02386fc..ee2845058 100644 --- a/modules/es/fsw/src/cfe_es_cds_mempool.c +++ b/modules/es/fsw/src/cfe_es_cds_mempool.c @@ -201,14 +201,12 @@ int32 CFE_ES_CDSBlockWrite(CFE_ES_CDSHandle_t Handle, const void *DataToWrite) Status = CFE_ES_GenPoolGetBlockSize(&CDS->Pool, &BlockSize, CDSRegRecPtr->BlockOffset); if (Status != CFE_SUCCESS) { - CFE_ES_SysLog_snprintf(LogMessage, sizeof(LogMessage), - "CFE_ES:CDSBlkWrite-Invalid Handle or Block Descriptor.\n"); + snprintf(LogMessage, sizeof(LogMessage), "Invalid Handle or Block Descriptor.\n"); } else if (BlockSize <= sizeof(CFE_ES_CDS_BlockHeader_t) || BlockSize != CDSRegRecPtr->BlockSize) { - CFE_ES_SysLog_snprintf(LogMessage, sizeof(LogMessage), - "CFE_ES:CDSBlkWrite-Block size %lu invalid, expected %lu\n", - (unsigned long)BlockSize, (unsigned long)CDSRegRecPtr->BlockSize); + snprintf(LogMessage, sizeof(LogMessage), "Block size %lu invalid, expected %lu\n", (unsigned long)BlockSize, + (unsigned long)CDSRegRecPtr->BlockSize); Status = CFE_ES_CDS_INVALID_SIZE; } else @@ -227,20 +225,18 @@ int32 CFE_ES_CDSBlockWrite(CFE_ES_CDSHandle_t Handle, const void *DataToWrite) Status = CFE_ES_CDS_CacheFlush(&CDS->Cache); if (Status != CFE_SUCCESS) { - CFE_ES_SysLog_snprintf( - LogMessage, sizeof(LogMessage), - "CFE_ES:CDSBlkWrite-Err writing header data to CDS (Stat=0x%08x) @Offset=0x%08lx\n", - (unsigned int)CDS->Cache.AccessStatus, (unsigned long)CDSRegRecPtr->BlockOffset); + snprintf(LogMessage, sizeof(LogMessage), + "Err writing header data to CDS (Stat=0x%08x) @Offset=0x%08lx\n", + (unsigned int)CDS->Cache.AccessStatus, (unsigned long)CDSRegRecPtr->BlockOffset); } else { Status = CFE_PSP_WriteToCDS(DataToWrite, UserDataOffset, UserDataSize); if (Status != CFE_PSP_SUCCESS) { - CFE_ES_SysLog_snprintf( - LogMessage, sizeof(LogMessage), - "CFE_ES:CDSBlkWrite-Err writing user data to CDS (Stat=0x%08x) @Offset=0x%08lx\n", - (unsigned int)Status, (unsigned long)UserDataOffset); + snprintf(LogMessage, sizeof(LogMessage), + "Err writing user data to CDS (Stat=0x%08x) @Offset=0x%08lx\n", (unsigned int)Status, + (unsigned long)UserDataOffset); } } } @@ -255,7 +251,7 @@ int32 CFE_ES_CDSBlockWrite(CFE_ES_CDSHandle_t Handle, const void *DataToWrite) /* Do the actual syslog if something went wrong */ if (LogMessage[0] != 0) { - CFE_ES_SYSLOG_APPEND(LogMessage); + CFE_ES_WriteToSysLog("%s(): %s", __func__, LogMessage); } return Status; @@ -271,7 +267,6 @@ int32 CFE_ES_CDSBlockWrite(CFE_ES_CDSHandle_t Handle, const void *DataToWrite) int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE]; int32 Status; uint32 CrcOfCDSData; size_t BlockSize; @@ -279,9 +274,6 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) size_t UserDataOffset; CFE_ES_CDS_RegRec_t * CDSRegRecPtr; - /* Validate the handle before doing anything */ - LogMessage[0] = 0; - CDSRegRecPtr = CFE_ES_LocateCDSBlockRecordByID(Handle); /* @@ -345,12 +337,6 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle) CFE_ES_UnlockCDS(); - /* Do the actual syslog if something went wrong */ - if (LogMessage[0] != 0) - { - CFE_ES_SYSLOG_APPEND(LogMessage); - } - return Status; } diff --git a/modules/es/fsw/src/cfe_es_log.h b/modules/es/fsw/src/cfe_es_log.h index cac9267c7..6dfb7c55b 100644 --- a/modules/es/fsw/src/cfe_es_log.h +++ b/modules/es/fsw/src/cfe_es_log.h @@ -85,26 +85,6 @@ */ #define CFE_ES_SYSLOG_READ_BUFFER_SIZE (3 * CFE_ES_MAX_SYSLOG_MSG_SIZE) -/** - * \brief Self-synchronized macro to call CFE_ES_SysLogAppend_Unsync - * - * Calls CFE_ES_SysLogAppend_Unsync() with appropriate synchronization. - * It will acquire the shared data lock and release it after appending the log. - * - * This is implemented as a macro such that the "__func__" and "__LINE__" directives - * will reflect the actual place that the append was done, rather than where this - * wrapper was defined. - * - * \sa CFE_ES_SysLogAppend_Unsync() - */ -#define CFE_ES_SYSLOG_APPEND(LogString) \ - { \ - CFE_ES_LockSharedData(__func__, __LINE__); \ - CFE_ES_SysLogAppend_Unsync(LogString); \ - CFE_ES_UnlockSharedData(__func__, __LINE__); \ - OS_printf("%s", LogString); \ - } - /** * \brief Indicates no context information Error Logs *