Skip to content

Commit 7d5aba0

Browse files
committed
extmod/moductypes: Refactor string literal as array initializer.
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1. Also split out the duplicate string to a top-level array (probably the duplicate string literal was interned, so unlikely to have any impact.) This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
1 parent 3fa77bd commit 7d5aba0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

extmod/moductypes.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,18 @@ static mp_obj_t uctypes_struct_sizeof(size_t n_args, const mp_obj_t *args) {
277277
}
278278
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(uctypes_struct_sizeof_obj, 1, 2, uctypes_struct_sizeof);
279279

280+
static const char type2char[16] = {
281+
'B', 'b', 'H', 'h', 'I', 'i', 'Q', 'q',
282+
'-', '-', '-', '-', '-', '-', 'f', 'd'
283+
};
284+
280285
static inline mp_obj_t get_unaligned(uint val_type, byte *p, int big_endian) {
281286
char struct_type = big_endian ? '>' : '<';
282-
static const char type2char[16] = "BbHhIiQq------fd";
283287
return mp_binary_get_val(struct_type, type2char[val_type], p, &p);
284288
}
285289

286290
static inline void set_unaligned(uint val_type, byte *p, int big_endian, mp_obj_t val) {
287291
char struct_type = big_endian ? '>' : '<';
288-
static const char type2char[16] = "BbHhIiQq------fd";
289292
mp_binary_set_val(struct_type, type2char[val_type], val, p, &p);
290293
}
291294

0 commit comments

Comments
 (0)