minor tweaks for XADC code
This commit is contained in:
parent
3f4a34d616
commit
be1d1cf5bf
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user