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 <pab@pabigot.com>
This commit is contained in:
Peter A. Bigot 2019-07-16 10:45:48 -05:00 committed by Kumar Gala
parent 879ce9c05a
commit 1090dbc6b4
2 changed files with 5 additions and 5 deletions

View file

@ -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, \
}

View file

@ -12,8 +12,8 @@
#include <logging/log.h>
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 */