From 841b11ed0d534d707f54160f8c7efe3b883eb3ed Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 4 Apr 2021 11:25:49 +0100 Subject: [PATCH] Fix warnings in image.c * src/image.c (svg_load_image): Fix types and move declaration of 'css' to the top of the function. --- src/image.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/image.c b/src/image.c index 13bd503e535..08e937e501f 100644 --- a/src/image.c +++ b/src/image.c @@ -9917,6 +9917,10 @@ svg_load_image (struct frame *f, struct image *img, char *contents, char *wrapped_contents = NULL; ptrdiff_t wrapped_size; +#if LIBRSVG_CHECK_VERSION (2, 48, 0) + char *css = NULL; +#endif + #if ! GLIB_CHECK_VERSION (2, 36, 0) /* g_type_init is a glib function that must be called prior to using gnome type library functions (obsolete since 2.36.0). */ @@ -9944,16 +9948,15 @@ svg_load_image (struct frame *f, struct image *img, char *contents, FRAME_DISPLAY_INFO (f)->resy); #if LIBRSVG_CHECK_VERSION (2, 48, 0) - char *css; Lisp_Object lcss = image_spec_value (img->spec, QCcss, NULL); if (!STRINGP (lcss)) { /* Generate the CSS for the SVG image. */ - char *css_spec = "svg{font-family:\"%s\";font-size:%4dpx}"; + const char *css_spec = "svg{font-family:\"%s\";font-size:%4dpx}"; int css_len = strlen (css_spec) + strlen (img->face_font_family); css = xmalloc (css_len); snprintf (css, css_len, css_spec, img->face_font_family, img->face_font_size); - rsvg_handle_set_stylesheet (rsvg_handle, css, strlen (css), NULL); + rsvg_handle_set_stylesheet (rsvg_handle, (guint8 *)css, strlen (css), NULL); } else { @@ -10141,7 +10144,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, FRAME_DISPLAY_INFO (f)->resy); #if LIBRSVG_CHECK_VERSION (2, 48, 0) - rsvg_handle_set_stylesheet (rsvg_handle, css, strlen (css), NULL); + rsvg_handle_set_stylesheet (rsvg_handle, (guint8 *)css, strlen (css), NULL); #endif #else /* Make a handle to a new rsvg object. */ -- 2.39.5