From 44fabef29dfada703f887b1d33f8b38cfd2009a9 Mon Sep 17 00:00:00 2001
From: kongr45gpen <electrovesta@gmail.com>
Date: Tue, 2 Apr 2019 19:06:23 +0300
Subject: [PATCH] Compliance with some rules

---
 ci/cppcheck-misra.sh                        |  2 +-
 inc/ECSS_Definitions.hpp                    |  6 +++---
 inc/ErrorHandler.hpp                        | 18 +++++++++-------
 inc/Helpers/TimeHelper.hpp                  |  6 +++---
 inc/Message.hpp                             | 14 ++++++------
 inc/Services/TimeBasedSchedulingService.hpp |  5 ++++-
 lib/Catch2                                  |  2 +-
 src/Helpers/CRCHelper.cpp                   |  2 +-
 src/Helpers/TimeAndDate.cpp                 | 14 ++++++------
 src/Helpers/TimeHelper.cpp                  | 24 ++++++++++-----------
 src/Message.cpp                             | 13 +++++------
 src/MessageParser.cpp                       | 12 +++++------
 src/Service.cpp                             |  2 ++
 src/Services/EventActionService.cpp         | 22 +++++++++----------
 src/Services/FunctionManagementService.cpp  |  2 +-
 src/Services/MemoryManagementService.cpp    | 12 +++++------
 src/Services/ParameterService.cpp           |  6 +++---
 src/main.cpp                                |  4 ++--
 18 files changed, 86 insertions(+), 80 deletions(-)

diff --git a/ci/cppcheck-misra.sh b/ci/cppcheck-misra.sh
index d5c31720..87954991 100755
--- a/ci/cppcheck-misra.sh
+++ b/ci/cppcheck-misra.sh
@@ -27,5 +27,5 @@ sed -i -r 's/(.*Script.*)|(.*Checking.*)|(.*MISRA.*)//gm; /(^$)/d; s/(\s\(.*\)\s
 
 # run the summarizer for a nice, clean summary of errors
 echo -e "\u001b[34;1mSummarizing results...\u001b[0m"
-python3 ci/summarizer.py --report ci/report.msr --suppress 3.1 5.1 5.2 5.3 12.3 14.4 16.3 18.8
+python3 ci/summarizer.py --report ci/report.msr --suppress 3.1 5.1 5.2 5.3 12.3 14.4 15.5 16.3 18.8
 
diff --git a/inc/ECSS_Definitions.hpp b/inc/ECSS_Definitions.hpp
index 047db0f7..e712e532 100644
--- a/inc/ECSS_Definitions.hpp
+++ b/inc/ECSS_Definitions.hpp
@@ -1,11 +1,11 @@
 #ifndef ECSS_SERVICES_ECSS_DEFINITIONS_H
 #define ECSS_SERVICES_ECSS_DEFINITIONS_H
 
-#define ECSS_MAX_MESSAGE_SIZE 1024
+#define ECSS_MAX_MESSAGE_SIZE 1024u
 
-#define ECSS_MAX_STRING_SIZE 256
+#define ECSS_MAX_STRING_SIZE 256u
 
-#define ECSS_MAX_FIXED_OCTET_STRING_SIZE 256 // For the ST13 large packet transfer service
+#define ECSS_MAX_FIXED_OCTET_STRING_SIZE 256u // For the ST13 large packet transfer service
 
 // 7.4.1
 #define CCSDS_PACKET_VERSION 0
diff --git a/inc/ErrorHandler.hpp b/inc/ErrorHandler.hpp
index 4f508375..74ba544e 100644
--- a/inc/ErrorHandler.hpp
+++ b/inc/ErrorHandler.hpp
@@ -2,12 +2,11 @@
 #define PROJECT_ERRORHANDLER_HPP
 
 #include <type_traits>
+#include <stdint.h> // for the uint_8t stepID
 
 // Forward declaration of the class, since its header file depends on the ErrorHandler
 class Message;
 
