Fix gcc warning 'stringop-truncation'
This commit is contained in:
@@ -365,13 +365,14 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options,
|
||||
}
|
||||
if( (*options) & DBR_AMSG ) {
|
||||
if (!pfl) {
|
||||
STATIC_ASSERT(sizeof(pcommon->amsg)==sizeof(pfl->amsg));
|
||||
strncpy(pbuffer, pcommon->amsg, sizeof(pcommon->amsg)-1);
|
||||
STATIC_ASSERT(sizeof(pcommon->amsg)==DB_AMSG_SIZE);
|
||||
strncpy(pbuffer, pcommon->amsg, DB_AMSG_SIZE);
|
||||
} else {
|
||||
strncpy(pbuffer, pfl->amsg,sizeof(pfl->amsg)-1);
|
||||
STATIC_ASSERT(sizeof(pfl->amsg)==DB_AMSG_SIZE);
|
||||
strncpy(pbuffer, pfl->amsg, DB_AMSG_SIZE);
|
||||
}
|
||||
pbuffer[sizeof(pcommon->amsg)-1] = '\0';
|
||||
pbuffer += sizeof(pcommon->amsg);
|
||||
pbuffer[DB_AMSG_SIZE-1] = '\0';
|
||||
pbuffer += DB_AMSG_SIZE;
|
||||
}
|
||||
if( (*options) & DBR_UNITS ) {
|
||||
memset(pbuffer,'\0',dbr_units_size);
|
||||
@@ -851,7 +852,7 @@ static long getLinkValue(DBADDR *paddr, short dbrType,
|
||||
{
|
||||
const char *rtnString = dbGetString(&dbEntry);
|
||||
|
||||
strncpy(pbuf, rtnString, maxlen-1);
|
||||
strncpy(pbuf, rtnString, maxlen);
|
||||
pbuf[maxlen-1] = 0;
|
||||
if(dbrType!=DBR_STRING)
|
||||
nReq = strlen(pbuf)+1;
|
||||
|
||||
@@ -743,8 +743,8 @@ static long dbAddOnePath (DBBASE *pdbbase, const char *path, unsigned length)
|
||||
ppathList = (ELLLIST *)pdbbase->pathPvt;
|
||||
|
||||
pdbPathNode = (dbPathNode *)dbCalloc(1, sizeof(dbPathNode));
|
||||
pdbPathNode->directory = (char *)dbCalloc(length+1, sizeof(char));
|
||||
strncpy(pdbPathNode->directory, path, length);
|
||||
pdbPathNode->directory = (char *)dbMalloc(length+1);
|
||||
strncpy(pdbPathNode->directory, path, length+1);
|
||||
pdbPathNode->directory[length] = '\0';
|
||||
ellAdd(ppathList, &pdbPathNode->node);
|
||||
return 0;
|
||||
|
||||
@@ -181,10 +181,10 @@ static long get_enum_str(const DBADDR *paddr, char *pstring)
|
||||
if(index!=biRecordVAL) {
|
||||
strcpy(pstring,"Illegal_Value");
|
||||
} else if(*pfield==0) {
|
||||
strncpy(pstring,prec->znam,sizeof(prec->znam));
|
||||
memcpy(pstring,prec->znam,sizeof(prec->znam));
|
||||
pstring[sizeof(prec->znam)] = 0;
|
||||
} else if(*pfield==1) {
|
||||
strncpy(pstring,prec->onam,sizeof(prec->onam));
|
||||
memcpy(pstring,prec->onam,sizeof(prec->onam));
|
||||
pstring[sizeof(prec->onam)] = 0;
|
||||
} else {
|
||||
strcpy(pstring,"Illegal_Value");
|
||||
@@ -198,9 +198,9 @@ static long get_enum_strs(const DBADDR *paddr,struct dbr_enumStrs *pes)
|
||||
|
||||
pes->no_str = 2;
|
||||
memset(pes->strs,'\0',sizeof(pes->strs));
|
||||
strncpy(pes->strs[0],prec->znam,sizeof(prec->znam));
|
||||
memcpy(pes->strs[0],prec->znam,sizeof(prec->znam));
|
||||
if(*prec->znam!=0) pes->no_str=1;
|
||||
strncpy(pes->strs[1],prec->onam,sizeof(prec->onam));
|
||||
memcpy(pes->strs[1],prec->onam,sizeof(prec->onam));
|
||||
if(*prec->onam!=0) pes->no_str=2;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -328,10 +328,10 @@ static long get_enum_str(const DBADDR *paddr, char *pstring)
|
||||
if(index!=indexof(VAL)) {
|
||||
strcpy(pstring,"Illegal_Value");
|
||||
} else if(*pfield==0) {
|
||||
strncpy(pstring,prec->znam,sizeof(prec->znam));
|
||||
memcpy(pstring,prec->znam,sizeof(prec->znam));
|
||||
pstring[sizeof(prec->znam)] = 0;
|
||||
} else if(*pfield==1) {
|
||||
strncpy(pstring,prec->onam,sizeof(prec->onam));
|
||||
memcpy(pstring,prec->onam,sizeof(prec->onam));
|
||||
pstring[sizeof(prec->onam)] = 0;
|
||||
} else {
|
||||
strcpy(pstring,"Illegal_Value");
|
||||
@@ -346,9 +346,9 @@ static long get_enum_strs(const DBADDR *paddr,struct dbr_enumStrs *pes)
|
||||
/*SETTING no_str=0 breaks channel access clients*/
|
||||
pes->no_str = 2;
|
||||
memset(pes->strs,'\0',sizeof(pes->strs));
|
||||
strncpy(pes->strs[0],prec->znam,sizeof(pes->strs[0]));
|
||||
memcpy(pes->strs[0],prec->znam,sizeof(pes->strs[0]));
|
||||
if(*prec->znam!=0) pes->no_str=1;
|
||||
strncpy(pes->strs[1],prec->onam,sizeof(pes->strs[1]));
|
||||
memcpy(pes->strs[1],prec->onam,sizeof(pes->strs[1]));
|
||||
if(*prec->onam!=0) pes->no_str=2;
|
||||
return(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user