- After a bug at TRICS I replaced all occurrences of strcpy, strcat, sprintf

by length limited versions wherever appropriate.


SKIPPED:
	psi/el755driv.c
	psi/faverage.c
	psi/frame.c
	psi/lmd200.c
	psi/polterwrite.c
	psi/psi.c
	psi/sanswave.c
	psi/sinqhmdriv.c
	psi/termprot.c
This commit is contained in:
koennecke
2009-12-04 12:58:31 +00:00
parent 297f9f2e02
commit 8cc5474334
80 changed files with 899 additions and 881 deletions

44
drive.c
View File

@ -66,7 +66,7 @@ int Drive(SConnection * pCon, SicsInterp * pInter, char *name, float fNew)
/* check if user is allowed to drive */
if (!SCMatchRights(pCon, usUser)) {
sprintf(pBueffel, "Insuficient Privilege to drive %s", name);
snprintf(pBueffel, 511, "Insuficient Privilege to drive %s", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -74,7 +74,7 @@ int Drive(SConnection * pCon, SicsInterp * pInter, char *name, float fNew)
/* first try to find the thing to drive */
pObject = FindCommand(pInter, name);
if (!pObject) {
sprintf(pBueffel, "Cannot find %s to drive ", name);
snprintf(pBueffel,511, "Cannot find %s to drive ", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -85,7 +85,7 @@ int Drive(SConnection * pCon, SicsInterp * pInter, char *name, float fNew)
pDum = (Dummy *) pObject->pData;
pDes = pDum->pDescriptor;
if (!pDes) {
sprintf(pBueffel, "%s is NOT drivable!", pDes->name);
snprintf(pBueffel,511, "%s is NOT drivable!", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -96,7 +96,7 @@ int Drive(SConnection * pCon, SicsInterp * pInter, char *name, float fNew)
pInt = pDes->GetInterface(pDum, DRIVEID);
if (!pInt) {
sprintf(pBueffel, "%s is NOT drivable!", pDes->name);
snprintf(pBueffel,511, "%s is NOT drivable!", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -109,7 +109,7 @@ int Drive(SConnection * pCon, SicsInterp * pInter, char *name, float fNew)
}
iRet = StartDevice(GetExecutor(), name, pDes, pDum, pCon, RUNDRIVE, fNew);
if (!iRet) {
sprintf(pBueffel, "ERROR: cannot start device %s", name);
snprintf(pBueffel,511, "ERROR: cannot start device %s", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -120,23 +120,23 @@ int Drive(SConnection * pCon, SicsInterp * pInter, char *name, float fNew)
if (iRet == DEVINT) {
if (SCGetInterrupt(pCon) == eAbortOperation) {
SCSetInterrupt(pCon, eContinue);
sprintf(pBueffel, "Driving %s aborted at %9.3f", name, fPos);
snprintf(pBueffel, 511, "Driving %s aborted at %9.3f", name, fPos);
SCWrite(pCon, pBueffel, eError);
}
return 0;
} else if (iRet == DEVDONE) {
sprintf(pBueffel, "Driving %s to %9.3f done", name, fPos);
snprintf(pBueffel, 511, "Driving %s to %9.3f done", name, fPos);
SCWrite(pCon, pBueffel, eValue);
return 1;
} else {
sprintf(pBueffel,
snprintf(pBueffel, 511,
"Driving %s finished with problems, position: %9.3f", name,
fPos);
SCWrite(pCon, pBueffel, eValue);
return 1;
}
}
sprintf(pBueffel, "%s is NOT drivable", pDes->name);
snprintf(pBueffel, 511, "%s is NOT drivable", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -159,7 +159,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
/* check if user is allowed to drive */
if (!SCMatchRights(pCon, usUser)) {
sprintf(pBueffel, "Insuficient Privilege to drive %s", name);
snprintf(pBueffel,511, "Insuficient Privilege to drive %s", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -167,7 +167,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
/* first try to find the thing to drive */
pObject = FindCommand(pInter, name);
if (!pObject) {
sprintf(pBueffel, "Cannot find %s to drive ", name);
snprintf(pBueffel,511, "Cannot find %s to drive ", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -178,7 +178,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
pDum = (Dummy *) pObject->pData;
pDes = pDum->pDescriptor;
if (!pDes) {
sprintf(pBueffel, "%s is NOT drivable!", pDes->name);
snprintf(pBueffel,511, "%s is NOT drivable!", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -188,7 +188,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
*/
pInt = pDes->GetInterface(pDum, DRIVEID);
if (!pInt) {
sprintf(pBueffel, "%s is NOT drivable!", pDes->name);
snprintf(pBueffel,511, "%s is NOT drivable!", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -206,7 +206,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
return 1;
}
} else {
sprintf(pBueffel, "%s is NOT drivable", pDes->name);
snprintf(pBueffel,511, "%s is NOT drivable", pDes->name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -251,7 +251,7 @@ static float findPosition(SicsInterp * pSics, SConnection * pCon,
if (pDes) {
pInt = pDes->GetInterface(pDum, DRIVEID);
if (!pInt) {
sprintf(pBueffel,
snprintf(pBueffel,131,
"ERROR: internal error in findPosition for %s", name);
SCWrite(pCon, pBueffel, eError);
return -999.99;
@ -285,7 +285,7 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
argtolower(argc, argv);
/* check no of args */
if (argc < 3) {
sprintf(pBueffel, "Insufficient number of args. Usage %s name val",
snprintf(pBueffel, 511,"Insufficient number of args. Usage %s name val",
argv[0]);
SCWrite(pCon, pBueffel, eError);
return 0;
@ -303,7 +303,7 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
SetStatus(eDriving);
for (i = 1; i < argc; i += 2) {
if (argv[i + 1] == NULL) {
sprintf(pBueffel, "ERROR: no value found for driving %s", argv[i]);
snprintf(pBueffel, 511, "ERROR: no value found for driving %s", argv[i]);
SCWrite(pCon, pBueffel, eError);
SetStatus(eOld);
return 0;
@ -317,7 +317,7 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
}
iRet = Start2Run(pCon, pSics, argv[i], RUNDRIVE, dTarget);
if (!iRet) {
sprintf(pBueffel, "ERROR: cannot run %s to %s", argv[i],
snprintf(pBueffel, 511,"ERROR: cannot run %s to %s", argv[i],
argv[i + 1]);
SCWrite(pCon, pBueffel, eError);
StopExe(GetExecutor(), "ALL");
@ -331,7 +331,7 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
/* print positions */
for (i = 1; i < argc; i += 2) {
sprintf(pBueffel, "New %s position: %9.3f", argv[i],
snprintf(pBueffel,511, "New %s position: %9.3f", argv[i],
findPosition(pSics, pCon, argv[i]));
SCWrite(pCon, pBueffel, eValue);
}
@ -377,7 +377,7 @@ int RunWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
/* check no of args */
if (argc < 3) {
sprintf(pBueffel, "Insufficient number of args. Usage %s name val",
snprintf(pBueffel,511, "Insufficient number of args. Usage %s name val",
argv[0]);
SCWrite(pCon, pBueffel, eError);
return 0;
@ -395,7 +395,7 @@ int RunWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
SetStatus(eDriving);
for (i = 1; i < argc; i += 2) {
if (argv[i + 1] == NULL) {
sprintf(pBueffel, "ERROR: no value found for driving %s", argv[i]);
snprintf(pBueffel,511, "ERROR: no value found for driving %s", argv[i]);
SCWrite(pCon, pBueffel, eError);
SetStatus(eOld);
return 0;
@ -409,7 +409,7 @@ int RunWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
}
iRet = Start2Run(pCon, pSics, argv[i], RUNRUN, dTarget);
if (!iRet) {
sprintf(pBueffel, "ERROR: cannot run %s to %s", argv[i],
snprintf(pBueffel, 511, "ERROR: cannot run %s to %s", argv[i],
argv[i + 1]);
SCWrite(pCon, pBueffel, eError);
StopExe(GetExecutor(), "ALL");