-#include <stdint.h> // for the uint_8t stepID
-
 /**
  * A class that handles unexpected software errors, including internal errors or errors due to
  * invalid & incorrect input data.
@@ -236,22 +235,25 @@ public:
 	template<typename ErrorType>
 	inline static ErrorSource findErrorSource(ErrorType error) {
 		// Static type checking
+		ErrorSource source = Internal;
+
 		if (std::is_same<ErrorType, AcceptanceErrorType>()) {
-			return Acceptance;
+			source = Acceptance;
 		}
 		if (std::is_same<ErrorType, ExecutionStartErrorType>()) {
-			return ExecutionStart;
+			source = ExecutionStart;
 		}
 		if (std::is_same<ErrorType, ExecutionProgressErrorType>()) {
-			return ExecutionProgress;
+			source = ExecutionProgress;
 		}
 		if (std::is_same<ErrorType, ExecutionCompletionErrorType>()) {
-			return ExecutionCompletion;
+			source = ExecutionCompletion;
 		}
 		if (std::is_same<ErrorType, RoutingErrorType>()) {
-			return Routing;
+			source = Routing;
 		}
-		return Internal;
+
+		return source;
 	}
 };
 
diff --git a/inc/Helpers/TimeHelper.hpp b/inc/Helpers/TimeHelper.hpp
index b9039cf3..d145f43c 100644
--- a/inc/Helpers/TimeHelper.hpp
+++ b/inc/Helpers/TimeHelper.hpp
@@ -5,9 +5,9 @@
 #include <Message.hpp>
 #include "TimeAndDate.hpp"
 
-#define SECONDS_PER_MINUTE 60
-#define SECONDS_PER_HOUR 3600
-#define SECONDS_PER_DAY 86400
+#define SECONDS_PER_MINUTE 60u
+#define SECONDS_PER_HOUR 3600u
+#define SECONDS_PER_DAY 86400u
 
 /**
  * This class formats the spacecraft time and cooperates closely with the ST[09] time management.
diff --git a/inc/Message.hpp b/inc/Message.hpp
index ac1509f9..1bbfcd48 100644
--- a/inc/Message.hpp
+++ b/inc/Message.hpp
@@ -1,10 +1,6 @@
 #ifndef ECSS_SERVICES_PACKET_H
 #define ECSS_SERVICES_PACKET_H
 
-
-// Forward declaration of the Message class, needed for the ErrorHandler
-class Message;
-
 #include "ECSS_Definitions.hpp"
 #include <cstdint>
 #include <etl/String.hpp>
@@ -496,13 +492,15 @@ public:
 	 */
 	bool assertType(Message::PacketType expectedPacketType, uint8_t expectedServiceType,
 		uint8_t expectedMessageType) {
-		if (packetType != expectedPacketType || serviceType != expectedServiceType ||
-		    messageType != expectedMessageType) {
+		bool status = true;
+
+		if ((packetType != expectedPacketType) || (serviceType != expectedServiceType) ||
+		    (messageType != expectedMessageType)) {
 			ErrorHandler::reportInternalError(ErrorHandler::OtherMessageType);
-			return false;
+			status = false;
 		}
 
-		return true;
+		return status;
 	}
 
 	/**
diff --git a/inc/Services/TimeBasedSchedulingService.hpp b/inc/Services/TimeBasedSchedulingService.hpp
index 76343b5d..8323e732 100644
--- a/inc/Services/TimeBasedSchedulingService.hpp
+++ b/inc/Services/TimeBasedSchedulingService.hpp
@@ -109,7 +109,10 @@ private:
 	inline void sortActivitiesReleaseTime(etl::list<ScheduledActivity,
 		ECSS_MAX_NUMBER_OF_TIME_SCHED_ACTIVITIES> &schedActivities) {
 		schedActivities.sort([](ScheduledActivity const &leftSide, ScheduledActivity const
-		&rightSide) { return leftSide.requestReleaseTime < rightSide.requestReleaseTime; });
+		&rightSide) { 
+			// cppcheck-suppress
+			return leftSide.requestReleaseTime < rightSide.requestReleaseTime; 
+		});
 	}
 
 	/**
diff --git a/lib/Catch2 b/lib/Catch2
index 62460faf..d6330727 160000
--- a/lib/Catch2
+++ b/lib/Catch2
@@ -1 +1 @@
-Subproject commit 62460fafe6b54c3173bc5cbc46d05a5f071017ff
+Subproject commit d63307279412de3870cf97cc6802bae8ab36089e
diff --git a/src/Helpers/CRCHelper.cpp b/src/Helpers/CRCHelper.cpp
index 83614550..63bcde7d 100644
--- a/src/Helpers/CRCHelper.cpp
+++ b/src/Helpers/CRCHelper.cpp
@@ -15,7 +15,7 @@ uint16_t CRCHelper::calculateCRC(const uint8_t* message, uint32_t length) {
 
 		for (int j = 0; j < 8; j++) {
 			// if the MSB is set, the bitwise AND gives 1
-			if ((shiftReg & 0x8000u) != 0) {
+			if ((shiftReg & 0x8000u) != 0u) {
 				// toss out of the register the MSB and divide (XOR) its content with the generator
 				shiftReg = ((shiftReg << 1u) ^ polynomial);
 			}
diff --git a/src/Helpers/TimeAndDate.cpp b/src/Helpers/TimeAndDate.cpp
index 38280ecb..798fd221 100644
--- a/src/Helpers/TimeAndDate.cpp
+++ b/src/Helpers/TimeAndDate.cpp
@@ -15,11 +15,11 @@ TimeAndDate::TimeAndDate(uint16_t year, uint8_t month, uint8_t day, uint8_t hour
                          uint8_t second) {
 	// check if the parameters make sense
 	ASSERT_INTERNAL(2019 <= year, ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(1 <= month && month <= 12, ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(1 <= day && day <= 31, ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(0 <= hour && hour <= 24, ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(0 <= minute && minute <= 60, ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(0 <= second && second <= 60, ErrorHandler::InternalErrorType::InvalidDate);
+	ASSERT_INTERNAL((1 <= month) && (month <= 12), ErrorHandler::InternalErrorType::InvalidDate);
+	ASSERT_INTERNAL((1 <= day) && (day <= 31), ErrorHandler::InternalErrorType::InvalidDate);
+	ASSERT_INTERNAL((0 <= hour) && (hour <= 24), ErrorHandler::InternalErrorType::InvalidDate);
+	ASSERT_INTERNAL((0 <= minute) && (minute <= 60), ErrorHandler::InternalErrorType::InvalidDate);
+	ASSERT_INTERNAL((0 <= second) && (second <= 60), ErrorHandler::InternalErrorType::InvalidDate);
 
 	this->year = year;
 	this->month = month;
@@ -163,9 +163,9 @@ bool TimeAndDate::operator==(const TimeAndDate &Date) {
 
 
 bool TimeAndDate::operator<=(const TimeAndDate &Date) {
-	return (*this < Date || *this == Date);
+	return ((*this < Date) || (*this == Date));
 }
 
 bool TimeAndDate::operator>=(const TimeAndDate &Date) {
-	return (*this > Date || *this == Date);
+	return ((*this > Date) || (*this == Date));
 }
diff --git a/src/Helpers/TimeHelper.cpp b/src/Helpers/TimeHelper.cpp
index 4b6885dc..2c346f44 100644
--- a/src/Helpers/TimeHelper.cpp
+++ b/src/Helpers/TimeHelper.cpp
@@ -1,10 +1,10 @@
 #include "Helpers/TimeHelper.hpp"
 
 bool TimeHelper::IsLeapYear(uint16_t year) {
-	if (year % 4 != 0) {
+	if ((year % 4) != 0) {
 		return false;
 	}
-	if (year % 100 != 0) {
+	if ((year % 100) != 0) {
 		return true;
 	}
 	return (year % 400) == 0;
@@ -14,15 +14,15 @@ uint32_t TimeHelper::utcToSeconds(TimeAndDate &TimeInfo) {
 	// the date, that \p TimeInfo represents, should be greater than or equal to 1/1/2019 and the
 	// date should be valid according to Gregorian calendar
 	ASSERT_INTERNAL(TimeInfo.year >= 2019, ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(1 <= TimeInfo.month && TimeInfo.month <= 12,
+	ASSERT_INTERNAL((1 <= TimeInfo.month) && (TimeInfo.month <= 12),
 	        ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(1 <= TimeInfo.day && TimeInfo.day <= 31,
+	ASSERT_INTERNAL((1 <= TimeInfo.day) && (TimeInfo.day <= 31),
 	        ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(0 <= TimeInfo.hour && TimeInfo.hour <= 24,
+	ASSERT_INTERNAL((0 <= TimeInfo.hour) && (TimeInfo.hour <= 24),
 	        ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(0 <= TimeInfo.minute && TimeInfo.minute <= 60,
+	ASSERT_INTERNAL((0 <= TimeInfo.minute) && (TimeInfo.minute <= 60),
 	        ErrorHandler::InternalErrorType::InvalidDate);
-	ASSERT_INTERNAL(0 <= TimeInfo.second && TimeInfo.second <= 60,
+	ASSERT_INTERNAL((0 <= TimeInfo.second) && (TimeInfo.second <= 60),
 	        ErrorHandler::InternalErrorType::InvalidDate);
 
 	uint32_t secs = 1546300800; // elapsed seconds from Unix epoch until 1/1/2019 00:00:00 (UTC)
@@ -31,7 +31,7 @@ uint32_t TimeHelper::utcToSeconds(TimeAndDate &TimeInfo) {
 	}
 	for (uint16_t m = 1; m < TimeInfo.month; ++m) {
 		secs += DaysOfMonth[m - 1] * SECONDS_PER_DAY;
-		if (m == 2 && IsLeapYear(TimeInfo.year)) {
+		if ((m == 2u) && IsLeapYear(TimeInfo.year)) {
 			secs += SECONDS_PER_DAY;
 		}
 	}
@@ -67,7 +67,7 @@ struct TimeAndDate TimeHelper::secondsToUTC(uint32_t seconds) {
 		TimeInfo.month++;
 		seconds -= (DaysOfMonth[i] * SECONDS_PER_DAY);
 		i++;
-		if (i == 1 && IsLeapYear(TimeInfo.year)) {
+		if ((i == 1u) && IsLeapYear(TimeInfo.year)) {
 			if (seconds <= (28 * SECONDS_PER_DAY)) {
 				break;
 			}
@@ -116,14 +116,14 @@ uint64_t TimeHelper::generateCDStimeFormat(TimeAndDate &TimeInfo) {
 	 */
 	auto msOfDay = static_cast<uint32_t >((seconds % SECONDS_PER_DAY) * 1000);
 
-	uint64_t timeFormat = (static_cast<uint64_t>(elapsedDays) << 32 | msOfDay);
+	uint64_t timeFormat = (static_cast<uint64_t>(elapsedDays) << 32) | msOfDay;
 
 	return timeFormat;
 }
 
 TimeAndDate TimeHelper::parseCDStimeFormat(const uint8_t *data) {
-	uint16_t elapsedDays = (static_cast<uint16_t >(data[0])) << 8 | static_cast<uint16_t >
-	(data[1]);
+	uint16_t elapsedDays = (static_cast<uint16_t >(data[0])) << 8) | (static_cast<uint16_t >
+		(data[1]));
 	uint32_t msOfDay = (static_cast<uint32_t >(data[2])) << 24 |
 	                   (static_cast<uint32_t >(data[3])) << 16 |
 	                   (static_cast<uint32_t >(data[4])) << 8 |
