From 823bae1a2a993af3ff700c0d7eb4709c8176d87d Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Wed, 30 Sep 2020 16:06:17 +0200 Subject: [PATCH 1/3] Added null pointer checks for FIFO Base --- container/FIFOBase.tpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/container/FIFOBase.tpp b/container/FIFOBase.tpp index d54b3f8f..763004b6 100644 --- a/container/FIFOBase.tpp +++ b/container/FIFOBase.tpp @@ -26,6 +26,9 @@ inline ReturnValue_t FIFOBase::retrieve(T* value) { if (empty()) { return EMPTY; } else { + if (value == nullptr){ + return HasReturnvaluesIF::RETURN_FAILED; + } *value = values[readIndex]; readIndex = next(readIndex); --currentSize; @@ -38,6 +41,9 @@ inline ReturnValue_t FIFOBase::peek(T* value) { if(empty()) { return EMPTY; } else { + if (value == nullptr){ + return HasReturnvaluesIF::RETURN_FAILED; + } *value = values[readIndex]; return HasReturnvaluesIF::RETURN_OK; } From ab9858b0c78fa6283b7218e7c9339444b91a5c39 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Wed, 30 Sep 2020 16:15:48 +0200 Subject: [PATCH 2/3] Added comments --- container/FIFOBase.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/container/FIFOBase.h b/container/FIFOBase.h index b744706d..201d488d 100644 --- a/container/FIFOBase.h +++ b/container/FIFOBase.h @@ -19,24 +19,24 @@ public: /** * Insert value into FIFO * @param value - * @return + * @return RETURN_OK on success, FULL if full */ ReturnValue_t insert(T value); /** * Retrieve item from FIFO. This removes the item from the FIFO. - * @param value - * @return + * @param value Must point to a valid T + * @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed */ ReturnValue_t retrieve(T *value); /** * Retrieve item from FIFO without removing it from FIFO. - * @param value - * @return + * @param value Must point to a valid T + * @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed */ ReturnValue_t peek(T * value); /** * Remove item from FIFO. - * @return + * @return RETURN_OK on success, EMPTY if empty */ ReturnValue_t pop(); From fcabf93af33c61d989bf06555bf3a005e985ff7a Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Wed, 30 Sep 2020 16:27:18 +0200 Subject: [PATCH 3/3] Added a few comments --- container/FIFOBase.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/container/FIFOBase.h b/container/FIFOBase.h index 201d488d..edd66d37 100644 --- a/container/FIFOBase.h +++ b/container/FIFOBase.h @@ -40,11 +40,25 @@ public: */ ReturnValue_t pop(); + /*** + * Check if FIFO is empty + * @return True if empty, False if not + */ bool empty(); + /*** + * Check if FIFO is Full + * @return True if full, False if not + */ bool full(); + /*** + * Current used size (elements) used + * @return size_t in elements + */ size_t size(); - - + /*** + * Get maximal capacity of fifo + * @return size_t with max capacity of this fifo + */ size_t getMaxCapacity() const; protected: