replaced int32_t size by ssize_t (type trait trick)

This commit is contained in:
Robin Müller 2020-04-05 22:42:48 +02:00
parent 87852e5f2a
commit 42838272a5
41 changed files with 70 additions and 65 deletions

View File

@ -201,7 +201,7 @@ public:
return printSize;
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
ReturnValue_t result = SerializeAdapter<uint32_t>::deSerialize(&this->_size,
buffer, size, bigEndian);

View File

@ -80,7 +80,7 @@ size_t DataPoolParameterWrapper::getSerializedSize() const {
}
ReturnValue_t DataPoolParameterWrapper::deSerialize(const uint8_t** buffer,
int32_t* size, bool bigEndian) {
ssize_t* size, bool bigEndian) {
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@ -16,7 +16,7 @@ public:
virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
ReturnValue_t copyFrom(const ParameterWrapper *from,

View File

@ -136,7 +136,7 @@ void DataSet::setValid(uint8_t valid) {
}
}
ReturnValue_t DataSet::deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t DataSet::deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
ReturnValue_t result = RETURN_FAILED;
for (uint16_t count = 0; count < fill_count; count++) {

View File

@ -126,7 +126,7 @@ public:
virtual size_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
private:

View File

@ -136,7 +136,7 @@ public:
return SerializeAdapter<T>::getSerializedSize(&value);
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian);
}

View File

@ -197,7 +197,7 @@ size_t PoolRawAccess::getSerializedSize() const {
return typeSize;
}
ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
*size -= typeSize;
if (*size >= 0) {

View File

@ -127,7 +127,7 @@ public:
size_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
protected:

View File

@ -25,7 +25,7 @@ ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size,
const size_t max_size, bool bigEndian) {
SerializationArgs serializationArgs = {buffer, size, max_size, bigEndian};
ReturnValue_t result;
int32_t remainingParametersSize = numberOfParameters * 4;
ssize_t remainingParametersSize = numberOfParameters * 4;
for(uint8_t count=0; count < numberOfParameters; count++) {
result = serializeCurrentPoolEntryIntoBuffer(serializationArgs,
&remainingParametersSize, false);
@ -44,7 +44,7 @@ ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer,
size_t * size, const size_t max_size, bool bigEndian) {
ReturnValue_t result;
SerializationArgs argStruct = {buffer, size, max_size, bigEndian};
int32_t remainingParametersSize = numberOfParameters * 4;
ssize_t remainingParametersSize = numberOfParameters * 4;
uint8_t validityMaskSize = ceil((float)numberOfParameters/8.0);
uint8_t validityMask[validityMaskSize];
memset(validityMask,0, validityMaskSize);
@ -68,7 +68,7 @@ ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer,
}
ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(SerializationArgs argStruct,
int32_t * remainingParameters, bool withValidMask, uint8_t * validityMask) {
ssize_t * remainingParameters, bool withValidMask, uint8_t * validityMask) {
uint32_t currentPoolId;
// Deserialize current pool ID from pool ID buffer
ReturnValue_t result = AutoSerializeAdapter::deSerialize(&currentPoolId,

View File

@ -85,10 +85,12 @@ private:
* @return
*/
ReturnValue_t serializeCurrentPoolEntryIntoBuffer(SerializationArgs argStruct,
int32_t * remainingParameters, bool withValidMask = false, uint8_t * validityMask = NULL);
ssize_t * remainingParameters, bool withValidMask = false,
uint8_t * validityMask = nullptr);
ReturnValue_t handlePoolEntrySerialization(uint32_t currentPoolId,SerializationArgs argStruct,
bool withValidMask = false, uint8_t * validityMask = NULL);
ReturnValue_t handlePoolEntrySerialization(uint32_t currentPoolId,
SerializationArgs argStruct, bool withValidMask = false,
uint8_t * validityMask = nullptr);
ReturnValue_t checkRemainingSize(PoolRawAccess * currentPoolRawAccess,
bool * isSerialized, uint8_t * arrayPosition);

View File

@ -203,7 +203,7 @@ public:
return SerializeAdapter<T>::getSerializedSize(&value);
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian);
}

View File

@ -215,7 +215,7 @@ public:
return vector_size * SerializeAdapter<T>::getSerializedSize(value);
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
uint16_t i;
ReturnValue_t result;

View File

