Ensure the string VAL and OVAL have the same storage length

There won't be any problems with overflow as long as dbPut
behaves correctly when setting VAL.
This commit is contained in:
Michael Davidsaver authored and Michael Davidsaver committed 2010-04-06 14:48:48 -04:00
1 parent b63e381fbe
commit e8f56d08b8
3 files changed
+9 -6

No files matched your search

+1
View File
@@ -210,6 +210,7 @@ static long init_record(aSubRecord *prec, int pass)
return S_db_BadSub;
}
}
STATIC_ASSERT(sizeof(prec->onam)==sizeof(prec->snam));
strcpy(prec->onam, prec->snam);
prec->oval = prec->val;
return 0;
+4 -3
View File
@@ -119,7 +119,8 @@ static long init_record(stringinRecord *prec, int pass)
if( pdset->init_record ) {
if((status=(*pdset->init_record)(prec))) return(status);
}
strncpy(prec->oval,prec->val,sizeof(prec->val));
STATIC_ASSERT(sizeof(prec->oval)==sizeof(prec->val));
strcpy(prec->oval,prec->val);
return(0);
}
@@ -158,9 +159,9 @@ static void monitor(stringinRecord *prec)
unsigned short monitor_mask;
monitor_mask = recGblResetAlarms(prec);
if(strncmp(prec->oval,prec->val,sizeof(prec->val))) {
if(strcmp(prec->oval,prec->val)) {
monitor_mask |= DBE_VALUE|DBE_LOG;
strncpy(prec->oval,prec->val,sizeof(prec->val));
strcpy(prec->oval,prec->val);
}
if (prec->mpst == stringinPOST_Always)
monitor_mask |= DBE_VALUE;
+4 -3
View File
@@ -121,7 +121,8 @@ static long init_record(stringoutRecord *prec, int pass)
if( pdset->init_record ) {
if((status=(*pdset->init_record)(prec))) return(status);
}
strncpy(prec->oval,prec->val,sizeof(prec->val));
STATIC_ASSERT(sizeof(prec->oval)==sizeof(prec->val));
strcpy(prec->oval,prec->val);
return(0);
}
@@ -186,9 +187,9 @@ static void monitor(stringoutRecord *prec)
unsigned short monitor_mask;
monitor_mask = recGblResetAlarms(prec);
if(strncmp(prec->oval,prec->val,sizeof(prec->val))) {
if(strcmp(prec->oval,prec->val)) {
monitor_mask |= DBE_VALUE|DBE_LOG;
strncpy(prec->oval,prec->val,sizeof(prec->val));
strcpy(prec->oval,prec->val);
}
if (prec->mpst == stringoutPOST_Always)
monitor_mask |= DBE_VALUE;