RPi: Use logError when possible (#689)

This commit is contained in:
Marcelo Aquino
2016-12-12 22:23:19 +01:00
committed by Patrick Fallberg
parent 7e1aa82d6e
commit 707442b257
3 changed files with 41 additions and 6 deletions
+27 -1
View File
@@ -22,6 +22,7 @@
#include <fstream>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include "log.h"
#include "SoftEeprom.h"
@@ -31,7 +32,7 @@ SoftEeprom::SoftEeprom(const char *fileName, size_t length)
_fileName = strdup(fileName);
if (_fileName == NULL) {
perror("Error: ");
logError("Error: %s\n", strerror(errno));
exit(1);
}
@@ -67,6 +68,17 @@ SoftEeprom::SoftEeprom(const char *fileName, size_t length)
}
}
SoftEeprom::SoftEeprom(const SoftEeprom& other)
{
_fileName = strdup(other._fileName);
_length = other._length;
_values = new uint8_t[_length];
for (size_t i = 0; i < _length; ++i) {
_values[i] = other._values[i];
}
}
SoftEeprom::~SoftEeprom()
{
delete[] _values;
@@ -128,3 +140,17 @@ void SoftEeprom::writeByte(int addr, uint8_t value)
writeBlock(&value, reinterpret_cast<void*>(addr), 1);
}
}
SoftEeprom& SoftEeprom::operator=(const SoftEeprom& other)
{
if (this != &other) {
_fileName = strdup(other._fileName);
_length = other._length;
_values = new uint8_t[_length];
for (size_t i = 0; i < _length; ++i) {
_values[i] = other._values[i];
}
}
return *this;
}
+9
View File
@@ -43,6 +43,10 @@ public:
* @brief SoftEeprom constructor.
*/
SoftEeprom(const char *fileName, size_t length);
/**
* @brief SoftEeprom copy constructor.
*/
SoftEeprom(const SoftEeprom& other);
/**
* @brief SoftEeprom destructor.
*/
@@ -77,6 +81,11 @@ public:
* @param value to write.
*/
void writeByte(int addr, uint8_t value);
/**
* @brief Overloaded assign operator.
*
*/
SoftEeprom& operator=(const SoftEeprom& other);
};
#endif