diff --git a/src/Message.cpp b/src/Message.cpp
index 0127ecf6..38b04749 100644
--- a/src/Message.cpp
+++ b/src/Message.cpp
@@ -15,7 +15,7 @@ void Message::appendBits(uint8_t numBits, uint16_t data) {
 	while (numBits > 0) { // For every sequence of 8 bits...
 		ASSERT_INTERNAL(dataSize < ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooLarge);
 
-		if (currentBit + numBits >= 8) {
+		if ((currentBit + numBits) >= 8) {
 			// Will have to shift the bits and insert the next ones later
 			auto bitsToAddNow = static_cast<uint8_t>(8 - currentBit);
 
@@ -54,7 +54,7 @@ void Message::appendByte(uint8_t value) {
 }
 
 void Message::appendHalfword(uint16_t value) {
-	ASSERT_INTERNAL(dataSize + 2 <= ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooLarge);
+	ASSERT_INTERNAL((dataSize + 2) <= ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooLarge);
 	ASSERT_INTERNAL(currentBit == 0, ErrorHandler::ByteBetweenBits);
 
 	data[dataSize] = static_cast<uint8_t>((value >> 8) & 0xFF);
@@ -64,7 +64,7 @@ void Message::appendHalfword(uint16_t value) {
 }
 
 void Message::appendWord(uint32_t value) {
-	ASSERT_INTERNAL(dataSize + 4 <= ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooLarge);
+	ASSERT_INTERNAL((dataSize + 4) <= ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooLarge);
 	ASSERT_INTERNAL(currentBit == 0, ErrorHandler::ByteBetweenBits);
 
 	data[dataSize] = static_cast<uint8_t>((value >> 24) & 0xFF);
@@ -83,10 +83,11 @@ uint16_t Message::readBits(uint8_t numBits) {
 	while (numBits > 0) {
 		ASSERT_REQUEST(readPosition < ECSS_MAX_MESSAGE_SIZE, ErrorHandler::MessageTooShort);
 
-		if (currentBit + numBits >= 8) {
-			auto bitsToAddNow = static_cast<uint8_t>(8 - currentBit);
+		if ((currentBit + numBits) >= 8) {
+			uint8_t bitsToAddNow = static_cast<uint8_t>(8 - currentBit);
 
-			auto maskedData = static_cast<uint8_t>(data[readPosition] & ((1 << bitsToAddNow) - 1));
+			uint8_t mask = ((1 << bitsToAddNow) - 1);
+			uint8_t maskedData = data[readPosition] & mask;
 			value |= maskedData << (numBits - bitsToAddNow);
 
 			numBits -= bitsToAddNow;
diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp
index d382dd34..bf3d36e2 100644
--- a/src/MessageParser.cpp
+++ b/src/MessageParser.cpp
@@ -36,10 +36,10 @@ Message MessageParser::parse(uint8_t *data, uint32_t length) {
 	auto sequenceFlags = static_cast<uint8_t>(packetSequenceControl >> 14);
 
 	// Returning an internal error, since the Message is not available yet
-	ASSERT_INTERNAL(versionNumber == 0, ErrorHandler::UnacceptablePacket);
-	ASSERT_INTERNAL(secondaryHeaderFlag == 1, ErrorHandler::UnacceptablePacket);
-	ASSERT_INTERNAL(sequenceFlags == 0x3, ErrorHandler::UnacceptablePacket);
-	ASSERT_INTERNAL(packetDataLength == length - 6, ErrorHandler::UnacceptablePacket);
+	ASSERT_INTERNAL(versionNumber == 0u, ErrorHandler::UnacceptablePacket);
+	ASSERT_INTERNAL(secondaryHeaderFlag == 1u, ErrorHandler::UnacceptablePacket);
+	ASSERT_INTERNAL(sequenceFlags == 0x3u, ErrorHandler::UnacceptablePacket);
+	ASSERT_INTERNAL(packetDataLength == (length - 6u), ErrorHandler::UnacceptablePacket);
 
 	Message message(0, 0, packetType, APID);
 
@@ -62,7 +62,7 @@ void MessageParser::parseTC(const uint8_t *data, uint16_t length, Message &messa
 
 	// todo: Fix this parsing function, because it assumes PUS header in data, which is not true
 	//  with the current implementation
-	ErrorHandler::assertRequest(pusVersion == 2, message, ErrorHandler::UnacceptableMessage);
+	ErrorHandler::assertRequest(pusVersion == 2u, message, ErrorHandler::UnacceptableMessage);
 
 	// Remove the length of the header
 	length -= 5;
@@ -110,7 +110,7 @@ void MessageParser::parseTM(const uint8_t *data, uint16_t length, Message &messa
 	uint8_t serviceType = data[1];
 	uint8_t messageType = data[2];
 
-	ErrorHandler::assertRequest(pusVersion == 2, message, ErrorHandler::UnacceptableMessage);
+	ErrorHandler::assertRequest(pusVersion == 2u, message, ErrorHandler::UnacceptableMessage);
 
 	// Remove the length of the header
 	length -= 5;
diff --git a/src/Service.cpp b/src/Service.cpp
index 66fdd045..061053b1 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -1 +1,3 @@
 #include "Service.hpp"
+
+// Nothing exists here yet
\ No newline at end of file
diff --git a/src/Services/EventActionService.cpp b/src/Services/EventActionService.cpp
index 6ac29c05..ed44e1c6 100644
--- a/src/Services/EventActionService.cpp
+++ b/src/Services/EventActionService.cpp
@@ -15,8 +15,8 @@ void EventActionService::addEventActionDefinitions(Message message) {
 	uint16_t eventDefinitionID = message.readEnum16();
 	bool accepted = true;
 	for (index = 0; index < ECSS_EVENT_ACTION_STRUCT_ARRAY_SIZE; index++) {
-		if (eventActionDefinitionArray[index].applicationId == applicationID &&
-		    eventActionDefinitionArray[index].eventDefinitionID == eventDefinitionID &&
+		if ((eventActionDefinitionArray[index].applicationId == applicationID) &&
+		    (eventActionDefinitionArray[index].eventDefinitionID == eventDefinitionID) &&
 		    eventActionDefinitionArray[index].enabled) {
 			// @todo: throw a failed start of execution error
 			accepted = false;
@@ -34,7 +34,7 @@ void EventActionService::addEventActionDefinitions(Message message) {
 			eventActionDefinitionArray[index].enabled = true;
 			eventActionDefinitionArray[index].applicationId = applicationID;
 			eventActionDefinitionArray[index].eventDefinitionID = eventDefinitionID;
-			if (message.dataSize - 4 > ECSS_TC_REQUEST_STRING_SIZE) {
+			if ((message.dataSize - 4) > ECSS_TC_REQUEST_STRING_SIZE) {
 				ErrorHandler::reportInternalError(ErrorHandler::InternalErrorType::MessageTooLarge);
 			} else {
 				char data[ECSS_TC_REQUEST_STRING_SIZE];
@@ -54,8 +54,8 @@ void EventActionService::deleteEventActionDefinitions(Message message) {
 		uint16_t applicationID = message.readEnum16();
 		uint16_t eventDefinitionID = message.readEnum16();
 		for (uint16_t index = 0; index < ECSS_EVENT_ACTION_STRUCT_ARRAY_SIZE; index++) {
-			if (eventActionDefinitionArray[index].applicationId == applicationID &&
-			    eventActionDefinitionArray[index].eventDefinitionID == eventDefinitionID &&
+			if ((eventActionDefinitionArray[index].applicationId == applicationID) &&
+			    (eventActionDefinitionArray[index].eventDefinitionID == eventDefinitionID) &&
 			    eventActionDefinitionArray[index].enabled) {
 				eventActionDefinitionArray[index].empty = true;
 				eventActionDefinitionArray[index].eventDefinitionID = 65535;
@@ -88,13 +88,13 @@ void EventActionService::enableEventActionDefinitions(Message message) {
 	message.assertTC(19, 4);
 
 	uint16_t numberOfEventActionDefinitions = message.readUint16();
-	if (numberOfEventActionDefinitions != 0){
+	if (numberOfEventActionDefinitions != 0u){
 		for (uint16_t i = 0; i < numberOfEventActionDefinitions; i++) {
 			uint16_t applicationID = message.readEnum16();
 			uint16_t eventDefinitionID = message.readEnum16();
 			for (uint16_t index = 0; index < ECSS_EVENT_ACTION_STRUCT_ARRAY_SIZE; index++) {
-				if (eventActionDefinitionArray[index].applicationId == applicationID &&
-				    eventActionDefinitionArray[index].eventDefinitionID == eventDefinitionID) {
+				if ((eventActionDefinitionArray[index].applicationId == applicationID) &&
+				    (eventActionDefinitionArray[index].eventDefinitionID == eventDefinitionID)) {
 					eventActionDefinitionArray[index].enabled = true;
 				}
 			}
@@ -113,13 +113,13 @@ void EventActionService::disableEventActionDefinitions(Message message) {
 	message.assertTC(19, 5);
 
 	uint16_t numberOfEventActionDefinitions = message.readUint16();
-	if (numberOfEventActionDefinitions != 0){
+	if (numberOfEventActionDefinitions != 0u) {
 		for (uint16_t i = 0; i < numberOfEventActionDefinitions; i++) {
 			uint16_t applicationID = message.readEnum16();
 			uint16_t eventDefinitionID = message.readEnum16();
 			for (uint16_t index = 0; index < ECSS_EVENT_ACTION_STRUCT_ARRAY_SIZE; index++) {
-				if (eventActionDefinitionArray[index].applicationId == applicationID &&
-				    eventActionDefinitionArray[index].eventDefinitionID == eventDefinitionID) {
+				if ((eventActionDefinitionArray[index].applicationId == applicationID) &&
+				    (eventActionDefinitionArray[index].eventDefinitionID == eventDefinitionID)) {
 					eventActionDefinitionArray[index].enabled = false;
 				}
 			}
diff --git a/src/Services/FunctionManagementService.cpp b/src/Services/FunctionManagementService.cpp
index 8dcc6027..ed05573b 100644
--- a/src/Services/FunctionManagementService.cpp
+++ b/src/Services/FunctionManagementService.cpp
@@ -15,7 +15,7 @@ void FunctionManagementService::call(Message& msg) {
 	msg.readString(funcName, FUNC_NAME_LENGTH);
 	msg.readString(funcArgs, MAX_ARG_LENGTH);
 
-	if (msg.dataSize > FUNC_NAME_LENGTH + MAX_ARG_LENGTH) {
+	if (msg.dataSize > (FUNC_NAME_LENGTH + MAX_ARG_LENGTH)) {
 		ErrorHandler::reportError(msg,
 			ErrorHandler::ExecutionStartErrorType::UnknownExecutionStartError);  // report failed
 			// start of execution as requested by the standard
diff --git a/src/Services/MemoryManagementService.cpp b/src/Services/MemoryManagementService.cpp
index c29c8fc1..0dd6f769 100644
--- a/src/Services/MemoryManagementService.cpp
+++ b/src/Services/MemoryManagementService.cpp
@@ -177,32 +177,32 @@ bool MemoryManagementService::addressValidator(
 
 	switch (memId) {
 		case MemoryManagementService::MemoryID::DTCMRAM:
-			if (address >= DTCMRAM_LOWER_LIM && address <= DTCMRAM_UPPER_LIM) {
+			if ((address >= DTCMRAM_LOWER_LIM) && (address <= DTCMRAM_UPPER_LIM)) {
 				validIndicator = true;
 			}
 			break;
 		case MemoryManagementService::MemoryID::ITCMRAM:
-			if (address >= ITCMRAM_LOWER_LIM && address <= ITCMRAM_UPPER_LIM) {
+			if ((address >= ITCMRAM_LOWER_LIM) && (address <= ITCMRAM_UPPER_LIM)) {
 				validIndicator = true;
 			}
 			break;
 		case MemoryManagementService::MemoryID::RAM_D1:
-			if (address >= RAM_D1_LOWER_LIM && address <= RAM_D1_UPPER_LIM) {
+			if ((address >= RAM_D1_LOWER_LIM) && (address <= RAM_D1_UPPER_LIM)) {
 				validIndicator = true;
 			}
 			break;
 		case MemoryManagementService::MemoryID::RAM_D2:
-			if (address >= RAM_D2_LOWER_LIM && address <= RAM_D2_UPPER_LIM) {
+			if ((address >= RAM_D2_LOWER_LIM) && (address <= RAM_D2_UPPER_LIM)) {
 				validIndicator = true;
 			}
 			break;
 		case MemoryManagementService::MemoryID::RAM_D3:
-			if (address >= RAM_D3_LOWER_LIM && address <= RAM_D3_UPPER_LIM) {
+			if ((address >= RAM_D3_LOWER_LIM) && (address <= RAM_D3_UPPER_LIM)) {
 				validIndicator = true;
 			}
 			break;
 		case MemoryManagementService::MemoryID::FLASH:
-			if (address >= FLASH_LOWER_LIM && address <= FLASH_UPPER_LIM) {
+			if ((address >= FLASH_LOWER_LIM) && (address <= FLASH_UPPER_LIM)) {
 				validIndicator = true;
 			}
 			break;
diff --git a/src/Services/ParameterService.cpp b/src/Services/ParameterService.cpp
index b32fa5b5..15b41223 100644
--- a/src/Services/ParameterService.cpp
+++ b/src/Services/ParameterService.cpp
@@ -53,7 +53,7 @@ void ParameterService::reportParameterIds(Message& paramIds) {
 	uint16_t ids = paramIds.readUint16();
 	reqParam.appendUint16(numOfValidIds(paramIds));   // include the number of valid IDs
 
-	for (int i = 0; i < ids; i++) {
+	for (uint16_t i = 0; i < ids; i++) {
 		uint16_t currId = paramIds.readUint16();      // current ID to be appended
 
 		if (paramsList.find(currId) != paramsList.end()) {
@@ -84,7 +84,7 @@ void ParameterService::setParameterIds(Message& newParamValues) {
 
 	uint16_t ids = newParamValues.readUint16();  //get number of ID's
 
-	for (int i = 0; i < ids; i++) {
+	for (uint16_t i = 0; i < ids; i++) {
 		uint16_t currId = newParamValues.readUint16();
 
 		if (paramsList.find(currId) != paramsList.end()) {
@@ -105,7 +105,7 @@ uint16_t ParameterService::numOfValidIds(Message idMsg) {
 	uint16_t ids = idMsg.readUint16();        // first 16bits of the packet are # of IDs
 	uint16_t validIds = 0;
 
-	for (int i = 0; i < ids; i++) {
+	for (uint16_t i = 0; i < ids; i++) {
 		uint16_t currId = idMsg.readUint16();
 
 		if (idMsg.messageType == 3) {
diff --git a/src/main.cpp b/src/main.cpp
index 4e5a4f46..f9430a0e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -322,10 +322,10 @@ int main() {
 	receivedMsg = Message(11, 4, Message::TC, 1);
 	receivedMsg.appendUint16(2); // Total number of requests
 
-	receivedMsg.appendUint32(currentTime + 1556435);
+	receivedMsg.appendUint32(currentTime + 1556435u);
 	receivedMsg.appendString(msgParser.convertTCToStr(testMessage1));
 
-	receivedMsg.appendUint32(currentTime + 1957232);
+	receivedMsg.appendUint32(currentTime + 1957232u);
 	receivedMsg.appendString(msgParser.convertTCToStr(testMessage2));
 	timeBasedSchedulingService.insertActivities(receivedMsg);
 
-- 
GitLab