diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index cabf6f09f..eadf83efb 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -1355,7 +1355,7 @@ int setVLimit(int val, char *mess) { } int validateDACIndex(enum DACINDEX ind, char *mess) { - if (ind < 0 || ind >= NDAC_ONLY) { + if (ind >= NDAC_ONLY) { sprintf(mess, "Could not set/get DAC. Invalid index %d\n", ind); LOG(logERROR, (mess)); return FAIL; @@ -1464,7 +1464,7 @@ int setDAC(enum DACINDEX ind, int val, bool mV, char *mess) { } int validatePowerDACIndex(enum powerIndex ind, char *mess) { - if (ind < 0 || ind > V_POWER_IO) { + if (ind > V_POWER_IO) { sprintf(mess, "Could not set/get Power DAC. Invalid index %d\n", ind); LOG(logERROR, (mess)); return FAIL; @@ -2330,7 +2330,7 @@ int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval) { } int setFrequency(enum CLKINDEX ind, int val) { - if (ind < 0 || ind >= NUM_CLOCKS) { + if (ind >= NUM_CLOCKS) { LOG(logERROR, ("Unknown clock index %d to set frequency\n", ind)); return FAIL; } @@ -2380,7 +2380,7 @@ int setFrequency(enum CLKINDEX ind, int val) { } int getFrequency(enum CLKINDEX ind) { - if (ind < 0 || ind >= NUM_CLOCKS) { + if (ind >= NUM_CLOCKS) { LOG(logERROR, ("Unknown clock index %d to get frequency\n", ind)); return -1; } diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 7ccc5baa4..72244a4eb 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -416,7 +416,7 @@ int setChipIndex(enum CHIPINDEX ind, char *mess) { enum CHIPINDEX getChipIndex() { return chipIndex; } int validateChipIndex(enum CHIPINDEX ind, char *mess) { - if (ind < 0 || ind >= NUM_CHIP_INDICES) { + if (ind >= NUM_CHIP_INDICES) { sprintf(mess, "Invalid chip index %d. Options: %s\n", (int)ind, CHIP_VALS_HELP); LOG(logERROR, (mess)); @@ -846,7 +846,7 @@ int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, return FAIL; } - if (index < 0 || index >= NDAC) + if (index >= NDAC) return FAIL; *retval = defaultDacValues[index]; return OK; @@ -882,7 +882,7 @@ int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) { // not a special dac return FAIL; } - if (index < 0 || index >= NDAC) + if (index >= NDAC) return FAIL; LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index, dac_names[index], value)); @@ -1564,7 +1564,7 @@ void setGainMode(enum gainMode mode) { /* parameters - dac, adc, hv */ int validateDACIndex(enum DACINDEX ind, char *mess) { - if (ind < 0 || ind >= NDAC) { + if (ind >= NDAC) { sprintf(mess, "Could not set DAC. Invalid index %d\n", ind); LOG(logERROR, (mess)); return FAIL; diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 1b9d7b343..b3cb6fe69 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -548,7 +548,7 @@ int resetToDefaultDacs(int hardReset, char *mess) { int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval) { - if (index < 0 || index >= NDAC) + if (index >= NDAC) return FAIL; *retval = defaultDacValues[index]; return OK; @@ -556,7 +556,7 @@ int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) { char *dac_names[] = {DAC_NAMES}; - if (index < 0 || index >= NDAC) + if (index >= NDAC) return FAIL; LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index, dac_names[index], value)); @@ -913,7 +913,7 @@ enum detectorSettings getSettings() { /* parameters - dac, adc, hv */ /* parameters - dac, adc, hv */ int validateDACIndex(enum DACINDEX ind, char *mess) { - if (ind < 0 || ind >= NDAC) { + if (ind >= NDAC) { sprintf(mess, "Could not set DAC. Invalid index %d\n", ind); LOG(logERROR, (mess)); return FAIL; diff --git a/slsDetectorServers/slsDetectorServer/src/LTC2620_Driver.c b/slsDetectorServers/slsDetectorServer/src/LTC2620_Driver.c index ee76c5e64..21db6fed1 100644 --- a/slsDetectorServers/slsDetectorServer/src/LTC2620_Driver.c +++ b/slsDetectorServers/slsDetectorServer/src/LTC2620_Driver.c @@ -94,16 +94,13 @@ int LTC2620_D_SetDacValue(int dacnum, int val, char *dacname, char *mess) { // fname to write to char fname[MAX_STR_LENGTH]; memset(fname, 0, MAX_STR_LENGTH); - char fnameFormat[MAX_STR_LENGTH]; - memset(fnameFormat, 0, MAX_STR_LENGTH); - strcpy(fnameFormat, LTC2620_D_DriverFileName); - sprintf(fname, "%s%d", fnameFormat, dacnum); + snprintf(fname, sizeof(fname), "%s%d", LTC2620_D_DriverFileName, dacnum); #if defined(XILINX_CHIPTESTBOARDD) if (val == LTC2620_D_PWR_DOWN_VAL) { - strcpy(fnameFormat, LTC2620_D_PowerDownDriverFileName); + snprintf(fname, sizeof(fname), "%s%d", + LTC2620_D_PowerDownDriverFileName, dacnum); val = 1; //-100?:Invalid Argument } - sprintf(fname, fnameFormat, dacnum); #endif LOG(logDEBUG1, ("fname %s\n", fname)); diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index d72fc5f74..04d95fc0b 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -145,7 +145,7 @@ void basictests() { } // check for API compatibility - old server - if (sw_fw_apiversion > requiredfwversion) { + if ((uint64_t)sw_fw_apiversion > requiredfwversion) { sprintf(initErrorMessage, "This firmware-software api version (0x%lx) is incompatible " "with the software's minimum required firmware version " @@ -158,7 +158,7 @@ void basictests() { } // check for firmware compatibility - old firmware - if (requiredfwversion > fwversion) { + if (requiredfwversion > (uint64_t)fwversion) { sprintf(initErrorMessage, "This firmware version (0x%lx) is incompatible.\n" "Please update firmware (min. 0x%lx) to be compatible with "