Skip to content

Commit 0f879ad

Browse files
committed
Apply @kjbracey-arm's comments
1 parent 7711d4c commit 0f879ad

File tree

1 file changed

+7
-7
lines changed
  • targets/TARGET_Silicon_Labs/TARGET_EFM32

1 file changed

+7
-7
lines changed

targets/TARGET_Silicon_Labs/TARGET_EFM32/crc_api.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void hal_crc_compute_partial(const uint8_t *data, const size_t size)
113113
return;
114114
}
115115

116-
if (!enableWordInput || size < 4) {
116+
if (!enableWordInput || size < sizeof(uint32_t)) {
117117
// Input to a non-word-sized poly, or too small data size for a word input
118118
for (size_t i = 0; i < size; i++) {
119119
GPCRC_InputU8(GPCRC, data[i]);
@@ -122,21 +122,21 @@ void hal_crc_compute_partial(const uint8_t *data, const size_t size)
122122
size_t i = 0;
123123

124124
// If input is unaligned, take off as many bytes as needed to align
125-
if (((uint32_t)data & 0x3) != 0) {
126-
for (; i < (sizeof(uint32_t) - ((uint32_t)data & 0x3)); i++) {
127-
GPCRC_InputU8(GPCRC, data[i]);
128-
}
125+
while (((uint32_t)(data + i) & 0x3) != 0) {
126+
GPCRC_InputU8(GPCRC, data[i]);
127+
i++;
129128
}
130129

131130
// If enough input remaining to do word-sized writes, do so
132131
while ((size - i) >= sizeof(uint32_t)) {
133132
GPCRC_InputU32(GPCRC, *((uint32_t*)(&data[i])));
134-
i += 4;
133+
i += sizeof(uint32_t);
135134
}
136135

137136
// Do byte input to pick off the last remaining bytes
138-
for (; i < size; i++) {
137+
while (i < size) {
139138
GPCRC_InputU8(GPCRC, data[i]);
139+
i++;
140140
}
141141
}
142142
}

0 commit comments

Comments
 (0)