Skip to content

Commit 6b34107

Browse files
committed
py: Change mp_uint_t to size_t for mp_obj_str_get_data len arg.
1 parent ca06fac commit 6b34107

File tree

11 files changed

+24
-24
lines changed

11 files changed

+24
-24
lines changed

py/builtinevex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
7878
(void)n_args;
7979

8080
// get the source
81-
mp_uint_t str_len;
81+
size_t str_len;
8282
const char *str = mp_obj_str_get_data(args[0], &str_len);
8383

8484
// get the filename
@@ -128,7 +128,7 @@ STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_i
128128
}
129129
#endif
130130

131-
mp_uint_t str_len;
131+
size_t str_len;
132132
const char *str = mp_obj_str_get_data(args[0], &str_len);
133133

134134
// create the lexer

py/builtinimport.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *d
111111
// go through each path looking for a directory or file
112112
for (mp_uint_t i = 0; i < path_num; i++) {
113113
vstr_reset(dest);
114-
mp_uint_t p_len;
114+
size_t p_len;
115115
const char *p = mp_obj_str_get_data(path_items[i], &p_len);
116116
if (p_len > 0) {
117117
vstr_add_strn(dest, p, p_len);
@@ -265,7 +265,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
265265
}
266266
}
267267

268-
mp_uint_t mod_len;
268+
size_t mod_len;
269269
const char *mod_str = mp_obj_str_get_data(module_name, &mod_len);
270270

271271
if (level != 0) {
@@ -296,7 +296,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
296296
DEBUG_printf("\n");
297297
#endif
298298

299-
mp_uint_t this_name_l;
299+
size_t this_name_l;
300300
const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l);
301301

302302
const char *p = this_name + this_name_l;

py/modbuiltins.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
336336
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct);
337337

338338
STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
339-
mp_uint_t len;
339+
size_t len;
340340
const char *str = mp_obj_str_get_data(o_in, &len);
341341
#if MICROPY_PY_BUILTINS_STR_UNICODE
342342
if (MP_OBJ_IS_STR(o_in)) {
@@ -397,9 +397,9 @@ STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *
397397
mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_sep), MP_MAP_LOOKUP);
398398
mp_map_elem_t *end_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_end), MP_MAP_LOOKUP);
399399
const char *sep_data = " ";
400-
mp_uint_t sep_len = 1;
400+
size_t sep_len = 1;
401401
const char *end_data = "\n";
402-
mp_uint_t end_len = 1;
402+
size_t end_len = 1;
403403
if (sep_elem != NULL && sep_elem->value != mp_const_none) {
404404
sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len);
405405
}

py/obj.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ void mp_init_emergency_exception_buf(void);
712712
bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2);
713713
qstr mp_obj_str_get_qstr(mp_obj_t self_in); // use this if you will anyway convert the string to a qstr
714714
const char *mp_obj_str_get_str(mp_obj_t self_in); // use this only if you need the string to be null terminated
715-
const char *mp_obj_str_get_data(mp_obj_t self_in, mp_uint_t *len);
715+
const char *mp_obj_str_get_data(mp_obj_t self_in, size_t *len);
716716
mp_obj_t mp_obj_str_intern(mp_obj_t str);
717717
void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, bool is_bytes);
718718

