mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
fixes from review, moving from array to vector to avoid VLA
This commit is contained in:
@ -374,26 +374,16 @@ void setupDetector() {
|
||||
burstPeriodReg = 0;
|
||||
filter = 0;
|
||||
cdsGain = 0;
|
||||
for (int i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
dacValues[i] = 0;
|
||||
}
|
||||
memset(clkPhase, 0, sizeof(clkPhase));
|
||||
memset(dacValues, 0, sizeof(dacValues));
|
||||
for (int i = 0; i < ONCHIP_NDAC; ++i) {
|
||||
for (int j = 0; j < NCHIP; ++j) {
|
||||
onChipdacValues[i][j] = -1;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NCHIP; ++i) {
|
||||
for (int j = 0; j < NCHAN; ++j) {
|
||||
vetoReference[i][j] = 0;
|
||||
vetoGainIndices[i][j] = 0;
|
||||
}
|
||||
for (int j = 0; j < NADC; ++j) {
|
||||
adcConfiguration[i][j] = 0;
|
||||
}
|
||||
}
|
||||
memset(vetoReference, 0, sizeof(vetoReference));
|
||||
memset(vetoGainIndices, 0, sizeof(vetoGainIndices));
|
||||
memset(adcConfiguration, 0, sizeof(adcConfiguration));
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStatus(IDLE);
|
||||
#endif
|
||||
@ -1789,9 +1779,7 @@ int setVetoReference(int gainIndex, int value) {
|
||||
LOG(logINFO, ("Setting veto reference [chip:-1, G%d, value:0x%x]\n",
|
||||
gainIndex, value));
|
||||
int values[NCHAN];
|
||||
memset(values, 0, sizeof(values));
|
||||
int gainIndices[NCHAN];
|
||||
memset(gainIndices, 0, sizeof(gainIndices));
|
||||
for (int ich = 0; ich < NCHAN; ++ich) {
|
||||
values[ich] = value;
|
||||
gainIndices[ich] = gainIndex;
|
||||
|
@ -6332,16 +6332,14 @@ int set_veto_photon(int file_des) {
|
||||
int args[2] = {-1, -1};
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
int chipIndex = args[0];
|
||||
int numChannels = args[1];
|
||||
const int chipIndex = args[0];
|
||||
const int numChannels = args[1];
|
||||
|
||||
int gainIndices[args[1]];
|
||||
memset(gainIndices, 0, sizeof(gainIndices));
|
||||
int gainIndices[numChannels];
|
||||
if (receiveData(file_des, gainIndices, sizeof(gainIndices), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
int values[args[1]];
|
||||
memset(values, 0, sizeof(values));
|
||||
int values[numChannels];
|
||||
if (receiveData(file_des, values, sizeof(values), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
@ -6353,19 +6351,18 @@ int set_veto_photon(int file_des) {
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
|
||||
if (chipIndex < -1 || chipIndex >= NCHIP) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set veto photon. Invalid chip index %d\n",
|
||||
chipIndex);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (numChannels != NCHAN) {
|
||||
if (numChannels != NCHAN) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set veto photon. Invalid number of channels %d. "
|
||||
"Expected %d\n",
|
||||
numChannels, NCHAN);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (chipIndex < -1 || chipIndex >= NCHIP) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set veto photon. Invalid chip index %d\n",
|
||||
chipIndex);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
for (int i = 0; i < NCHAN; ++i) {
|
||||
if (gainIndices[i] < 0 || gainIndices[i] > 2) {
|
||||
|
Reference in New Issue
Block a user