From 00060d99f300575dab95b255e31f75787f34078e Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 30 Dec 2022 22:55:56 +0200 Subject: [PATCH] [hb-cairo] Silence warning when building with FreeType In file included from ../util/hb-view.cc:33: In file included from ../util/view-cairo.hh:32: ../util/helper-cairo.hh:102:7: warning: variable 'cairo_face' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (use_hb_draw) ^~~~~~~~~~~ ../util/helper-cairo.hh:129:64: note: uninitialized use occurs here cairo_scaled_font_t *scaled_font = cairo_scaled_font_create (cairo_face, ^~~~~~~~~~ ../util/helper-cairo.hh:102:3: note: remove the 'if' if its condition is always true if (use_hb_draw) ^~~~~~~~~~~~~~~~ ../util/helper-cairo.hh:101:32: note: initialize the variable 'cairo_face' to silence this warning cairo_font_face_t *cairo_face; ^ = nullptr We know that cairo_face will always be assigned since use_hb_draw will always be true, but the compiler does not know that. --- util/helper-cairo.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh index 3505794eb..c0ce5955f 100644 --- a/util/helper-cairo.hh +++ b/util/helper-cairo.hh @@ -98,7 +98,7 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts) #endif - cairo_font_face_t *cairo_face; + cairo_font_face_t *cairo_face = nullptr; if (use_hb_draw) { cairo_face = hb_cairo_font_face_create_for_font (font);