minor tweaks for XADC code #736

Merged
muellerr merged 3 commits from minor-xadc-tweak into main 2023-07-11 09:40:07 +02:00
Showing only changes of commit be1d1cf5bf - Show all commits

View File

@ -129,7 +129,7 @@ ReturnValue_t Xadc::readValFromFile(const char* filename, T& val) {
sif::warning << "Xadc::readValFromFile: Failed to open file " << filename << std::endl; sif::warning << "Xadc::readValFromFile: Failed to open file " << filename << std::endl;
return returnvalue::FAILED; return returnvalue::FAILED;
} }
char valstring[MAX_STR_LENGTH] = ""; char valstring[MAX_STR_LENGTH]{};
char* returnVal = fgets(valstring, MAX_STR_LENGTH, fp); char* returnVal = fgets(valstring, MAX_STR_LENGTH, fp);
if (returnVal == nullptr) { if (returnVal == nullptr) {
sif::warning << "Xadc::readValFromFile: Failed to read string from file " << filename sif::warning << "Xadc::readValFromFile: Failed to read string from file " << filename
@ -139,6 +139,11 @@ ReturnValue_t Xadc::readValFromFile(const char* filename, T& val) {
} }
std::istringstream valSstream(valstring); std::istringstream valSstream(valstring);
valSstream >> val; valSstream >> val;
if(valSstream.bad()) {
sif::warning << "Xadc: Conversion of value to target type failed" << std::endl;
fclose(fp);
return returnvalue::FAILED;
}
fclose(fp); fclose(fp);
return returnvalue::OK; return returnvalue::OK;
} }