cairo: fix gnu_printf format warning

This commit is contained in:
Jari Vetoniemi 2021-05-07 23:50:45 +09:00
parent dd276c0a15
commit 4b7b483bd6

View File

@ -120,20 +120,9 @@ bm_pango_get_text_extents(struct cairo *cairo, struct cairo_paint *paint, struct
return true; return true;
} }
BM_LOG_ATTR(4, 5) static inline bool static inline bool
bm_cairo_draw_line(struct cairo *cairo, struct cairo_paint *paint, struct cairo_result *result, const char *fmt, ...) bm_cairo_draw_line_str(struct cairo *cairo, struct cairo_paint *paint, struct cairo_result *result, const char *buffer)
{ {
assert(cairo && paint && result && fmt);
memset(result, 0, sizeof(struct cairo_result));
va_list args;
va_start(args, fmt);
bool ret = bm_vrprintf(&buffer, &blen, fmt, args);
va_end(args);
if (!ret)
return false;
PangoLayout *layout = bm_pango_get_layout(cairo, paint, buffer); PangoLayout *layout = bm_pango_get_layout(cairo, paint, buffer);
pango_cairo_update_layout(cairo->cr, layout); pango_cairo_update_layout(cairo->cr, layout);
@ -189,6 +178,23 @@ bm_cairo_draw_line(struct cairo *cairo, struct cairo_paint *paint, struct cairo_
return true; return true;
} }
BM_LOG_ATTR(4, 5) static inline bool
bm_cairo_draw_line(struct cairo *cairo, struct cairo_paint *paint, struct cairo_result *result, const char *fmt, ...)
{
assert(cairo && paint && result && fmt);
memset(result, 0, sizeof(struct cairo_result));
va_list args;
va_start(args, fmt);
bool ret = bm_vrprintf(&buffer, &blen, fmt, args);
va_end(args);
if (!ret)
return false;
return bm_cairo_draw_line_str(cairo, paint, result, buffer);
}
static inline void static inline void
bm_cairo_color_from_menu_color(const struct bm_menu *menu, enum bm_color color, struct cairo_color *c) bm_cairo_color_from_menu_color(const struct bm_menu *menu, enum bm_color color, struct cairo_color *c)
{ {
@ -250,7 +256,7 @@ bm_cairo_paint(struct cairo *cairo, uint32_t width, uint32_t max_height, const s
const char *filter_text = (menu->filter ? menu->filter : ""); const char *filter_text = (menu->filter ? menu->filter : "");
if (menu->password) { if (menu->password) {
bm_cairo_draw_line(cairo, &paint, &result, ""); bm_cairo_draw_line_str(cairo, &paint, &result, "");
} else { } else {
bm_cairo_draw_line(cairo, &paint, &result, "%s", filter_text); bm_cairo_draw_line(cairo, &paint, &result, "%s", filter_text);
} }