@ -31,7 +31,7 @@ size_t DeviceTmReportingWrapper::getSerializedSize() const {
}
ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer,
int32_t* size, bool bigEndian) {
ssize_t* size, bool bigEndian) {
ReturnValue_t result = SerializeAdapter<object_id_t>::deSerialize(&objectId,
buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -16,7 +16,7 @@ public:
virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
private:
object_id_t objectId;

View File

@ -18,7 +18,7 @@ public:
size_t getSerializedSize() const {
return rangeMatcher.getSerializedSize();
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return rangeMatcher.deSerialize(buffer, size, bigEndian);
}

View File

@ -1,4 +1,3 @@
#include <framework/serialize/SerializeAdapter.h>
#include <framework/globalfunctions/Type.h>
#include <framework/serialize/SerializeAdapter.h>
@ -86,7 +85,7 @@ size_t Type::getSerializedSize() const {
return 2 * SerializeAdapter<uint8_t>::getSerializedSize(&dontcare);
}
ReturnValue_t Type::deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t Type::deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
uint8_t ptc;
uint8_t pfc;

View File

@ -44,7 +44,7 @@ public:
virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
private:

View File

@ -115,7 +115,7 @@ public:
return size;
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -44,7 +44,7 @@ public:
return sizeof(lowerBound) + sizeof(upperBound) + sizeof(bool);
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
ReturnValue_t result = SerializeAdapter<T>::deSerialize(&lowerBound, buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -112,7 +112,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow,
//treat from as a continuous Stream as we copy all of it
const uint8_t *fromAsStream = (const uint8_t *) from;
int32_t streamSize = fromRows * fromColumns * sizeof(T);
ssize_t streamSize = fromRows * fromColumns * sizeof(T);
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
@ -137,12 +137,12 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow,
}
ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer,
int32_t* size, bool bigEndian) {
ssize_t* size, bool bigEndian) {
return deSerialize(buffer, size, bigEndian, 0);
}
ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer,
int32_t* size, bool bigEndian, uint16_t startWritingAtIndex) {
ssize_t* size, bool bigEndian, uint16_t startWritingAtIndex) {
ParameterWrapper streamDescription;
ReturnValue_t result = streamDescription.set(*buffer, *size, buffer, size);
@ -153,8 +153,8 @@ ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer,
return copyFrom(&streamDescription, startWritingAtIndex);
}
ReturnValue_t ParameterWrapper::set(const uint8_t* stream, int32_t streamSize,
const uint8_t **remainingStream, int32_t *remainingSize) {
ReturnValue_t ParameterWrapper::set(const uint8_t* stream, ssize_t streamSize,
const uint8_t **remainingStream, ssize_t *remainingSize) {
ReturnValue_t result = SerializeAdapter<Type>::deSerialize(&type, &stream,
&streamSize, true);
if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -30,10 +30,10 @@ public:
virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian, uint16_t startWritingAtIndex = 0);
template<typename T>
@ -111,8 +111,8 @@ public:
void setMatrix(const T& member) {
this->set(member[0], sizeof(member)/sizeof(member[0]), sizeof(member[0])/sizeof(member[0][0]));
}
ReturnValue_t set(const uint8_t *stream, int32_t streamSize,
const uint8_t **remainingStream = NULL, int32_t *remainingSize =
ReturnValue_t set(const uint8_t *stream, ssize_t streamSize,
const uint8_t **remainingStream = NULL, ssize_t *remainingSize =
NULL);
ReturnValue_t copyFrom(const ParameterWrapper *from,

View File

@ -108,7 +108,7 @@ uint32_t Fuse::getSerializedSize() const {
return size;
}
ReturnValue_t Fuse::deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t Fuse::deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
ReturnValue_t result = RETURN_FAILED;
for (DeviceList::iterator iter = devices.begin(); iter != devices.end();

View File

@ -52,8 +52,8 @@ public:
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const;
uint32_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian);
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
void setAllMonitorsToUnchecked();
ReturnValue_t performOperation(uint8_t opCode);
MessageQueueId_t getCommandQueue() const;

View File

@ -56,8 +56,8 @@ float PowerComponent::getMax() {
return max;
}
ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) {
ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
ReturnValue_t result = SerializeAdapter<float>::deSerialize(&min, buffer,
size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -24,7 +24,7 @@ public:
size_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,

View File

@ -56,13 +56,13 @@ public:
return printSize;
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return deSerialize(adaptee, buffer, size, bigEndian);
}
static ReturnValue_t deSerialize(ArrayList<T, count_t>* list, const uint8_t** buffer, int32_t* size,
bool bigEndian) {
static ReturnValue_t deSerialize(ArrayList<T, count_t>* list,
const uint8_t** buffer, ssize_t* size, bool bigEndian) {
count_t tempSize = 0;
ReturnValue_t result = SerializeAdapter<count_t>::deSerialize(&tempSize,
buffer, size, bigEndian);

View File

@ -63,7 +63,7 @@ size_t SerialBufferAdapter<count_t>::getSerializedSize() const {
}
template<typename count_t>
ReturnValue_t SerialBufferAdapter<count_t>::deSerialize(const uint8_t** buffer,
int32_t* size, bool bigEndian) {
ssize_t* size, bool bigEndian) {
//TODO Ignores Endian flag!
if (buffer != NULL) {
if(m_serialize_length){

View File

@ -45,7 +45,7 @@ public:
virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian);
uint8_t * getBuffer();

View File

@ -40,9 +40,10 @@ public:
size_t getSerializedSize() const {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::getSerializedSize(this);
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::deSerialize(this, buffer, size, bigEndian);
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::deSerialize(this,
buffer, size, bigEndian);
}
void swapArrayListEndianness() {

View File

@ -112,13 +112,13 @@ public:
* @param bigEndian Specify endianness
* @return
*/
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return deSerialize(SinglyLinkedList<T>::start, buffer, size, bigEndian);
}
static ReturnValue_t deSerialize(LinkedElement<T>* element,
const uint8_t** buffer, int32_t* size, bool bigEndian) {
const uint8_t** buffer, ssize_t* size, bool bigEndian) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) {
result = element->value->deSerialize(buffer, size, bigEndian);

View File

@ -88,7 +88,7 @@ public:
* @param bigEndian Specify endianness
* @return
*/
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
T tmp;
*size -= sizeof(T);
@ -127,7 +127,7 @@ public:
return object->getSerializedSize();
}
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return object->deSerialize(buffer, size, bigEndian);
}
@ -147,7 +147,7 @@ public:
}
static ReturnValue_t deSerialize(T* object, const uint8_t** buffer,
int32_t* size, bool bigEndian) {
ssize_t* size, bool bigEndian) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.deSerialize(object, buffer, size, bigEndian);
}
@ -169,7 +169,7 @@ public:
}
template<typename T>
static ReturnValue_t deSerialize(T* object, const uint8_t** buffer,
int32_t* size, bool bigEndian) {
ssize_t* size, bool bigEndian) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.deSerialize(object, buffer, size, bigEndian);
}

View File

@ -41,10 +41,11 @@ public:
return SerializeAdapter<T>::getSerializedSize(&entry);
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return SerializeAdapter<T>::deSerialize(&entry, buffer, size, bigEndian);
}
operator T() {
return entry;
}

