Skip to content

Commit 4e7107a

Browse files
committed
py: Change mp_print_strn_t func type to use size_t for the str length.
1 parent fad7d93 commit 4e7107a

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

lib/utils/printf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ typedef struct _strn_print_env_t {
9292
size_t remain;
9393
} strn_print_env_t;
9494

95-
STATIC void strn_print_strn(void *data, const char *str, mp_uint_t len) {
95+
STATIC void strn_print_strn(void *data, const char *str, size_t len) {
9696
strn_print_env_t *strn_print_env = data;
9797
if (len > strn_print_env->remain) {
9898
len = strn_print_env->remain;

py/emitglue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print) {
606606
#include <sys/stat.h>
607607
#include <fcntl.h>
608608

609-
STATIC void fd_print_strn(void *env, const char *str, mp_uint_t len) {
610-
int fd = (mp_int_t)env;
609+
STATIC void fd_print_strn(void *env, const char *str, size_t len) {
610+
int fd = (intptr_t)env;
611611
ssize_t ret = write(fd, str, len);
612612
(void)ret;
613613
}

py/mpprint.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@
4343
static const char pad_spaces[] = " ";
4444
static const char pad_zeroes[] = "0000000000000000";
4545

46-
STATIC void plat_print_strn(void *env, const char *str, mp_uint_t len) {
46+
STATIC void plat_print_strn(void *env, const char *str, size_t len) {
4747
(void)env;
4848
MP_PLAT_PRINT_STRN(str, len);
4949
}
5050

5151
const mp_print_t mp_plat_print = {NULL, plat_print_strn};
5252

5353
int mp_print_str(const mp_print_t *print, const char *str) {
54-
mp_uint_t len = strlen(str);
54+
size_t len = strlen(str);
5555
if (len) {
5656
print->print_strn(print->data, str, len);
5757
}
5858
return len;
5959
}
6060

61-
int mp_print_strn(const mp_print_t *print, const char *str, mp_uint_t len, int flags, char fill, int width) {
61+
int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width) {
6262
int left_pad = 0;
6363
int right_pad = 0;
6464
int pad = width - len;

py/mpprint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define PF_FLAG_ADD_PERCENT (0x100)
4040
#define PF_FLAG_SHOW_OCTAL_LETTER (0x200)
4141

42-
typedef void (*mp_print_strn_t)(void *data, const char *str, mp_uint_t len);
42+
typedef void (*mp_print_strn_t)(void *data, const char *str, size_t len);
4343

4444
typedef struct _mp_print_t {
4545
void *data;
@@ -55,7 +55,7 @@ extern const mp_print_t mp_sys_stdout_print;
5555
#endif
5656

5757
int mp_print_str(const mp_print_t *print, const char *str);
58-
int mp_print_strn(const mp_print_t *print, const char *str, mp_uint_t len, int flags, char fill, int width);
58+
int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width);
5959
#if MICROPY_PY_BUILTINS_FLOAT
6060
int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec);
6161
#endif

py/stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ STATIC mp_obj_t stream_read(mp_uint_t n_args, const mp_obj_t *args) {
174174
}
175175
}
176176

177-
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len) {
177+
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len) {
178178
struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)self_in;
179179
if (o->type->stream_p == NULL || o->type->stream_p->write == NULL) {
180180
// CPython: io.UnsupportedOperation, OSError subclass

py/stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_tell_obj);
4040
// Iterator which uses mp_stream_unbuffered_readline_obj
4141
mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self);
4242

43-
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len);
43+
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len);
4444

4545
#if MICROPY_STREAMS_NON_BLOCK
4646
// TODO: This is POSIX-specific (but then POSIX is the only real thing,

0 commit comments

Comments
 (0)