Skip to content

Commit 8658e7a

Browse files
committed
re-use length validator
1 parent ac99909 commit 8658e7a

File tree

1 file changed

+1
-3
lines changed
  • shared-bindings/microcontroller

1 file changed

+1
-3
lines changed

shared-bindings/microcontroller/Pin.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ void validate_no_duplicate_pins_2(mp_obj_t seq1, mp_obj_t seq2, qstr arg_name1,
156156
// Validate every element in the list to be a free pin.
157157
void validate_list_is_free_pins(qstr what, const mcu_pin_obj_t **pins_out, mp_int_t max_pins, mp_obj_t seq, uint8_t *count_out) {
158158
mp_int_t len = MP_OBJ_SMALL_INT_VALUE(mp_obj_len(seq));
159-
if (len > max_pins) {
160-
mp_raise_ValueError_varg(translate("At most %d %q may be specified (not %d)"), max_pins, what, len);
161-
}
159+
mp_arg_validate_length_max(len, max_pins, what);
162160
*count_out = len;
163161
for (mp_int_t i = 0; i < len; i++) {
164162
pins_out[i] = validate_obj_is_free_pin(mp_obj_subscr(seq, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL));

0 commit comments

Comments
 (0)