Skip to content

Commit 2e2e404

Browse files
committed
py: Allow to compile with extra warnings (sign-compare, unused-param).
1 parent 02894b5 commit 2e2e404

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

py/lexer.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,33 @@ STATIC bool is_physical_newline(mp_lexer_t *lex) {
5858
return lex->chr0 == '\n';
5959
}
6060

61-
STATIC bool is_char(mp_lexer_t *lex, char c) {
61+
STATIC bool is_char(mp_lexer_t *lex, byte c) {
6262
return lex->chr0 == c;
6363
}
6464

65-
STATIC bool is_char_or(mp_lexer_t *lex, char c1, char c2) {
65+
STATIC bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) {
6666
return lex->chr0 == c1 || lex->chr0 == c2;
6767
}
6868

69-
STATIC bool is_char_or3(mp_lexer_t *lex, char c1, char c2, char c3) {
69+
STATIC bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) {
7070
return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3;
7171
}
7272

7373
/*
74-
STATIC bool is_char_following(mp_lexer_t *lex, char c) {
74+
STATIC bool is_char_following(mp_lexer_t *lex, byte c) {
7575
return lex->chr1 == c;
7676
}
7777
*/
7878

79-
STATIC bool is_char_following_or(mp_lexer_t *lex, char c1, char c2) {
79+
STATIC bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) {
8080
return lex->chr1 == c1 || lex->chr1 == c2;
8181
}
8282

83-
STATIC bool is_char_following_following_or(mp_lexer_t *lex, char c1, char c2) {
83+
STATIC bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byte c2) {
8484
return lex->chr2 == c1 || lex->chr2 == c2;
8585
}
8686

87-
STATIC bool is_char_and(mp_lexer_t *lex, char c1, char c2) {
87+
STATIC bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) {
8888
return lex->chr0 == c1 && lex->chr1 == c2;
8989
}
9090

py/lexer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ typedef enum _mp_token_kind_t {
141141
// the next-byte function must return the next byte in the stream
142142
// it must return MP_LEXER_EOF if end of stream
143143
// it can be called again after returning MP_LEXER_EOF, and in that case must return MP_LEXER_EOF
144-
#define MP_LEXER_EOF (-1)
144+
#define MP_LEXER_EOF ((unichar)(-1))
145+
145146
typedef mp_uint_t (*mp_lexer_stream_next_byte_t)(void*);
146147
typedef void (*mp_lexer_stream_close_t)(void*);
147148

py/modbuiltins.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#include <math.h>
4242
#endif
4343

44+
#if MICROPY_PY_IO
45+
extern mp_uint_t mp_sys_stdout_obj; // type is irrelevant, just need pointer
46+
#endif
47+
4448
// args[0] is function from class body
4549
// args[1] is class name
4650
// args[2:] are base objects
@@ -403,7 +407,6 @@ STATIC mp_obj_t mp_builtin_print(mp_uint_t n_args, const mp_obj_t *args, mp_map_
403407
end_data = mp_obj_str_get_data(end_elem->value, &end_len);
404408
}
405409
#if MICROPY_PY_IO
406-
extern mp_uint_t mp_sys_stdout_obj; // type is irrelevant, just need pointer
407410
mp_obj_t stream_obj = &mp_sys_stdout_obj;
408411
mp_map_elem_t *file_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_file), MP_MAP_LOOKUP);
409412
if (file_elem != NULL && file_elem->value != mp_const_none) {
@@ -440,7 +443,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print);
440443
STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
441444
if (o != mp_const_none) {
442445
#if MICROPY_PY_IO
443-
extern mp_uint_t mp_sys_stdout_obj; // type is irrelevant, just need pointer
444446
pfenv_t pfenv;
445447
pfenv.data = &mp_sys_stdout_obj;
446448
pfenv.print_strn = (void (*)(void *, const char *, mp_uint_t))mp_stream_write;

py/objarray.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, mp_uint_t nitems, void *items) {
220220
}
221221

222222
STATIC mp_obj_t memoryview_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
223+
(void)type_in;
224+
223225
// TODO possibly allow memoryview constructor to take start/stop so that one
224226
// can do memoryview(b, 4, 8) instead of memoryview(b)[4:8] (uses less RAM)
225227

py/objstrunicode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ STATIC void uni_print_quoted(void (*print)(void *env, const char *fmt, ...), voi
5353
has_double_quote = true;
5454
}
5555
}
56-
int quote_char = '\'';
56+
unichar quote_char = '\'';
5757
if (has_single_quote && !has_double_quote) {
5858
quote_char = '"';
5959
}

0 commit comments

Comments
 (0)