Fix mtce build error with gcc-8.2.1
1.Remove 'const' in DELIMITER to fix "Werror=ignored-qualifiers" 2.Replace sprintf with snprintf, and add return value check for snprintf to fix "Werror=format-overflow" 3.Replace strncpy with snprintf to fix "Werror=stringop-truncation" Change-Id: Iecca021fc02df35a472a3f8aa04c9501998e2dba Story: 2007506 Task: 39279 Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com> Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
This commit is contained in:
parent
b235d3c111
commit
456c255ea1
@ -20,7 +20,7 @@
|
|||||||
#include "hwmonGroup.h" /* for ... bmc_get_grouptype */
|
#include "hwmonGroup.h" /* for ... bmc_get_grouptype */
|
||||||
#include "hwmonAlarm.h" /* for ... hwmonAlarm */
|
#include "hwmonAlarm.h" /* for ... hwmonAlarm */
|
||||||
|
|
||||||
#define DELIMITER ((const char)',')
|
#define DELIMITER ((char)',')
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -332,7 +332,7 @@ int lmon_interfaces_init ( interface_ctrl_type * ptr, string physical_interface
|
|||||||
string line;
|
string line;
|
||||||
while ( getline( finTwo, line ) )
|
while ( getline( finTwo, line ) )
|
||||||
{
|
{
|
||||||
strncpy(line_buf, line.c_str(), MAX_CHARS_ON_LINE);
|
snprintf(line_buf, sizeof(line_buf), "%s", line.c_str());
|
||||||
|
|
||||||
// the slave interfaces are listed as enXYYY enXYYY...
|
// the slave interfaces are listed as enXYYY enXYYY...
|
||||||
// starting with the primary. Read all other slaves
|
// starting with the primary. Read all other slaves
|
||||||
|
@ -237,8 +237,9 @@ int active_monitor_dispatch ( void )
|
|||||||
char str[AMON_MAX_LEN] ;
|
char str[AMON_MAX_LEN] ;
|
||||||
unsigned int magic = 0 ;
|
unsigned int magic = 0 ;
|
||||||
int seq ;
|
int seq ;
|
||||||
|
int ret ;
|
||||||
|
|
||||||
memset (str, 0, AMON_MAX_LEN );
|
memset ( str, 0, sizeof(str) );
|
||||||
sscanf ( amon.rx_buf, "%s %8x %d", str, &magic, &seq );
|
sscanf ( amon.rx_buf, "%s %8x %d", str, &magic, &seq );
|
||||||
|
|
||||||
/* Fault Insertion Controls */
|
/* Fault Insertion Controls */
|
||||||
@ -256,8 +257,12 @@ int active_monitor_dispatch ( void )
|
|||||||
magic = magic ^ -1 ;
|
magic = magic ^ -1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset ( amon.tx_buf, 0 , AMON_MAX_LEN );
|
memset ( amon.tx_buf, 0, sizeof(amon.tx_buf) );
|
||||||
sprintf( amon.tx_buf, "%s %8x %d%c", str, magic, seq, '\0' );
|
ret = snprintf( amon.tx_buf, sizeof(amon.tx_buf), "%s %8x %d", str, magic, seq );
|
||||||
|
if ( ret >= (int)sizeof(amon.tx_buf) )
|
||||||
|
{
|
||||||
|
syslog ( LOG_ERR, "amon.tx_buf is truncated\n");
|
||||||
|
}
|
||||||
|
|
||||||
if ( strcmp ( str, amon.name ) )
|
if ( strcmp ( str, amon.name ) )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user