View File

@ -3,7 +3,9 @@
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <cstddef>
#include <type_traits>
typedef std::make_signed<std::size_t>::type ssize_t;
/**
* @defgroup serialize Serialization
* Contains serialisation services.
@ -42,7 +44,7 @@ public:
virtual size_t getSerializedSize() const = 0;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) = 0;
};

View File

@ -168,7 +168,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
&sizeRead);
if (result == RETURN_OK) {
Mode_t fallbackId;
int32_t size = sizeRead;
ssize_t size = sizeRead;
result = SerializeAdapter<Mode_t>::deSerialize(&fallbackId,
&pointer, &size, true);
if (result == RETURN_OK) {
@ -193,7 +193,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
ModeSequenceMessage::getStoreAddress(message), &pointer,
&sizeRead);
if (result == RETURN_OK) {
int32_t size = sizeRead;
ssize_t size = sizeRead;
result = SerialArrayListAdapter<ModeListEntry>::deSerialize(&table,
&pointer, &size, true);
if (result == RETURN_OK) {

View File

@ -53,7 +53,7 @@ public:
return sizeof(value1) + sizeof(value2) + sizeof(value3) + sizeof(value4);
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
ReturnValue_t result;

View File

@ -40,11 +40,11 @@ ReturnValue_t ThermalComponent::setTargetState(int8_t newState) {
}
}
ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, uint32_t size) {
ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, ssize_t size) {
if (size != 4 * sizeof(parameters.lowerOpLimit)) {
return MonitoringIF::INVALID_SIZE;
}
int32_t readSize = size;
ssize_t readSize = size;
SerializeAdapter<float>::deSerialize(&nopParameters.lowerNopLimit, &data,
&readSize, true);
SerializeAdapter<float>::deSerialize(&parameters.lowerOpLimit, &data,

View File

@ -53,7 +53,7 @@ public:
ReturnValue_t setTargetState(int8_t newState);
virtual ReturnValue_t setLimits( const uint8_t* data, uint32_t size);
virtual ReturnValue_t setLimits( const uint8_t* data, ssize_t size);
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
ParameterWrapper *parameterWrapper,

View File

@ -48,7 +48,7 @@ public:
return sizeof(apid) + sizeof(ssc);
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
ReturnValue_t result = SerializeAdapter<uint16_t>::deSerialize(&apid,
buffer, size, bigEndian);
@ -257,7 +257,7 @@ public:
};
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
ReturnValue_t result = AutoSerializeAdapter::deSerialize(&apid, buffer,
size, bigEndian);

View File

@ -30,7 +30,7 @@ public:
size_t getSerializedSize() const {
return SerializeAdapter<uint16_t>::getSerializedSize(&apid);
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return SerializeAdapter<uint16_t>::deSerialize(&apid, buffer, size, bigEndian);
}

View File

@ -30,7 +30,7 @@ public:
size_t getSerializedSize() const {
return SerializeAdapter<uint8_t>::getSerializedSize(&service);
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return SerializeAdapter<uint8_t>::deSerialize(&service, buffer, size, bigEndian);
}

View File

@ -28,7 +28,7 @@ public:
size_t getSerializedSize() const {
return SerializeAdapter<uint8_t>::getSerializedSize(&subService);
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size,
bool bigEndian) {
return SerializeAdapter<uint8_t>::deSerialize(&subService, buffer, size, bigEndian);
}