Prevent SEGV in ansto_sctdriveadapter on node not found and add names to messages

This commit is contained in:
Douglas Clowes
2014-06-20 13:15:26 +10:00
parent fc85619eac
commit 68afbed2ce

View File

@ -310,7 +310,7 @@ int ANSTO_SctMakeDriveAdapter(SConnection *pCon, SicsInterp *pSics, void *object
pSICSOBJ obj = NULL;
hdbCallback *cb;
if(argc < 4){
if(argc < 5){
SCWrite(pCon,"ERROR: not enough arguments for ANSTO_SctMakeDriveAdapter", eError);
return 0;
}
@ -324,19 +324,21 @@ int ANSTO_SctMakeDriveAdapter(SConnection *pCon, SicsInterp *pSics, void *object
pNew->write_node = FindHdbNode(NULL, argv[2], pCon);
if (pNew->write_node == NULL)
SCWrite(pCon, "ERROR: write-node not found", eError);
if (pNew->write_node->value.dataType != HIPFLOAT && pNew->write_node->value.dataType != HIPINT) {
SCWrite(pCon, "ERROR: write-node not INT or FLOAT", eError);
SCPrintf(pCon, eError, "ERROR: write-node %s not found", argv[2]);
else if (pNew->write_node->value.dataType != HIPFLOAT && pNew->write_node->value.dataType != HIPINT) {
SCPrintf(pCon, eError, "ERROR: write-node %s not INT or FLOAT", argv[2]);
pNew->write_node = NULL;
}
pNew->read_node = FindHdbNode(NULL, argv[3], pCon);
if (pNew->read_node->value.dataType != HIPFLOAT && pNew->read_node->value.dataType != HIPINT) {
SCWrite(pCon, "ERROR: read-node not INT or FLOAT", eError);
if (pNew->read_node == NULL)
SCPrintf(pCon, eError, "ERROR: read-node %s not found", argv[3]);
else if (pNew->read_node->value.dataType != HIPFLOAT && pNew->read_node->value.dataType != HIPINT) {
SCPrintf(pCon, eError, "ERROR: read-node %s not INT or FLOAT", argv[3]);
pNew->write_node = NULL;
}
obj = FindCommandData(pSics,argv[4], "SctController");
if (obj == NULL)
SCWrite(pCon, "ERROR: controller not found", eError);
SCPrintf(pCon, eError, "ERROR: controller %s not found", argv[4]);
if (pNew->write_node == NULL || pNew->read_node == NULL || obj == NULL) {
SctDriveKill(pNew);
return 0;