Skip to content

Commit de541cf

Browse files
committed
Fix pointer-ness, const-ness of compressed messages
micropython puts the pointer-ness into the typedef; we can put the const-ness there too. this reduces the delta to micropython; for instance, emitinlinextensa and emitinlinethumb now match upstream.
1 parent 54a5878 commit de541cf

File tree

30 files changed

+104
-101
lines changed

30 files changed

+104
-101
lines changed

devices/ble_hci/common-hal/_bleio/att.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ void att_process_data(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) {
17221722

17231723
// FIX Do we need all of these?
17241724
static void check_att_err(uint8_t err) {
1725-
const mp_rom_error_text_t *msg = NULL;
1725+
mp_rom_error_text_t msg = NULL;
17261726
switch (err) {
17271727
case 0:
17281728
return;

ports/espressif/common-hal/espidf/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ intptr_t common_hal_espidf_get_psram_end(void) {
122122
}
123123

124124
void raise_esp_error(esp_err_t err) {
125-
const mp_rom_error_text_t *msg = NULL;
125+
mp_rom_error_text_t msg = NULL;
126126
const mp_obj_type_t *exception_type = &mp_type_espidf_IDFError;
127127
switch (err) {
128128
case ESP_FAIL:

ports/espressif/common-hal/wifi/Monitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void wifi_monitor_cb(void *recv_buf, wifi_promiscuous_pkt_type_t type) {
7878
}
7979

8080
void common_hal_wifi_monitor_construct(wifi_monitor_obj_t *self, uint8_t channel, size_t queue) {
81-
const mp_rom_error_text_t *monitor_mode_init_error = translate("monitor init failed");
81+
mp_rom_error_text_t monitor_mode_init_error = translate("monitor init failed");
8282

8383
self->queue = xQueueCreate(queue, sizeof(monitor_packet_t));
8484
if (!self->queue) {

py/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
255255
}
256256
}
257257

258-
STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, const mp_rom_error_text_t *msg) {
258+
STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, mp_rom_error_text_t msg) {
259259
// only register the error if there has been no other error
260260
if (comp->compile_error == MP_OBJ_NULL) {
261261
comp->compile_error = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);

py/emitinlinethumb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ static inline bool emit_inline_thumb_allow_float(emit_inline_asm_t *emit) {
7474

7575
#endif
7676

77-
// CIRCUITPY-CHANGE
78-
STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, const mp_rom_error_text_t *msg) {
77+
STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
7978
*emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
8079
}
8180

py/emitinlinextensa.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ struct _emit_inline_asm_t {
4343
qstr *label_lookup;
4444
};
4545

46-
// CIRCUITPY-CHANGE
47-
STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, const mp_rom_error_text_t *msg) {
46+
STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, mp_rom_error_text_t msg) {
4847
*emit->error_slot = mp_obj_new_exception_msg(&mp_type_SyntaxError, msg);
4948
}
5049

py/maketranslationdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def output_translation_data(encoding_table, i18ns, out):
595595
decompressed = decompressed.replace(c, C_ESCAPES[c])
596596
formatted = ["{:d}".format(x) for x in compressed]
597597
out.write(
598-
"const mp_rom_error_text_t translation{} = {{ .data = {}, .tail = {{ {} }} }}; // {}\n".format(
598+
"const struct compressed_string translation{} = {{ .data = {}, .tail = {{ {} }} }}; // {}\n".format(
599599
i, formatted[0], ", ".join(formatted[1:]), original, decompressed
600600
)
601601
)

py/moderrno.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const char *mp_common_errno_to_str(mp_obj_t errno_val, char *buf, size_t len) {
127127
return NULL;
128128
}
129129

130-
const mp_rom_error_text_t *desc = NULL;
130+
mp_rom_error_text_t desc = NULL;
131131
switch (MP_OBJ_SMALL_INT_VALUE(errno_val)) {
132132
case EPERM:
133133
desc = MP_ERROR_TEXT("Operation not permitted");

py/mpprint.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
496496
break;
497497
}
498498
case 'S': {
499-
mp_rom_error_text_t *arg = va_arg(args, mp_rom_error_text_t *);
499+
mp_rom_error_text_t arg = va_arg(args, mp_rom_error_text_t );
500500
size_t len_with_nul = decompress_length(arg);
501501
size_t len = len_with_nul - 1;
502502
char str[len_with_nul];
@@ -593,15 +593,15 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
593593
return chrs;
594594
}
595595

596-
int mp_cprintf(const mp_print_t *print, const mp_rom_error_text_t *compressed_fmt, ...) {
596+
int mp_cprintf(const mp_print_t *print, mp_rom_error_text_t compressed_fmt, ...) {
597597
va_list ap;
598598
va_start(ap, compressed_fmt);
599599
int ret = mp_vcprintf(print, compressed_fmt, ap);
600600
va_end(ap);
601601
return ret;
602602
}
603603

604-
int mp_vcprintf(const mp_print_t *print, const mp_rom_error_text_t *compressed_fmt, va_list args) {
604+
int mp_vcprintf(const mp_print_t *print, mp_rom_error_text_t compressed_fmt, va_list args) {
605605
char fmt[decompress_length(compressed_fmt)];
606606
// TODO: Optimise this to format-while-decompressing (and not require the temp stack space).
607607
decompress(compressed_fmt, fmt);

py/mpprint.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#define MICROPY_INCLUDED_PY_MPPRINT_H
2828

2929
#include "py/mpconfig.h"
30-
#include "py/misc.h"
3130

3231
#define PF_FLAG_LEFT_ADJUST (0x001)
3332
#define PF_FLAG_SHOW_SIGN (0x002)

0 commit comments

Comments
 (0)