Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove FPP dependencies on native int types #2548

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Drv/BlockDriver/BlockDriverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
this->BufferOut_out(0,buffer);
}

void BlockDriverImpl::Sched_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) {
void BlockDriverImpl::Sched_handler(NATIVE_INT_TYPE portNum, U32 context) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

portNum uses the basic integral type int rather than a typedef with size and signedness.
}

void BlockDriverImpl::callIsr() {
Expand Down
2 changes: 1 addition & 1 deletion Drv/BlockDriver/BlockDriverImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Drv {
// downcalls for input ports
void InterruptReport_internalInterfaceHandler(U32 ip);
void BufferIn_handler(NATIVE_INT_TYPE portNum, Drv::DataBuffer& buffer);
void Sched_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context);
void Sched_handler(NATIVE_INT_TYPE portNum, U32 context);
//! Handler implementation for PingIn
//!
void PingIn_handler(
Expand Down
6 changes: 3 additions & 3 deletions Drv/Ip/SocketReadTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

void SocketReadTask::startSocketTask(const Fw::StringBase &name,
const bool reconnect,
const NATIVE_UINT_TYPE priority,
const NATIVE_UINT_TYPE stack,
const NATIVE_UINT_TYPE cpuAffinity) {
const Os::Task::ParamType priority,

Check notice

Code scanning / CodeQL

Use of basic integral type Note

priority uses the basic integral type unsigned long rather than a typedef with size and signedness.
const Os::Task::ParamType stack,

Check notice

Code scanning / CodeQL

Use of basic integral type Note

stack uses the basic integral type unsigned int rather than a typedef with size and signedness.
const Os::Task::ParamType cpuAffinity) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

cpuAffinity uses the basic integral type unsigned int rather than a typedef with size and signedness.
FW_ASSERT(not m_task.isStarted()); // It is a coding error to start this task multiple times
FW_ASSERT(not this->m_stop); // It is a coding error to stop the thread before it is started
m_reconnect = reconnect;
Expand Down
6 changes: 3 additions & 3 deletions Drv/Ip/SocketReadTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class SocketReadTask {
*/
void startSocketTask(const Fw::StringBase &name,
const bool reconnect = true,
const NATIVE_UINT_TYPE priority = Os::Task::TASK_DEFAULT,
const NATIVE_UINT_TYPE stack = Os::Task::TASK_DEFAULT,
const NATIVE_UINT_TYPE cpuAffinity = Os::Task::TASK_DEFAULT);
const Os::Task::ParamType priority = Os::Task::TASK_DEFAULT,
const Os::Task::ParamType stack = Os::Task::TASK_DEFAULT,
const Os::Task::ParamType cpuAffinity = Os::Task::TASK_DEFAULT);

/**
* \brief startup the socket for communications
Expand Down
2 changes: 1 addition & 1 deletion FppTest/dp/DpTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DpTest ::~DpTest() {}
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

void DpTest::schedIn_handler(const NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) {
void DpTest::schedIn_handler(const NATIVE_INT_TYPE portNum, U32 context) {
// Request a buffer for Container 1
this->dpRequest_Container1(CONTAINER_1_DATA_SIZE);
// Request a buffer for Container 2
Expand Down
2 changes: 1 addition & 1 deletion FppTest/dp/DpTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DpTest : public DpTestComponentBase {

//! Handler implementation for schedIn
void schedIn_handler(const NATIVE_INT_TYPE portNum, //!< The port number
NATIVE_UINT_TYPE context //!< The call order
U32 context //!< The call order
) override;

PRIVATE:
Expand Down
8 changes: 1 addition & 7 deletions Fw/Comp/ActiveComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@
}
#endif

void ActiveComponentBase::start(NATIVE_INT_TYPE identifier, NATIVE_INT_TYPE priority, NATIVE_INT_TYPE stackSize, NATIVE_INT_TYPE cpuAffinity) {
this->start(static_cast<NATIVE_UINT_TYPE>(priority), static_cast<NATIVE_UINT_TYPE>(stackSize),
((cpuAffinity == -1) ? Os::Task::TASK_DEFAULT : static_cast<NATIVE_UINT_TYPE>(cpuAffinity)),
static_cast<NATIVE_UINT_TYPE>(identifier));
}

void ActiveComponentBase::start(NATIVE_UINT_TYPE priority, NATIVE_UINT_TYPE stackSize, NATIVE_UINT_TYPE cpuAffinity, NATIVE_UINT_TYPE identifier) {
void ActiveComponentBase::start(Os::Task::ParamType priority, Os::Task::ParamType stackSize, Os::Task::ParamType cpuAffinity, Os::Task::ParamType identifier) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

priority uses the basic integral type unsigned long rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

stackSize uses the basic integral type unsigned long rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

cpuAffinity uses the basic integral type unsigned long rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

identifier uses the basic integral type unsigned long rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
Os::TaskString taskName;

#if FW_OBJECT_NAMES == 1
Expand Down
55 changes: 28 additions & 27 deletions Fw/Comp/ActiveComponentBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,41 @@
#ifndef FW_ACTIVE_COMPONENT_BASE_HPP
#define FW_ACTIVE_COMPONENT_BASE_HPP

#include <Fw/Comp/QueuedComponentBase.hpp>
#include <Os/Task.hpp>
#include <FpConfig.hpp>
#include <Fw/Comp/QueuedComponentBase.hpp>
#include <Fw/Deprecate.hpp>
#include <Os/Task.hpp>

namespace Fw {
class ActiveComponentBase : public QueuedComponentBase {
public:
void start(NATIVE_UINT_TYPE priority = Os::Task::TASK_DEFAULT, NATIVE_UINT_TYPE stackSize = Os::Task::TASK_DEFAULT, NATIVE_UINT_TYPE cpuAffinity = Os::Task::TASK_DEFAULT, NATIVE_UINT_TYPE identifier = Os::Task::TASK_DEFAULT); //!< called by instantiator when task is to be started
class ActiveComponentBase : public QueuedComponentBase {
public:
void start(Os::Task::ParamType priority = Os::Task::TASK_DEFAULT,
Os::Task::ParamType stackSize = Os::Task::TASK_DEFAULT,
Os::Task::ParamType cpuAffinity = Os::Task::TASK_DEFAULT,
Os::Task::ParamType identifier =
Os::Task::TASK_DEFAULT); //!< called by instantiator when task is to be started
void exit(); //!< exit task in active component
Os::Task::TaskStatus join(void** value_ptr); //!< provide return value of thread if value_ptr is not NULL

DEPRECATED(void start(NATIVE_INT_TYPE identifier, NATIVE_INT_TYPE priority, NATIVE_INT_TYPE stackSize, NATIVE_INT_TYPE cpuAffinity = -1),
"Please switch to start(NATIVE_UINT_TYPE priority, NATIVE_UINT_TYPE stackSize, NATIVE_UINT_TYPE cpuAffinity, NATIVE_UINT_TYPE identifier)"); //!< called by instantiator when task is to be started
void exit(); //!< exit task in active component
Os::Task::TaskStatus join(void **value_ptr); //!< provide return value of thread if value_ptr is not NULL

enum {
ACTIVE_COMPONENT_EXIT //!< message to exit active component task
};
enum {
ACTIVE_COMPONENT_EXIT //!< message to exit active component task
};

PROTECTED:
ActiveComponentBase(const char* name); //!< Constructor
virtual ~ActiveComponentBase(); //!< Destructor
void init(NATIVE_INT_TYPE instance); //!< initialization code
virtual void preamble(); //!< A function that will be called before the event loop is entered
virtual void loop(); //!< The function that will loop dispatching messages
virtual void finalizer(); //!< A function that will be called after exiting the loop
Os::Task m_task; //!< task object for active component
PROTECTED:
ActiveComponentBase(const char* name); //!< Constructor
Fixed Show fixed Hide fixed
virtual ~ActiveComponentBase(); //!< Destructor
void init(NATIVE_INT_TYPE instance); //!< initialization code
virtual void preamble(); //!< A function that will be called before the event loop is entered
virtual void loop(); //!< The function that will loop dispatching messages
virtual void finalizer(); //!< A function that will be called after exiting the loop
Os::Task m_task; //!< task object for active component
#if FW_OBJECT_TO_STRING == 1
virtual void toString(char* str, NATIVE_INT_TYPE size); //!< create string description of component
virtual void toString(char* str, NATIVE_INT_TYPE size); //!< create string description of component
#endif
PRIVATE:
static void s_baseTask(void*); //!< function provided to task class for new thread.
static void s_baseBareTask(void*); //!< function provided to task class for new thread.
};
PRIVATE:
static void s_baseTask(void*); //!< function provided to task class for new thread.
static void s_baseBareTask(void*); //!< function provided to task class for new thread.
};

}
} // namespace Fw
#endif
24 changes: 12 additions & 12 deletions Fw/Types/StringType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

bool StringBase::operator==(const StringBase& other) const {
NATIVE_UINT_TYPE len = this->length();
SizeType len = this->length();

Check notice

Code scanning / CodeQL

Use of basic integral type Note

len uses the basic integral type unsigned int rather than a typedef with size and signedness.
if (len != other.length()) {
return false;
} else {
Expand All @@ -51,15 +51,15 @@
return false;
}

const NATIVE_UINT_TYPE capacity = this->getCapacity();
const SizeType capacity = this->getCapacity();

Check notice

Code scanning / CodeQL

Use of basic integral type Note

capacity uses the basic integral type unsigned int rather than a typedef with size and signedness.
const size_t result = strncmp(us, other, capacity);
return (result == 0);

}

void StringBase::format(const CHAR* formatString, ...) {
CHAR* us = const_cast<CHAR*>(this->toChar());
NATIVE_UINT_TYPE cap = this->getCapacity();
SizeType cap = this->getCapacity();

Check notice

Code scanning / CodeQL

Use of basic integral type Note

cap uses the basic integral type unsigned int rather than a typedef with size and signedness.
FW_ASSERT(us);
va_list args;
va_start(args, formatString);
Expand Down Expand Up @@ -107,34 +107,34 @@
return *this;
}

void StringBase::appendBuff(const CHAR* buff, NATIVE_UINT_TYPE size) {
const U32 capacity = this->getCapacity();
const U32 length = this->length();
void StringBase::appendBuff(const CHAR* buff, SizeType size) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

buff uses the basic integral type char rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

size uses the basic integral type unsigned int rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
const SizeType capacity = this->getCapacity();

Check notice

Code scanning / CodeQL

Use of basic integral type Note

capacity uses the basic integral type unsigned int rather than a typedef with size and signedness.
const SizeType length = this->length();

Check notice

Code scanning / CodeQL

Use of basic integral type Note

length uses the basic integral type unsigned int rather than a typedef with size and signedness.
FW_ASSERT(capacity > length, capacity, length);
// Subtract 1 to leave space for null terminator
U32 remaining = capacity - length - 1;
SizeType remaining = capacity - length - 1;

Check notice

Code scanning / CodeQL

Use of basic integral type Note

remaining uses the basic integral type unsigned int rather than a typedef with size and signedness.
if(size < remaining) {
remaining = size;
}
FW_ASSERT(remaining < capacity, remaining, capacity);
(void) strncat(const_cast<CHAR*>(this->toChar()), buff, remaining);
}

NATIVE_UINT_TYPE StringBase::length() const {
return static_cast<NATIVE_UINT_TYPE>(StringUtils::string_length(this->toChar(),this->getCapacity()));
StringBase::SizeType StringBase::length() const {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

length uses the basic integral type unsigned int rather than a typedef with size and signedness.
return static_cast<SizeType>(StringUtils::string_length(this->toChar(),this->getCapacity()));
}

SerializeStatus StringBase::serialize(SerializeBufferBase& buffer) const {
return buffer.serialize(reinterpret_cast<const U8*>(this->toChar()),this->length());
}

SerializeStatus StringBase::serialize(SerializeBufferBase& buffer, NATIVE_UINT_TYPE maxLength) const {
NATIVE_INT_TYPE len = FW_MIN(maxLength,this->length());
SerializeStatus StringBase::serialize(SerializeBufferBase& buffer, SizeType maxLength) const {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

maxLength uses the basic integral type unsigned int rather than a typedef with size and signedness.
SizeType len = FW_MIN(maxLength,this->length());

Check notice

Code scanning / CodeQL

Use of basic integral type Note

len uses the basic integral type unsigned int rather than a typedef with size and signedness.
return buffer.serialize(reinterpret_cast<const U8*>(this->toChar()), len);
}

SerializeStatus StringBase::deserialize(SerializeBufferBase& buffer) {
NATIVE_UINT_TYPE maxSize = this->getCapacity() - 1;
SizeType maxSize = this->getCapacity() - 1;

Check notice

Code scanning / CodeQL

Use of basic integral type Note

maxSize uses the basic integral type unsigned int rather than a typedef with size and signedness.
CHAR* raw = const_cast<CHAR*>(this->toChar());
SerializeStatus stat = buffer.deserialize(reinterpret_cast<U8*>(raw),maxSize);
// Null terminate deserialized string
Expand Down
9 changes: 5 additions & 4 deletions Fw/Types/StringType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
namespace Fw {
class StringBase : public Serializable {
public:
using SizeType = NATIVE_UINT_TYPE;
virtual const CHAR* toChar() const = 0; //<! Convert to a C-style char*
virtual NATIVE_UINT_TYPE getCapacity() const = 0; //!< return size of buffer
NATIVE_UINT_TYPE length() const; //!< Get length of string
virtual SizeType getCapacity() const = 0; //!< return size of buffer
SizeType length() const; //!< Get length of string

const CHAR* operator+=(const CHAR* src); //!< Concatenate a CHAR*
const StringBase& operator+=(const StringBase& src); //!< Concatenate a StringBase
Expand All @@ -38,7 +39,7 @@ namespace Fw {
void format(const CHAR* formatString, ...); //!< write formatted string to buffer

virtual SerializeStatus serialize(SerializeBufferBase& buffer) const; //!< serialization function
virtual SerializeStatus serialize(SerializeBufferBase& buffer, NATIVE_UINT_TYPE maxLen) const; //!< serialization function
virtual SerializeStatus serialize(SerializeBufferBase& buffer, SizeType maxLen) const; //!< serialization function
virtual SerializeStatus deserialize(SerializeBufferBase& buffer); //!< deserialization function

#ifdef BUILD_UT
Expand All @@ -53,7 +54,7 @@ namespace Fw {
StringBase();
virtual ~StringBase();

void appendBuff(const CHAR* buff, NATIVE_UINT_TYPE size);
void appendBuff(const CHAR* buff, SizeType size);

private:
// A no-implementation copy constructor here will prevent the default copy constructor from being called
Expand Down
2 changes: 1 addition & 1 deletion Os/Baremetal/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Task::Task() :
m_suspendedOnPurpose(false)
{}

Task::TaskStatus Task::start(const Fw::StringBase &name, taskRoutine routine, void* arg, NATIVE_UINT_TYPE priority, NATIVE_UINT_TYPE stackSize, NATIVE_UINT_TYPE cpuAffinity, NATIVE_UINT_TYPE identifier) {
Task::TaskStatus Task::start(const Fw::StringBase &name, taskRoutine routine, void* arg, ParamType priority, ParamType stackSize, ParamType cpuAffinity, ParamType identifier) {
//Get a task handle, and set it up
BareTaskHandle* handle = new(std::nothrow) BareTaskHandle();
if (handle == nullptr) {
Expand Down
6 changes: 3 additions & 3 deletions Os/Posix/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
Fw::Logger::logMsg("[WARNING] Task priority set and permissions unavailable. Discarding priority.\n");
priority = Task::TASK_DEFAULT; //Action: use constant
}
if (priority != Task::TASK_DEFAULT and priority < static_cast<NATIVE_UINT_TYPE>(min_priority)) {
if (priority != Task::TASK_DEFAULT and priority < static_cast<Task::ParamType>(min_priority)) {
Fw::Logger::logMsg("[WARNING] Low task priority of %d being clamped to %d\n", priority, min_priority);
priority = min_priority;
}
if (priority != Task::TASK_DEFAULT and priority > static_cast<NATIVE_UINT_TYPE>(max_priority)) {
if (priority != Task::TASK_DEFAULT and priority > static_cast<Task::ParamType>(max_priority)) {
Fw::Logger::logMsg("[WARNING] High task priority of %d being clamped to %d\n", priority, max_priority);
priority = max_priority;
}
Expand Down Expand Up @@ -193,7 +193,7 @@
Task::Task() : m_handle(reinterpret_cast<POINTER_CAST>(nullptr)), m_identifier(0), m_affinity(-1), m_started(false), m_suspendedOnPurpose(false), m_routineWrapper() {
}

Task::TaskStatus Task::start(const Fw::StringBase &name, taskRoutine routine, void* arg, NATIVE_UINT_TYPE priority, NATIVE_UINT_TYPE stackSize, NATIVE_UINT_TYPE cpuAffinity, NATIVE_UINT_TYPE identifier) {
Task::TaskStatus Task::start(const Fw::StringBase &name, taskRoutine routine, void* arg, ParamType priority, ParamType stackSize, ParamType cpuAffinity, ParamType identifier) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

priority uses the basic integral type unsigned int rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

stackSize uses the basic integral type unsigned int rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

cpuAffinity uses the basic integral type unsigned int rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

identifier uses the basic integral type unsigned int rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

Check notice

Code scanning / CodeQL

Function too long Note

start has too many parameters (7, while 6 are allowed).
FW_ASSERT(routine);

this->m_name = "TP_";
Expand Down
Loading
Loading