summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/gc.c3
-rw-r--r--py/objstr.c28
-rw-r--r--teensy/led.c3
-rw-r--r--teensy/servo.c3
-rw-r--r--tests/basics/enumerate.py2
5 files changed, 22 insertions, 17 deletions
diff --git a/py/gc.c b/py/gc.c
index 5533b84334..c8256fb03b 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -332,6 +332,9 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
} else {
// TODO check if we can grow inplace
void *ptr2 = gc_alloc(n_bytes);
+ if (ptr2 == NULL) {
+ return ptr2;
+ }
memcpy(ptr2, ptr, n_existing);
gc_free(ptr);
return ptr2;
diff --git a/py/objstr.c b/py/objstr.c
index 81e0d65b3b..8f6e90f810 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -100,7 +100,7 @@ static const byte *find_subbytes(const byte *haystack, uint hlen, const byte *ne
return NULL;
}
-mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+static mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
GET_STR_DATA_LEN(lhs_in, lhs_data, lhs_len);
switch (op) {
case RT_BINARY_OP_SUBSCR:
@@ -188,7 +188,7 @@ mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return MP_OBJ_NULL; // op not supported
}
-mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
+static mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
assert(MP_OBJ_IS_STR(self_in));
// get separation string
@@ -329,7 +329,7 @@ static bool chr_in_str(const byte* const str, const size_t str_len, int c) {
return false;
}
-mp_obj_t str_strip(uint n_args, const mp_obj_t *args) {
+static mp_obj_t str_strip(uint n_args, const mp_obj_t *args) {
assert(1 <= n_args && n_args <= 2);
assert(MP_OBJ_IS_STR(args[0]));
@@ -403,20 +403,20 @@ mp_obj_t str_format(uint n_args, const mp_obj_t *args) {
return s;
}
-mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
+static mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
assert(MP_OBJ_IS_STR(args[0]));
assert(MP_OBJ_IS_STR(args[1]));
assert(MP_OBJ_IS_STR(args[2]));
machine_int_t max_rep = 0;
if (n_args == 4) {
- assert(MP_OBJ_IS_SMALL_INT(args[3]));
- max_rep = MP_OBJ_SMALL_INT_VALUE(args[3]);
- if (max_rep == 0) {
- return args[0];
- } else if (max_rep < 0) {
- max_rep = 0;
- }
+ assert(MP_OBJ_IS_SMALL_INT(args[3]));
+ max_rep = MP_OBJ_SMALL_INT_VALUE(args[3]);
+ if (max_rep == 0) {
+ return args[0];
+ } else if (max_rep < 0) {
+ max_rep = 0;
+ }
}
// if max_rep is still 0 by this point we will need to do all possible replacements
@@ -427,7 +427,7 @@ mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
// old won't exist in str if it's longer, so nothing to replace
if (old_len > str_len) {
- return args[0];
+ return args[0];
}
// data for the replaced string
@@ -654,7 +654,7 @@ typedef struct _mp_obj_str_it_t {
machine_uint_t cur;
} mp_obj_str_it_t;
-mp_obj_t str_it_iternext(mp_obj_t self_in) {
+static mp_obj_t str_it_iternext(mp_obj_t self_in) {
mp_obj_str_it_t *self = self_in;
GET_STR_DATA_LEN(self->str, str, len);
if (self->cur < len) {
@@ -672,7 +672,7 @@ static const mp_obj_type_t str_it_type = {
.iternext = str_it_iternext,
};
-mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
+static mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
mp_obj_str_it_t *self = self_in;
GET_STR_DATA_LEN(self->str, str, len);
if (self->cur < len) {
diff --git a/teensy/led.c b/teensy/led.c
index 5eace0d373..f16ba83b39 100644
--- a/teensy/led.c
+++ b/teensy/led.c
@@ -42,8 +42,9 @@ typedef struct _pyb_led_obj_t {
uint led_id;
} pyb_led_obj_t;
-void led_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
+void led_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_led_obj_t *self = self_in;
+ (void)kind;
print(env, "<LED %lu>", self->led_id);
}
diff --git a/teensy/servo.c b/teensy/servo.c
index 3d6c9420d2..da720c892b 100644
--- a/teensy/servo.c
+++ b/teensy/servo.c
@@ -155,8 +155,9 @@ static mp_obj_t servo_obj_attached(mp_obj_t self_in) {
return MP_OBJ_NEW_SMALL_INT(attached);
}
-static void servo_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
+static void servo_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_servo_obj_t *self = self_in;
+ (void)kind;
print(env, "<Servo %lu>", self->servo_id);
}
diff --git a/tests/basics/enumerate.py b/tests/basics/enumerate.py
index f2bdf4f326..da97f46010 100644
--- a/tests/basics/enumerate.py
+++ b/tests/basics/enumerate.py
@@ -2,5 +2,5 @@ print(list(enumerate([])))
print(list(enumerate([1, 2, 3])))
print(list(enumerate([1, 2, 3], 5)))
print(list(enumerate([1, 2, 3], -5)))
-print(list(enumerate(range(10000))))
+print(list(enumerate(range(1000))))