Skip to content

Commit 2052d4d

Browse files
committed
update isotp-c to latest, fix sa defect in isotp_mock.c
1 parent b04d1f9 commit 2052d4d

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

Diff for: src/tp/isotp-c/isotp.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int isotp_send_flow_control(const IsoTpLink* link, uint8_t flow_status, u
5858
return ret;
5959
}
6060

61-
static int isotp_send_single_frame(const IsoTpLink* link, uint32_t id) {
61+
static int isotp_send_single_frame(const IsoTpLink* link, uint32_t) {
6262

6363
IsoTpCanMessage message;
6464
int ret;
@@ -186,7 +186,7 @@ static int isotp_receive_first_frame(IsoTpLink *link, IsoTpCanMessage *message,
186186

187187
/* check data length */
188188
payload_length = message->as.first_frame.FF_DL_high;
189-
payload_length = (payload_length << 8) + message->as.first_frame.FF_DL_low;
189+
payload_length = (uint16_t)(payload_length << 8) + message->as.first_frame.FF_DL_low;
190190

191191
/* should not use multiple frame transmition */
192192
if (payload_length <= 7) {
@@ -269,8 +269,13 @@ int isotp_send_with_id(IsoTpLink *link, uint32_t id, const uint8_t payload[], ui
269269

270270
if (size > link->send_buf_size) {
271271
isotp_user_debug("Message size too large. Increase ISO_TP_MAX_MESSAGE_SIZE to set a larger buffer\n");
272-
char message[128];
273-
sprintf(&message[0], "Attempted to send %d bytes; max size is %d!\n", size, link->send_buf_size);
272+
const int32_t messageSize = 128;
273+
char message[messageSize];
274+
int32_t writtenChars = sprintf(&message[0], "Attempted to send %d bytes; max size is %d!\n", size, link->send_buf_size);
275+
276+
assert(writtenChars <= messageSize);
277+
(void) writtenChars;
278+
274279
isotp_user_debug(message);
275280
return ISOTP_RET_OVERFLOW;
276281
}
@@ -284,7 +289,7 @@ int isotp_send_with_id(IsoTpLink *link, uint32_t id, const uint8_t payload[], ui
284289
link->send_size = size;
285290
link->send_offset = 0;
286291
(void) memcpy(link->send_buffer, payload, size);
287-
292+
288293
if (link->send_size < 8) {
289294
/* send single frame */
290295
ret = isotp_send_single_frame(link, id);
@@ -307,7 +312,7 @@ int isotp_send_with_id(IsoTpLink *link, uint32_t id, const uint8_t payload[], ui
307312
return ret;
308313
}
309314

310-
void isotp_on_can_message(IsoTpLink *link, const uint8_t *data, uint8_t len) {
315+
void isotp_on_can_message(IsoTpLink* link, const uint8_t* data, uint8_t len) {
311316
IsoTpCanMessage message;
312317
int ret;
313318

Diff for: src/tp/isotp-c/isotp.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __ISOTP_H__
2-
#define __ISOTP_H__
1+
#ifndef ISOTPC_H
2+
#define ISOTPC_H
33

44
#include <stdio.h>
55
#include <string.h>
@@ -130,5 +130,5 @@ int isotp_receive(IsoTpLink *link, uint8_t *payload, const uint16_t payload_size
130130
}
131131
#endif
132132

133-
#endif // __ISOTP_H__
133+
#endif // ISOTPC_H
134134

Diff for: src/tp/isotp-c/isotp_config.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __ISOTP_CONFIG__
2-
#define __ISOTP_CONFIG__
1+
#ifndef ISOTPC_CONFIG_H
2+
#define ISOTPC_CONFIG_H
33

44
/* Max number of messages the receiver can receive at one time, this value
55
* is affected by can driver queue length
@@ -36,5 +36,4 @@
3636
*/
3737
//#define ISO_TP_USER_SEND_CAN_ARG
3838

39-
#endif
40-
39+
#endif // ISOTPC_CONFIG_H

Diff for: src/tp/isotp-c/isotp_defines.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __ISOTP_DEFINES_H__
2-
#define __ISOTP_DEFINES_H__
1+
#ifndef ISOTPC_USER_DEFINITIONS_H
2+
#define ISOTPC_USER_DEFINITIONS_H
33

44
#include <stdint.h>
55

@@ -225,5 +225,4 @@ typedef enum {
225225
#define ISOTP_PROTOCOL_RESULT_BUFFER_OVFLW -8
226226
#define ISOTP_PROTOCOL_RESULT_ERROR -9
227227

228-
#endif
229-
228+
#endif // ISOTPC_USER_DEFINITIONS_H

Diff for: src/tp/isotp-c/isotp_user.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __ISOTP_USER_H__
2-
#define __ISOTP_USER_H__
1+
#ifndef ISOTPC_USER_H
2+
#define ISOTPC_USER_H
33

44
#include <stdint.h>
55

@@ -32,5 +32,5 @@ uint32_t isotp_user_get_us(void);
3232
}
3333
#endif
3434

35-
#endif // __ISOTP_H__
35+
#endif // ISOTPC_USER_H
3636

Diff for: src/tp/isotp_mock.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ UDSTp_t *ISOTPMockNew(const char *name, ISOTPMockArgs_t *args) {
180180
if (name) {
181181
strncpy(tp->name, name, sizeof(tp->name));
182182
} else {
183-
snprintf(tp->name, sizeof(tp->name), "TPMock%d", TPCount);
183+
snprintf(tp->name, sizeof(tp->name), "TPMock%u", TPCount);
184184
}
185185
ISOTPMockAttach(tp, args);
186186
return &tp->hdl;

0 commit comments

Comments
 (0)