Skip to content

Commit 556c8a9

Browse files
committed
unix: Fix coverage build now that mp_plat_print uses write.
1 parent 4300c7d commit 556c8a9

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

unix/coverage.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
STATIC mp_obj_t extra_coverage(void) {
1212
// mp_printf (used by ports that don't have a native printf)
1313
{
14-
printf("# mp_printf\n");
14+
mp_printf(&mp_plat_print, "# mp_printf\n");
1515
mp_printf(&mp_plat_print, "%"); // nothing after percent
1616
mp_printf(&mp_plat_print, "%d %+d % d\n", -123, 123, 123); // sign
1717
mp_printf(&mp_plat_print, "%05d\n", -123); // negative number with zero padding
@@ -26,85 +26,85 @@ STATIC mp_obj_t extra_coverage(void) {
2626

2727
// vstr
2828
{
29-
printf("# vstr\n");
29+
mp_printf(&mp_plat_print, "# vstr\n");
3030
vstr_t *vstr = vstr_new_size(16);
3131
vstr_hint_size(vstr, 32);
3232
vstr_add_str(vstr, "ts");
3333
vstr_ins_byte(vstr, 1, 'e');
3434
vstr_ins_char(vstr, 3, 't');
3535
vstr_ins_char(vstr, 10, 's');
36-
printf("%.*s\n", (int)vstr->len, vstr->buf);
36+
mp_printf(&mp_plat_print, "%.*s\n", (int)vstr->len, vstr->buf);
3737

3838
vstr_cut_head_bytes(vstr, 2);
39-
printf("%.*s\n", (int)vstr->len, vstr->buf);
39+
mp_printf(&mp_plat_print, "%.*s\n", (int)vstr->len, vstr->buf);
4040

4141
vstr_cut_tail_bytes(vstr, 10);
42-
printf("%.*s\n", (int)vstr->len, vstr->buf);
42+
mp_printf(&mp_plat_print, "%.*s\n", (int)vstr->len, vstr->buf);
4343

4444
vstr_printf(vstr, "t%cst", 'e');
45-
printf("%.*s\n", (int)vstr->len, vstr->buf);
45+
mp_printf(&mp_plat_print, "%.*s\n", (int)vstr->len, vstr->buf);
4646

4747
vstr_cut_out_bytes(vstr, 3, 10);
48-
printf("%.*s\n", (int)vstr->len, vstr->buf);
48+
mp_printf(&mp_plat_print, "%.*s\n", (int)vstr->len, vstr->buf);
4949

5050
VSTR_FIXED(fix, 4);
5151
vstr_add_str(&fix, "large");
52-
printf("%.*s\n", (int)fix.len, fix.buf);
52+
mp_printf(&mp_plat_print, "%.*s\n", (int)fix.len, fix.buf);
5353
}
5454

5555
// repl autocomplete
5656
{
57-
printf("# repl\n");
57+
mp_printf(&mp_plat_print, "# repl\n");
5858

5959
const char *str;
6060
mp_uint_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
61-
printf("%.*s\n", (int)len, str);
61+
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
6262

6363
mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0)));
6464
mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str);
6565
len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str);
66-
printf("%.*s\n", (int)len, str);
66+
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
6767
}
6868

6969
// attrtuple
7070
{
71-
printf("# attrtuple\n");
71+
mp_printf(&mp_plat_print, "# attrtuple\n");
7272

7373
static const qstr fields[] = {MP_QSTR_start, MP_QSTR_stop, MP_QSTR_step};
7474
static const mp_obj_t items[] = {MP_OBJ_NEW_SMALL_INT(1), MP_OBJ_NEW_SMALL_INT(2), MP_OBJ_NEW_SMALL_INT(3)};
7575
mp_obj_print_helper(&mp_plat_print, mp_obj_new_attrtuple(fields, 3, items), PRINT_REPR);
76-
printf("\n");
76+
mp_printf(&mp_plat_print, "\n");
7777
}
7878

7979
// str
8080
{
81-
printf("# str\n");
81+
mp_printf(&mp_plat_print, "# str\n");
8282

8383
// intern string
84-
printf("%d\n", MP_OBJ_IS_QSTR(mp_obj_str_intern(mp_obj_new_str("intern me", 9, false))));
84+
mp_printf(&mp_plat_print, "%d\n", MP_OBJ_IS_QSTR(mp_obj_str_intern(mp_obj_new_str("intern me", 9, false))));
8585
}
8686

8787
// mpz
8888
{
89-
printf("# mpz\n");
89+
mp_printf(&mp_plat_print, "# mpz\n");
9090

9191
mp_uint_t value;
9292
mpz_t mpz;
9393
mpz_init_zero(&mpz);
9494

9595
// mpz_as_uint_checked, with success
9696
mpz_set_from_int(&mpz, 12345678);
97-
printf("%d\n", mpz_as_uint_checked(&mpz, &value));
98-
printf("%d\n", (int)value);
97+
mp_printf(&mp_plat_print, "%d\n", mpz_as_uint_checked(&mpz, &value));
98+
mp_printf(&mp_plat_print, "%d\n", (int)value);
9999

100100
// mpz_as_uint_checked, with negative arg
101101
mpz_set_from_int(&mpz, -1);
102-
printf("%d\n", mpz_as_uint_checked(&mpz, &value));
102+
mp_printf(&mp_plat_print, "%d\n", mpz_as_uint_checked(&mpz, &value));
103103

104104
// mpz_as_uint_checked, with overflowing arg
105105
mpz_set_from_int(&mpz, 1);
106106
mpz_shl_inpl(&mpz, &mpz, 70);
107-
printf("%d\n", mpz_as_uint_checked(&mpz, &value));
107+
mp_printf(&mp_plat_print, "%d\n", mpz_as_uint_checked(&mpz, &value));
108108
}
109109

110110
return mp_const_none;

unix/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void mp_unix_mark_exec(void);
192192
#define MP_PLAT_FREE_EXEC(ptr, size) mp_unix_free_exec(ptr, size)
193193

194194
#include <unistd.h>
195-
#define MP_PLAT_PRINT_STRN(str, len) write(1, str, len)
195+
#define MP_PLAT_PRINT_STRN(str, len) do { ssize_t ret = write(1, str, len); (void)ret; } while (0)
196196

197197
#ifdef __linux__
198198
// Can access physical memory using /dev/mem

0 commit comments

Comments
 (0)