Skip to content

Commit c212ed7

Browse files
Merge branch 'main' into arbitrator-timeout
2 parents cc68692 + 9967e4a commit c212ed7

63 files changed

Lines changed: 170 additions & 278 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
### Updated
13+
14+
- eRPC Zephyr module port updated for Zephyr version 4.4
15+
1216
### Fixed
1317
- Python code of the eRPC infrastructure was updated to match the proper python code style, add type annotations and improve readability.
18+
- eRPC: Several MISRA violations addressed.
1419

1520
## [1.14.0]
1621

erpc_c/infra/erpc_arbitrated_client_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2016, Freescale Semiconductor, Inc.
3-
* Copyright 2016-2020 NXP
3+
* Copyright 2016-2026 NXP
44
* Copyright 2021 ACRIOS Systems s.r.o.
55
* All rights reserved.
66
*
@@ -86,7 +86,7 @@ void ArbitratedClientManager::performClientRequest(RequestContext &request)
8686
m_arbitrator->clientReceive(token);
8787
}
8888

89-
if (token != 0)
89+
if (token != 0U)
9090
{
9191
// Also if status bad, need to free the token.
9292
m_arbitrator->removePendingClient(token);

erpc_c/infra/erpc_basic_codec.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2014, Freescale Semiconductor, Inc.
3-
* Copyright 2016-2025 NXP
3+
* Copyright 2016-2026 NXP
44
* Copyright 2021 ACRIOS Systems s.r.o.
55
* All rights reserved.
66
*
@@ -307,7 +307,10 @@ void BasicCodec::readPtr(uintptr_t &value)
307307

308308
void BasicCodec::readString(uint32_t &length, char **value)
309309
{
310-
readBinary(length, reinterpret_cast<uint8_t **>(value));
310+
uint8_t *tempPtr = NULL;
311+
readBinary(length, &tempPtr);
312+
313+
*value = reinterpret_cast<char *>(tempPtr);
311314
}
312315

313316
void BasicCodec::readBinary(uint32_t &length, uint8_t **value)
@@ -331,7 +334,7 @@ void BasicCodec::readBinary(uint32_t &length, uint8_t **value)
331334
*value = m_cursor.get();
332335

333336
// Skip over data.
334-
m_cursor += (uint16_t)length;
337+
(void)(m_cursor += (uint16_t)length);
335338
}
336339
}
337340
if (!isStatusOk())

erpc_c/infra/erpc_message_buffer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
3-
* Copyright 2016-2025 NXP
3+
* Copyright 2016-2026 NXP
44
* Copyright 2021 ACRIOS Systems s.r.o.
55
* All rights reserved.
66
*
@@ -45,7 +45,7 @@ erpc_status_t MessageBuffer::read(uint16_t offset, void *data, uint32_t length)
4545
{
4646
err = kErpcStatus_MemoryError;
4747
}
48-
else if (offset >= m_len || length > (uint32_t)(m_len - offset))
48+
else if (offset >= m_len || length > ((uint32_t)m_len - (uint32_t)offset))
4949
{
5050
err = kErpcStatus_BufferOverrun;
5151
}
@@ -68,7 +68,7 @@ erpc_status_t MessageBuffer::write(uint16_t offset, const void *data, uint32_t l
6868
{
6969
err = kErpcStatus_MemoryError;
7070
}
71-
else if (offset >= m_len || length > (uint32_t)(m_len - offset))
71+
else if (offset >= m_len || length > ((uint32_t)m_len - (uint32_t)offset))
7272
{
7373
err = kErpcStatus_BufferOverrun;
7474
}
@@ -136,22 +136,22 @@ MessageBuffer &Cursor::getBufferRef(void)
136136
uint8_t &Cursor::operator[](int index)
137137
{
138138
erpc_assert(((m_pos + index) >= m_buffer.get()) &&
139-
((uint16_t)(m_pos - m_buffer.get()) + index <= m_buffer.getLength()));
139+
((int32_t)(m_pos - m_buffer.get()) + (int32_t)index <= (int32_t)m_buffer.getLength()));
140140

141141
return m_pos[index];
142142
}
143143