py/objcomplex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, si
8080
case 1:
8181
if (MP_OBJ_IS_STR(args[0])) {
8282
// a string, parse it
83-
mp_uint_t l;
83+
size_t l;
8484
const char *s = mp_obj_str_get_data(args[0], &l);
8585
return mp_parse_num_decimal(s, l, true, true, NULL);
8686
} else if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) {

py/objfloat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size
8989
default:
9090
if (MP_OBJ_IS_STR(args[0])) {
9191
// a string, parse it
92-
mp_uint_t l;
92+
size_t l;
9393
const char *s = mp_obj_str_get_data(args[0], &l);
9494
return mp_parse_num_decimal(s, l, false, false, NULL);
9595
} else if (mp_obj_is_float(args[0])) {

py/objfun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
501501
return mp_obj_int_get_truncated(obj);
502502
} else if (MP_OBJ_IS_STR(obj)) {
503503
// pointer to the string (it's probably constant though!)
504-
mp_uint_t l;
504+
size_t l;
505505
return (mp_uint_t)mp_obj_str_get_data(obj, &l);
506506
} else {
507507
mp_obj_type_t *type = mp_obj_get_type(obj);

py/objint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args,
5656
return args[0];
5757
} else if (MP_OBJ_IS_STR_OR_BYTES(args[0])) {
5858
// a string, parse it
59-
mp_uint_t l;
59+
size_t l;
6060
const char *s = mp_obj_str_get_data(args[0], &l);
6161
return mp_parse_num_integer(s, l, 0, NULL);
6262
#if MICROPY_PY_BUILTINS_FLOAT
@@ -72,7 +72,7 @@ STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args,
7272
default: {
7373
// should be a string, parse it
7474
// TODO proper error checking of argument types
75-
mp_uint_t l;
75+
size_t l;
7676
const char *s = mp_obj_str_get_data(args[0], &l);
7777
return mp_parse_num_integer(s, l, mp_obj_get_int(args[1]), NULL);
7878
}

py/objstr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args) {
513513
bad_implicit_conversion(sep);
514514
}
515515

516-
mp_uint_t sep_len;
516+
size_t sep_len;
517517
const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
518518

519519
if (sep_len == 0) {
@@ -611,7 +611,7 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
611611
if (sep == mp_const_none) {
612612
mp_not_implemented("rsplit(None,n)");
613613
} else {
614-
mp_uint_t sep_len;
614+
size_t sep_len;
615615
const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
616616

617617
if (sep_len == 0) {
@@ -1306,12 +1306,12 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
13061306
switch (type) {
13071307
case '\0': // no explicit format type implies 's'
13081308
case 's': {
1309-
mp_uint_t slen;
1309+
size_t slen;
13101310
const char *s = mp_obj_str_get_data(arg, &slen);
13111311
if (precision < 0) {
13121312
precision = slen;
13131313
}
1314-
if (slen > (mp_uint_t)precision) {
1314+
if (slen > (size_t)precision) {
13151315
slen = precision;
13161316
}
13171317
mp_print_strn(&print, s, slen, flags, fill, width);
@@ -1452,7 +1452,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
14521452
switch (*str) {
14531453
case 'c':
14541454
if (MP_OBJ_IS_STR(arg)) {
1455-
mp_uint_t slen;
1455+
size_t slen;
14561456
const char *s = mp_obj_str_get_data(arg, &slen);
14571457
if (slen != 1) {
14581458
mp_raise_TypeError("%%c requires int or char");
@@ -2097,7 +2097,7 @@ const char *mp_obj_str_get_str(mp_obj_t self_in) {
20972097
}
20982098
}
20992099

2100-
const char *mp_obj_str_get_data(mp_obj_t self_in, mp_uint_t *len) {
2100+
const char *mp_obj_str_get_data(mp_obj_t self_in, size_t *len) {
21012101
if (MP_OBJ_IS_STR_OR_BYTES(self_in)) {
21022102
GET_STR_DATA_LEN(self_in, s, l);
21032103
*len = l;

py/repl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
153153
mp_obj_t obj = MP_OBJ_NULL;
154154
for (mp_uint_t i = 0; i < dict->map.alloc; i++) {
155155
if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
156-
mp_uint_t d_len;
156+
size_t d_len;
157157
const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len);
158158
if (s_len == d_len && strncmp(s_start, d_str, d_len) == 0) {
159159
obj = dict->map.table[i].value;
@@ -197,7 +197,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
197197
mp_uint_t match_len = 0;
198198
for (mp_uint_t i = 0; i < dict->map.alloc; i++) {
199199
if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
200-
mp_uint_t d_len;
200+
size_t d_len;
201201
const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len);
202202
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
203203
if (match_str == NULL) {
@@ -247,7 +247,7 @@ mp_uint_t mp_repl_autocomplete(const char *str, mp_uint_t len, const mp_print_t
247247
int line_len = MAX_LINE_LEN; // force a newline for first word
248248
for (mp_uint_t i = 0; i < dict->map.alloc; i++) {
249249
if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
250-
mp_uint_t d_len;
250+
size_t d_len;
251251
const char *d_str = mp_obj_str_get_data(dict->map.table[i].key, &d_len);
252252
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
253253
int gap = (line_len + WORD_SLOT_LEN - 1) / WORD_SLOT_LEN * WORD_SLOT_LEN - line_len;

0 commit comments

Comments
 (0)