Skip to content

Commit 3a79f07

Browse files
committed
test for MISRA
1 parent f762fdc commit 3a79f07

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Inc/crc/crc32_variants/crc32.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
uint32_t Crc32(
5858
const uint8_t* crc_data_ptr,
5959
uint32_t crc_length,
60-
bool final_xor
60+
bool final_xor,
61+
uint32_t* last_crc_value
6162
);
6263

6364
#endif /* UTILITY_CRC32_H_ */

Src/crc/crc32_variants/crc32.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ uint32_t
4545
Crc32(
4646
const uint8_t* crc_data_ptr,
4747
uint32_t crc_length,
48-
bool final_xor) {
48+
bool final_xor,
49+
uint32_t* last_crc_value) {
4950

5051
/* CRC32 also know as Ethernet CRC (Polynomial 0x4C11DB7) */
5152
static const uint32_t crc_table[256] = {
@@ -83,11 +84,16 @@ Crc32(
8384
0xAFB010B1U, 0xAB710D06U, 0xA6322BDFU, 0xA2F33668U, 0xBCB4666DU, 0xB8757BDAU, 0xB5365D03U, 0xB1F740B4U
8485
};
8586

87+
uint32_t crc_initial_value = INITIAL_CRC32_VALUE;
88+
if (NULL_PTR != last_crc_value) {
89+
crc_initial_value = *last_crc_value;
90+
}
91+
8692
return Crc32Base(
8793
crc_table,
8894
crc_data_ptr,
8995
crc_length,
90-
INITIAL_CRC32_VALUE,
96+
crc_initial_value,
9197
FINAL_XOR_VALUE,
9298
REFLECTED_OUTPUT,
9399
REFLECTED_INPUT,

0 commit comments

Comments
 (0)