Skip to content

Commit 966a48b

Browse files
committed
More size_t usage
1 parent d956b3b commit 966a48b

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

Diff for: lib/utils/buffer_helper.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
#include "lib/utils/buffer_helper.h"
2828

29-
void normalize_buffer_bounds(int32_t* start, int32_t end, uint32_t* length) {
29+
void normalize_buffer_bounds(int32_t* start, int32_t end, size_t* length) {
3030
if (end < 0) {
3131
end += *length;
32-
} else if (((uint32_t) end) > *length) {
32+
} else if (((size_t) end) > *length) {
3333
end = *length;
3434
}
3535
if (*start < 0) {

Diff for: lib/utils/buffer_helper.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
#define MICROPY_INCLUDED_LIB_UTILS_BUFFER_HELPER_H
2929

3030
#include <stdint.h>
31+
#include <string.h>
3132

32-
void normalize_buffer_bounds(int32_t* start, int32_t end, uint32_t* length);
33+
void normalize_buffer_bounds(int32_t* start, int32_t end, size_t* length);
3334

3435
#endif // MICROPY_INCLUDED_LIB_UTILS_BUFFER_HELPER_H

Diff for: shared-bindings/bitbangio/SPI.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_
275275
mp_buffer_info_t buf_out_info;
276276
mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ);
277277
int32_t out_start = args[ARG_out_start].u_int;
278-
uint32_t out_length = buf_out_info.len;
278+
size_t out_length = buf_out_info.len;
279279
normalize_buffer_bounds(&out_start, args[ARG_out_end].u_int, &out_length);
280280

281281
mp_buffer_info_t buf_in_info;
282282
mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE);
283283
int32_t in_start = args[ARG_in_start].u_int;
284-
uint32_t in_length = buf_in_info.len;
284+
size_t in_length = buf_in_info.len;
285285
normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length);
286286

287287
if (out_length != in_length) {

Diff for: shared-bindings/busio/SPI.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_
244244
mp_buffer_info_t bufinfo;
245245
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ);
246246
int32_t start = args[ARG_start].u_int;
247-
uint32_t length = bufinfo.len;
247+
size_t length = bufinfo.len;
248248
normalize_buffer_bounds(&start, args[ARG_end].u_int, &length);
249249

250250
if (length == 0) {
@@ -288,7 +288,7 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m
288288
mp_buffer_info_t bufinfo;
289289
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_WRITE);
290290
int32_t start = args[ARG_start].u_int;
291-
uint32_t length = bufinfo.len;
291+
size_t length = bufinfo.len;
292292
normalize_buffer_bounds(&start, args[ARG_end].u_int, &length);
293293

294294
if (length == 0) {
@@ -337,13 +337,13 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args
337337
mp_buffer_info_t buf_out_info;
338338
mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ);
339339
int32_t out_start = args[ARG_out_start].u_int;
340-
uint32_t out_length = buf_out_info.len;
340+
size_t out_length = buf_out_info.len;
341341
normalize_buffer_bounds(&out_start, args[ARG_out_end].u_int, &out_length);
342342

343343
mp_buffer_info_t buf_in_info;
344344
mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE);
345345
int32_t in_start = args[ARG_in_start].u_int;
346-
uint32_t in_length = buf_in_info.len;
346+
size_t in_length = buf_in_info.len;
347347
normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length);
348348

349349
if (out_length != in_length) {

0 commit comments

Comments
 (0)