diff options
author | Angus Gratton <angus@redyak.com.au> | 2025-05-09 13:34:37 +1000 |
---|---|---|
committer | Angus Gratton <gus@projectgus.com> | 2025-05-09 18:31:40 +1000 |
commit | 7d5aba0523cac0a23dc63a5bb4b64a8eab845836 (patch) | |
tree | 00834ae214e56e7554228d4782ad85a8c3f47186 | |
parent | 3fa77bdc7d413a410fb85a8943d417bca3b562e7 (diff) |
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 <angus@redyak.com.au>
-rw-r--r-- | extmod/moductypes.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/extmod/moductypes.c b/extmod/moductypes.c index bf4579765..54abce79e 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -277,15 +277,18 @@ static mp_obj_t uctypes_struct_sizeof(size_t n_args, const mp_obj_t *args) { } static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(uctypes_struct_sizeof_obj, 1, 2, uctypes_struct_sizeof); +static const char type2char[16] = { + 'B', 'b', 'H', 'h', 'I', 'i', 'Q', 'q', + '-', '-', '-', '-', '-', '-', 'f', 'd' +}; + static inline mp_obj_t get_unaligned(uint val_type, byte *p, int big_endian) { char struct_type = big_endian ? '>' : '<'; - static const char type2char[16] = "BbHhIiQq------fd"; return mp_binary_get_val(struct_type, type2char[val_type], p, &p); } static inline void set_unaligned(uint val_type, byte *p, int big_endian, mp_obj_t val) { char struct_type = big_endian ? '>' : '<'; - static const char type2char[16] = "BbHhIiQq------fd"; mp_binary_set_val(struct_type, type2char[val_type], val, p, &p); } |