Replace passed buffer arguments with logical units #610

Open
opened 2022-04-29 15:09:59 +02:00 by muellerr · 0 comments
Owner

In C or embedded C++ programming, buffers are usually passed like this

int fooWriter(uint8_t* buf, size_t bufLen, uint8_t* writeThis, size_t writeLen) {}
int fooReader(const uint8_t* buf, size_t bufLen) {}

This can become a bit confusing once multiple of these pairs are passed into the function. I think it would be a good idea to pass these parameters as logical pairs:

using BufPair = std::pair<uint8_t*, size_t>;
using ConstBufPair = std::pair<const uint8_t*, size_t>;

int fooWriter(BufPair buf, BufPair toWrite);
int fooReader(ConstBufPair buf);
In C or embedded C++ programming, buffers are usually passed like this ```cpp int fooWriter(uint8_t* buf, size_t bufLen, uint8_t* writeThis, size_t writeLen) {} int fooReader(const uint8_t* buf, size_t bufLen) {} ``` This can become a bit confusing once multiple of these pairs are passed into the function. I think it would be a good idea to pass these parameters as logical pairs: ```cpp using BufPair = std::pair<uint8_t*, size_t>; using ConstBufPair = std::pair<const uint8_t*, size_t>; int fooWriter(BufPair buf, BufPair toWrite); int fooReader(ConstBufPair buf); ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fsfw/fsfw#610
No description provided.