Skip to content

Commit 6ebeb3f

Browse files
committed
Demoted some variables from size_t to uint8_t (for loop indexes)
1 parent 04d4ccb commit 6ebeb3f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

saxbospiral/initialise.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ sxbp_status_t sxbp_init_spiral(sxbp_buffer_t buffer, sxbp_spiral_t* spiral) {
8787
*/
8888
for(size_t s = 0; s < buffer.size; s++) {
8989
// byte-level loop
90-
for(size_t b = 0; b < 8; b++) {
90+
for(uint8_t b = 0; b < 8; b++) {
9191
// bit level loop
9292
uint8_t e = 7 - b; // which power of two to use with bit mask
9393
uint8_t bit = (buffer.bytes[s] & (1 << e)) >> e; // the current bit
94-
size_t index = (s * 8) + b + 1; // line index
94+
size_t index = (s * 8) + (size_t)b + 1; // line index
9595
sxbp_rotation_t rotation; // the rotation we're going to make
9696
// set rotation direction based on the current bit
9797
rotation = (bit == 0) ? SXBP_CLOCKWISE : SXBP_ANTI_CLOCKWISE;

saxbospiral/serialise.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static uint64_t load_uint64_t(sxbp_buffer_t* buffer, size_t start_index) {
4949
// preconditional assertions
5050
assert(buffer->bytes != NULL);
5151
uint64_t value = 0;
52-
for(size_t i = 0; i < 8; i++) {
52+
for(uint8_t i = 0; i < 8; i++) {
5353
value |= (buffer->bytes[start_index + i]) << (8 * (7 - i));
5454
}
5555
return value;
@@ -65,7 +65,7 @@ static uint32_t load_uint32_t(sxbp_buffer_t* buffer, size_t start_index) {
6565
// preconditional assertions
6666
assert(buffer->bytes != NULL);
6767
uint32_t value = 0;
68-
for(size_t i = 0; i < 4; i++) {
68+
for(uint8_t i = 0; i < 4; i++) {
6969
value |= (buffer->bytes[start_index + i]) << (8 * (3 - i));
7070
}
7171
return value;

0 commit comments

Comments
 (0)