Skip to content
Permalink
Browse files

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>
  • Loading branch information...
pabigot authored and galak committed Jul 16, 2019
1 parent 879ce9c commit 1090dbc6b4c751f92697ba44957021edf7fa3987
Showing with 5 additions and 5 deletions.
  1. +3 −3 include/display/cfb.h
  2. +2 −2 subsys/fb/cfb.c
@@ -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, \
}
@@ -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 */

0 comments on commit 1090dbc

Please sign in to comment.
You can’t perform that action at this time.