From 1090dbc6b4c751f92697ba44957021edf7fa3987 Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Tue, 16 Jul 2019 10:45:48 -0500 Subject: [PATCH] subsys/cfb: improve font structure packing The specified order of fields wastes space when the cfb_font_caps enum isn't packed. Reorder to avoid this behavior. Also remove the unnecessary array size on the extern symbol declaration, lest the compiler misinterpret the properties as being zero-length arrays rather than pointers. (The idiom is already technically using undefined behavior since we're relying on the linker rather than the language to produce an array from the individual declarations.) Signed-off-by: Peter A. Bigot --- include/display/cfb.h | 6 +++--- subsys/fb/cfb.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/display/cfb.h b/include/display/cfb.h index 69eb82827c6..e8c4772a281 100644 --- a/include/display/cfb.h +++ b/include/display/cfb.h @@ -48,9 +48,9 @@ enum cfb_font_caps { struct cfb_font { const void *data; + enum cfb_font_caps caps; u8_t width; u8_t height; - enum cfb_font_caps caps; u8_t first_char; u8_t last_char; }; @@ -69,10 +69,10 @@ struct cfb_font { #define FONT_ENTRY_DEFINE(_name, _width, _height, _caps, _data, _fc, _lc) \ static const Z_STRUCT_SECTION_ITERABLE(cfb_font, _name) = \ { \ + .data = _data, \ + .caps = _caps, \ .width = _width, \ .height = _height, \ - .caps = _caps, \ - .data = _data, \ .first_char = _fc, \ .last_char = _lc, \ } diff --git a/subsys/fb/cfb.c b/subsys/fb/cfb.c index 4ad0b10a992..50b9cfa9360 100644 --- a/subsys/fb/cfb.c +++ b/subsys/fb/cfb.c @@ -12,8 +12,8 @@ #include LOG_MODULE_REGISTER(cfb); -extern const struct cfb_font __font_entry_start[0]; -extern const struct cfb_font __font_entry_end[0]; +extern const struct cfb_font __font_entry_start[]; +extern const struct cfb_font __font_entry_end[]; struct char_framebuffer { /** Pointer to a buffer in RAM */