Skip to content

Commit 88feacd

Browse files
authored
Many minor code improvements. (#323)
* Many minor code improvements. Signed-off-by: Cervenka Dusan <[email protected]> * Fix based on PR Signed-off-by: Cervenka Dusan <[email protected]> --------- Signed-off-by: Cervenka Dusan <[email protected]>
1 parent 21e035e commit 88feacd

Some content is hidden

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

71 files changed

+232
-221
lines changed

erpc_c/infra/erpc_arbitrated_client_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ArbitratedClientManager : public ClientManager
7676
*
7777
* @param[in] request Request context to perform.
7878
*/
79-
virtual void performClientRequest(RequestContext &request);
79+
virtual void performClientRequest(RequestContext &request) override;
8080

8181
//! @brief This method is not used with this class.
8282
void setTransport(Transport *transport) { (void)transport; }

erpc_c/infra/erpc_client_server_common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
namespace erpc {
3333

3434
/*!
35-
* @brief Common class inheritand by client and server class.
35+
* @brief Common class inherited by client and server class.
3636
*
3737
* @ingroup infra_utility
3838
*/

erpc_c/infra/erpc_crc16.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Crc16
3434
*
3535
* @param[in] crcStart Start value for crc function.
3636
*/
37-
Crc16(uint32_t crcStart);
37+
explicit Crc16(uint32_t crcStart);
3838

3939
/*!
4040
* @brief Constructor.

erpc_c/infra/erpc_message_loggers.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MessageLogger
3434
/*!
3535
* @brief MessageLogger constructor.
3636
*/
37-
MessageLogger(Transport *transport)
37+
explicit MessageLogger(Transport *transport)
3838
: m_next(NULL)
3939
, m_transport(transport){};
4040

erpc_c/infra/erpc_static_queue.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class StaticQueue
4242
m_capacity = elementCount;
4343
m_head = 0;
4444
m_tail = 0;
45+
(void)memset(m_storage, 0, sizeof(m_storage));
4546
}
4647

4748
/*!
@@ -106,9 +107,9 @@ class StaticQueue
106107
uint64_t m_storage[elementCount]
107108
[(sizeof(T) + sizeof(uint64_t) - 1U) / sizeof(uint64_t)]; /*!< Preallocated space based on data
108109
type size and elements count. */
109-
uint32_t m_capacity; /*!< Capacity of queue */
110-
uint32_t volatile m_head; /*!< Index to free slot */
111-
uint32_t volatile m_tail; /*!< Index to slot with m_data */
110+
uint32_t m_capacity; /*!< Capacity of queue */
111+
uint32_t volatile m_head; /*!< Index to free slot */
112+
uint32_t volatile m_tail; /*!< Index to slot with m_data */
112113
};
113114

114115
} // namespace erpc

erpc_c/port/erpc_serial.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ int serial_set_read_timeout(int fd, uint8_t vtime, uint8_t vmin)
171171
return 0;
172172
}
173173

174-
int serial_write(int fd, char *buf, int size)
174+
int serial_write(int fd, const char *buf, int size)
175175
{
176176
#ifdef _WIN32
177177
HANDLE hCom = (HANDLE)fd;
@@ -207,7 +207,6 @@ int serial_read(int fd, char *buf, int size)
207207
{
208208
#ifdef _WIN32
209209
HANDLE hCom = (HANDLE)fd;
210-
unsigned long bread = 0;
211210
char temp[RX_BUF_BYTES] = { 0 };
212211
DWORD errors;
213212
DWORD bytesToRead = 0;
@@ -262,7 +261,7 @@ int serial_read(int fd, char *buf, int size)
262261
return bytesToRead;
263262
#else
264263
int len = 0;
265-
int ret = 0;
264+
int ret;
266265
int timeout = 0;
267266

268267
while (len < size)

erpc_c/port/erpc_serial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extern "C" {
6464

6565
int serial_setup(int fd, speed_t speed);
6666
int serial_set_read_timeout(int fd, uint8_t vtime, uint8_t vmin);
67-
int serial_write(int fd, char *buf, int size);
67+
int serial_write(int fd, const char *buf, int size);
6868
int serial_read(int fd, char *buf, int size);
6969
int serial_open(const char *port);
7070
int serial_close(int fd);

erpc_c/port/erpc_spidev.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int spidev_set_wordbits(int fd, unsigned char bits)
6969
return retVal;
7070
}
7171

72-
int spidev_transfer(int fd, unsigned char *tx_buf, unsigned char *rx_buf, unsigned int len)
72+
int spidev_transfer(int fd, const unsigned char *tx_buf, unsigned char *rx_buf, unsigned int len)
7373
{
7474
int retVal = ERPC_SPIDEV_STATUS_SUCCESS;
7575
struct spi_ioc_transfer spi_message;

erpc_c/port/erpc_spidev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int spidev_open(const char *port);
2020
int spidev_set_mode(int fd, unsigned char mode);
2121
int spidev_set_speed(int fd, unsigned int speed_hz);
2222
int spidev_set_wordbits(int fd, unsigned char bits);
23-
int spidev_transfer(int fd, unsigned char *tx_buf, unsigned char *rx_buf, unsigned int len);
23+
int spidev_transfer(int fd, const unsigned char *tx_buf, unsigned char *rx_buf, unsigned int len);
2424
int spidev_close(int fd);
2525

2626
#if __cplusplus

erpc_c/setup/erpc_setup_dspi_master.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ERPC_MANUALLY_CONSTRUCTED(DspiMasterTransport, s_transport);
2525

2626
erpc_transport_t erpc_transport_dspi_master_init(void *baseAddr, uint32_t baudRate, uint32_t srcClock_Hz)
2727
{
28-
s_transport.construct((SPI_Type *)baseAddr, baudRate, srcClock_Hz);
28+
s_transport.construct(reinterpret_cast<SPI_Type *>(baseAddr), baudRate, srcClock_Hz);
2929
(void)s_transport->init();
3030
return reinterpret_cast<erpc_transport_t>(s_transport.get());
3131
}

0 commit comments

Comments
 (0)