144144
const uint8_t &Cursor::operator[](int index) const
145145
{
146146
erpc_assert(((m_pos + index) >= m_buffer.get()) &&
147-
((uint16_t)(m_pos - m_buffer.get()) + index <= m_buffer.getLength()));
147+
((int32_t)(m_pos - m_buffer.get()) + (int32_t)index <= (int32_t)m_buffer.getLength()));
148148

149149
return m_pos[index];
150150
}
151151

152152
Cursor &Cursor::operator+=(uint16_t n)
153153
{
154-
erpc_assert((uint32_t)(m_pos - m_buffer.get()) + n <= m_buffer.getLength());
154+
erpc_assert((int32_t)(m_pos - m_buffer.get()) + (int32_t)n <= (int32_t)m_buffer.getLength());
155155

156156
m_pos += n;
157157

@@ -169,7 +169,7 @@ Cursor &Cursor::operator-=(uint16_t n)
169169

170170
Cursor &Cursor::operator++(void)
171171
{
172-
erpc_assert((uint16_t)(m_pos - m_buffer.get()) < m_buffer.getLength());
172+
erpc_assert((int32_t)(m_pos - m_buffer.get()) < (int32_t)m_buffer.getLength());
173173

174174
++m_pos;
175175

erpc_c/infra/erpc_message_buffer.hpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
3-
* Copyright 2016-2025 NXP
3+
* Copyright 2016-2026 NXP
44
* All rights reserved.
55
*
66
*
@@ -105,9 +105,10 @@ class MessageBuffer
105105
*
106106
* @return Length of free space of buffer.
107107
*/
108-
uint16_t getFree(void) const {
108+
uint16_t getFree(void) const
109+
{
109110
erpc_assert(m_used <= m_len);
110-
return m_len - m_used;
111+
return m_len - m_used;
111112
}
112113

113114
/*!
@@ -248,19 +249,21 @@ class Cursor
248249
*
249250
* @return Remaining free space in current buffer.
250251
*/
251-
uint16_t getRemaining(void) const {
252+
uint16_t getRemaining(void) const
253+
{
252254
erpc_assert(m_pos >= m_buffer.get() && m_pos <= m_buffer.get() + m_buffer.getLength());
253-
return m_buffer.getLength() - (uint16_t)(m_pos - m_buffer.get());
255+
return m_buffer.getLength() - (uint16_t)((uintptr_t)m_pos - (uintptr_t)m_buffer.get());
254256
}
255257

256258
/*!
257259
* @brief Return remaining space from used of current buffer.
258260
*
259261
* @return Remaining space from used of current buffer.
260262
*/
261-
uint16_t getRemainingUsed(void) const {
262-
erpc_assert(m_pos >= m_buffer.get() && m_pos <= m_buffer.get() + m_buffer.getLength());
263-
return m_buffer.getUsed() - (uint16_t)(m_pos - m_buffer.get());
263+
uint16_t getRemainingUsed(void) const
264+
{
265+
erpc_assert(m_pos >= m_buffer.get() && m_pos <= m_buffer.get() + m_buffer.getLength());
266+
return m_buffer.getUsed() - (uint16_t)((uintptr_t)m_pos - (uintptr_t)m_buffer.get());
264267
}
265268

266269
/*!

erpc_c/infra/erpc_transport_arbitrator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2016, Freescale Semiconductor, Inc.
3-
* Copyright 2016-2021 NXP
3+
* Copyright 2016-2026 NXP
44
* Copyright 2021 ACRIOS Systems s.r.o.
55
* All rights reserved.
66
*
@@ -66,7 +66,7 @@ erpc_status_t TransportArbitrator::receive(MessageBuffer *message)
6666
if (err == kErpcStatus_Timeout || err == kErpcStatus_ReceiveFailed)
6767
{
6868
client = m_clientList;
69-
for (; client; client = client->m_next)
69+
for (; client != NULL; client = client->m_next)
7070
{
7171
if (client->m_isValid)
7272
{
@@ -102,7 +102,7 @@ erpc_status_t TransportArbitrator::receive(MessageBuffer *message)
102102

103103
// Check if there is a client waiting for this message.
104104
client = m_clientList;
105-
for (; client; client = client->m_next)
105+
for (; client != NULL; client = client->m_next)
106106
{
107107
if (client->m_isValid && (sequence == client->m_request->getSequence()))
108108
{
@@ -187,13 +187,13 @@ TransportArbitrator::client_token_t TransportArbitrator::prepareClientReceive(Re
187187

188188
void TransportArbitrator::clientReceive(client_token_t token)
189189
{
190-
erpc_assert((token != 0) && ("invalid client token" != NULL));
190+
erpc_assert((token != 0U) && ("invalid client token" != NULL));
191191

192192
// Convert token to pointer to info struct for this client receive request.
193193
PendingClientInfo *info = reinterpret_cast<PendingClientInfo *>(token);
194194

195195
// Wait on the semaphore until we're signaled.
196-
info->m_sem.get(Semaphore::kWaitForever);
196+
(void)info->m_sem.get(Semaphore::kWaitForever);
197197
}
198198

199199
TransportArbitrator::PendingClientInfo *TransportArbitrator::createPendingClient(void){ ERPC_CREATE_NEW_OBJECT(
@@ -232,7 +232,7 @@ void TransportArbitrator::removePendingClient(client_token_t token)
232232
Mutex::Guard lock(m_clientListMutex);
233233
PendingClientInfo *node;
234234

235-
erpc_assert((token != 0) && ("invalid client token" != NULL));
235+
erpc_assert((token != 0U) && ("invalid client token" != NULL));
236236
erpc_assert((info->m_sem.getCount() == 0) && ("Semaphore should be clean" != NULL));
237237

238238
// Clear fields.

erpc_c/infra/erpc_utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright 2023 ACRIOS Systems s.r.o.
3+
* Copyright 2026 NXP
34
* All rights reserved.
45
*
56
*
@@ -11,7 +12,7 @@
1112
bool erpc::findIndexOfFunction(const arrayOfFunctionPtr_t sourceArrayOfFunctionPtr, uint16_t sourceArrayLength,
1213
const functionPtr_t functionPtr, uint16_t &retVal)
1314
{
14-
uint32_t index;
15+
uint16_t index;
1516
bool find = false;
1617
for (index = 0; index < sourceArrayLength; index++)
1718
{

erpc_c/infra/erpc_utils.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
/*
22
* Copyright 2023 ACRIOS Systems s.r.o.
3+
* Copyright 2026 NXP
34
* All rights reserved.
45
*
56
*
67
* SPDX-License-Identifier: BSD-3-Clause
78
*/
89

10+
#ifndef _EMBEDDED_RPC__UTILS_H_
11+
#define _EMBEDDED_RPC__UTILS_H_
12+
913
#include <stdint.h>
1014

1115
namespace erpc {
@@ -15,3 +19,4 @@ typedef functionPtr_t *arrayOfFunctionPtr_t;
1519
bool findIndexOfFunction(const arrayOfFunctionPtr_t sourceArrayOfFunctionPtr, uint16_t sourceArrayLength,
1620
const functionPtr_t functionPtr, uint16_t &retVal);
1721
} // namespace erpc
22+
#endif // _EMBEDDED_RPC__UTILS_H_

erpc_c/port/erpc_port_freertos.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ void operator delete[](void *ptr) THROW
5555

5656
void *erpc_malloc(size_t size)
5757
{
58+
if (size == 0)
59+
{
60+
return nullptr;
61+
}
5862
void *p = pvPortMalloc(size);
5963
return p;
6064
}

erpc_c/port/erpc_serial.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,24 @@ int serial_setup(int fd, speed_t speed)
103103
case 9600:
104104
speed = B9600;
105105
break;
106+
case 19200:
107+
speed = B19200;
108+
break;
106109
case 38400:
107110
speed = B38400;
108111
break;
109112
case 115200:
110113
speed = B115200;
111114
break;
115+
case 230400:
116+
speed = B230400;
117+
break;
118+
case 460800:
119+
speed = B460800;
120+
break;
121+
case 921600:
122+
speed = B921600;
123+
break;
112124
case 57600:
113125
default:
114126
speed = B57600;

0 commit comments

Comments
 (0)