Skip to content

Commit 6dff3df

Browse files
committed
py/objint: Use size_t for arguments that measure bytes/sizes.
1 parent 8bb7d95 commit 6dff3df

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

py/mpprint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ int mp_print_mp_int(const mp_print_t *print, mp_obj_t x, int base, int base_char
252252
// enough, a dynamic one will be allocated.
253253
char stack_buf[sizeof(mp_int_t) * 4];
254254
char *buf = stack_buf;
255-
mp_uint_t buf_size = sizeof(stack_buf);
256-
mp_uint_t fmt_size = 0;
255+
size_t buf_size = sizeof(stack_buf);
256+
size_t fmt_size = 0;
257257
char *str;
258258

259259
if (prec > 1) {

py/objint.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
133133
// enough, a dynamic one will be allocated.
134134
char stack_buf[sizeof(mp_int_t) * 4];
135135
char *buf = stack_buf;
136-
mp_uint_t buf_size = sizeof(stack_buf);
137-
mp_uint_t fmt_size;
136+
size_t buf_size = sizeof(stack_buf);
137+
size_t fmt_size;
138138

139139
char *str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size, self_in, 10, NULL, '\0', '\0');
140140
mp_print_str(print, str);
@@ -180,7 +180,7 @@ size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char co
180180
//
181181
// The resulting formatted string will be returned from this function and the
182182
// formatted size will be in *fmt_size.
183-
char *mp_obj_int_formatted(char **buf, mp_uint_t *buf_size, mp_uint_t *fmt_size, mp_const_obj_t self_in,
183+
char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
184184
int base, const char *prefix, char base_char, char comma) {
185185
fmt_int_t num;
186186
if (MP_OBJ_IS_SMALL_INT(self_in)) {
@@ -211,7 +211,7 @@ char *mp_obj_int_formatted(char **buf, mp_uint_t *buf_size, mp_uint_t *fmt_size,
211211
sign = '-';
212212
}
213213

214-
uint needed_size = mp_int_format_size(sizeof(fmt_int_t) * 8, base, prefix, comma);
214+
size_t needed_size = mp_int_format_size(sizeof(fmt_int_t) * 8, base, prefix, comma);
215215
if (needed_size > *buf_size) {
216216
*buf = m_new(char, needed_size);
217217
*buf_size = needed_size;

py/objint.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val);
5353
size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma);
5454

5555
void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
56-
char *mp_obj_int_formatted(char **buf, mp_uint_t *buf_size, mp_uint_t *fmt_size, mp_const_obj_t self_in,
56+
char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
5757
int base, const char *prefix, char base_char, char comma);
58-
char *mp_obj_int_formatted_impl(char **buf, mp_uint_t *buf_size, mp_uint_t *fmt_size, mp_const_obj_t self_in,
58+
char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
5959
int base, const char *prefix, char base_char, char comma);
6060
mp_int_t mp_obj_int_hash(mp_obj_t self_in);
61-
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, mp_uint_t len, byte *buf);
61+
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf);
6262
int mp_obj_int_sign(mp_obj_t self_in);
6363
mp_obj_t mp_obj_int_abs(mp_obj_t self_in);
6464
mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in);

py/objint_longlong.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
const mp_obj_int_t mp_maxsize_obj = {{&mp_type_int}, MP_SSIZE_MAX};
5454
#endif
5555

56-
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, mp_uint_t len, byte *buf) {
56+
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) {
5757
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int));
5858
mp_obj_int_t *self = self_in;
5959
long long val = self->val;

py/objint_mpz.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ STATIC mp_obj_int_t *mp_obj_int_new_mpz(void) {
9090
// formatted size will be in *fmt_size.
9191
//
9292
// This particular routine should only be called for the mpz representation of the int.
93-
char *mp_obj_int_formatted_impl(char **buf, mp_uint_t *buf_size, mp_uint_t *fmt_size, mp_const_obj_t self_in,
93+
char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
9494
int base, const char *prefix, char base_char, char comma) {
9595
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int));
9696
const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
9797

98-
mp_uint_t needed_size = mp_int_format_size(mpz_max_num_bits(&self->mpz), base, prefix, comma);
98+
size_t needed_size = mp_int_format_size(mpz_max_num_bits(&self->mpz), base, prefix, comma);
9999
if (needed_size > *buf_size) {
100100
*buf = m_new(char, needed_size);
101101
*buf_size = needed_size;
@@ -107,7 +107,7 @@ char *mp_obj_int_formatted_impl(char **buf, mp_uint_t *buf_size, mp_uint_t *fmt_
107107
return str;
108108
}
109109

110-
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, mp_uint_t len, byte *buf) {
110+
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) {
111111
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int));
112112
mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
113113
mpz_as_bytes(&self->mpz, big_endian, len, buf);

0 commit comments

Comments
 (0)