mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 15:57:13 +02:00
client multi.cpp modified common out of bounds error
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
|
||||
#define MULTI_HAVE_DIFFERENT_VALUES 0x4000000000000000ULL
|
||||
#define MULTI_CONFIG_FILE_ERROR 0x2000000000000000ULL
|
||||
#define MULTI_POS_EXCEEDS_LIST 0x1000000000000000ULL
|
||||
|
||||
// sls errors
|
||||
#define CRITICAL_ERROR_MASK 0xFFFFFFF
|
||||
|
@ -340,11 +340,10 @@ std::string multiSlsDetector::getErrorMessage(int& critical, int detPos) {
|
||||
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
// position exceeds multi list size
|
||||
if (detPos > detectors.size()) {
|
||||
FILE_LOG(logERROR) << "Position " << detPos << " exceeds list of " << detectors.size();
|
||||
|
||||
if(isDetectorIndexOutOfBounds())
|
||||
return retval;
|
||||
}
|
||||
|
||||
slsMask = getErrorMask();
|
||||
posmin = (unsigned int)detPos;
|
||||
posmax = posmin + 1;
|
||||
@ -404,14 +403,8 @@ int64_t multiSlsDetector::clearAllErrorMask(int detPos) {
|
||||
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
|
||||
// position exceeds multi list size
|
||||
if (detPos > detectors.size()) {
|
||||
FILE_LOG(logERROR) << "Position " << detPos << " exceeds list of " << detectors.size();
|
||||
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
|
||||
if(isDetectorIndexOutOfBounds())
|
||||
return -1;
|
||||
}
|
||||
|
||||
return detectors[idet]->clearErrorMask();
|
||||
}
|
||||
|
||||
@ -456,12 +449,8 @@ int multiSlsDetector::checkVersionCompatibility(portType t, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
|
||||
// position exceeds multi list size
|
||||
if (detPos > detectors.size()) {
|
||||
FILE_LOG(logERROR) << "Position " << detPos << " exceeds list of " << detectors.size();
|
||||
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
|
||||
if(isDetectorIndexOutOfBounds())
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = detectors[detPos]->checkVersionCompatibility(t);
|
||||
if (detectors[detPos]->getErrorMask())
|
||||
@ -478,12 +467,8 @@ int64_t multiSlsDetector::getId(idMode mode, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
|
||||
// position exceeds multi list size
|
||||
if (detPos > detectors.size()) {
|
||||
FILE_LOG(logERROR) << "Position " << detPos << " exceeds list of " << detectors.size();
|
||||
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
|
||||
if(isDetectorIndexOutOfBounds())
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t ret = detectors[detPos]->getId(mode);
|
||||
if (detectors[detPos]->getErrorMask())
|
||||
@ -4614,3 +4599,13 @@ int multiSlsDetector::kbhit() {
|
||||
select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
|
||||
return FD_ISSET(STDIN_FILENO, &fds);
|
||||
}
|
||||
|
||||
bool multiSlsDetector::isDetectorIndexOutOfBounds(int detPos) {
|
||||
// position exceeds multi list size
|
||||
if (detPos >= detectors.size()) {
|
||||
FILE_LOG(logERROR) << "Position " << detPos << " is out of bounds with a detector list of " << detectors.size();
|
||||
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1569,6 +1569,11 @@ public:
|
||||
*/
|
||||
int setThreadedProcessing(int enable=-1);
|
||||
|
||||
/**
|
||||
* Returns true if detector position is out of bounds
|
||||
*/
|
||||
bool isDetectorIndexOutOfBounds(int detPos);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Initialize (open/create) shared memory for the sharedMultiDetector structure
|
||||
|
Reference in New Issue
Block a user