aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2023-02-28 16:13:59 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2023-04-14 18:34:54 +0200
commitbd58df61efbb86cd43682acfd7cde8085b503590 (patch)
treee03108b4a06bc940d0a1f03a9b6696b2ca93e420
parentAdd format_str() and vformat_str() (diff)
downloadsway-bd58df61efbb86cd43682acfd7cde8085b503590.tar.gz
sway-bd58df61efbb86cd43682acfd7cde8085b503590.tar.zst
sway-bd58df61efbb86cd43682acfd7cde8085b503590.zip
pango: add printf attribute
This allows the compiler to catch mismatches between the format string and the arguments passed in. Need to add -Wno-format-zero-length because we pass an empty string on purpose in swaybar/render.c.
-rw-r--r--include/pango.h5
-rw-r--r--meson.build1
2 files changed, 4 insertions, 2 deletions
diff --git a/include/pango.h b/include/pango.h
index 1db113c2..228e39cf 100644
--- a/include/pango.h
+++ b/include/pango.h
@@ -5,6 +5,7 @@
5#include <stdint.h> 5#include <stdint.h>
6#include <cairo.h> 6#include <cairo.h>
7#include <pango/pangocairo.h> 7#include <pango/pangocairo.h>
8#include "stringop.h"
8 9
9/** 10/**
10 * Utility function which escape characters a & < > ' ". 11 * Utility function which escape characters a & < > ' ".
@@ -16,9 +17,9 @@ size_t escape_markup_text(const char *src, char *dest);
16PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc, 17PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc,
17 const char *text, double scale, bool markup); 18 const char *text, double scale, bool markup);
18void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height, 19void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height,
19 int *baseline, double scale, bool markup, const char *fmt, ...); 20 int *baseline, double scale, bool markup, const char *fmt, ...) _SWAY_ATTRIB_PRINTF(8, 9);
20void get_text_metrics(const PangoFontDescription *desc, int *height, int *baseline); 21void get_text_metrics(const PangoFontDescription *desc, int *height, int *baseline);
21void render_text(cairo_t *cairo, PangoFontDescription *desc, 22void render_text(cairo_t *cairo, PangoFontDescription *desc,
22 double scale, bool markup, const char *fmt, ...); 23 double scale, bool markup, const char *fmt, ...) _SWAY_ATTRIB_PRINTF(5, 6);
23 24
24#endif 25#endif
diff --git a/meson.build b/meson.build
index d1fbfa38..559ee962 100644
--- a/meson.build
+++ b/meson.build
@@ -18,6 +18,7 @@ add_project_arguments(
18 '-Wno-unused-parameter', 18 '-Wno-unused-parameter',
19 '-Wno-unused-result', 19 '-Wno-unused-result',
20 '-Wno-missing-braces', 20 '-Wno-missing-braces',
21 '-Wno-format-zero-length',
21 '-Wundef', 22 '-Wundef',
22 '-Wvla', 23 '-Wvla',
23 ], 24 ],