all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Welsh Duggan <mwd@md5i.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Michael Welsh Duggan <mwd@md5i.com>,
	luangruo@yahoo.com, emacs-devel@gnu.org
Subject: Re: Warning in svg_load_image
Date: Wed, 23 Feb 2022 16:58:59 -0500	[thread overview]
Message-ID: <8735k9meho.fsf@md5i.com> (raw)
In-Reply-To: <83r17tscvf.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 23 Feb 2022 19:37:24 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Michael Welsh Duggan <mwd@md5i.com>
>> Cc: Po Lu <luangruo@yahoo.com>,  emacs-devel@gnu.org
>> Date: Wed, 23 Feb 2022 12:11:24 -0500
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> >        "xmlns:xi=\"http://www.w3.org/2001/XInclude\" "
>> >        "style=\"color: #%06X; fill: currentColor;\" "
>> >        "width=\"%d\" height=\"%d\" preserveAspectRatio=\"none\" "
>> > -      "viewBox=\"0 0 %f %f\">"
>> > +      "viewBox=\"0 0 %5.0f %5.0f\">"
>> >        "<rect width=\"100%%\" height=\"100%%\" fill=\"#%06X\"/>"
>> >        "<xi:include href=\"data:image/svg+xml;base64,%s\"></xi:include>"
>> >        "</svg>";
>> > @@ -10801,7 +10801,9 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
>> >  
>> >      if (buffer_size <= snprintf (wrapped_contents, buffer_size, wrapper,
>> >  				 foreground & 0xFFFFFF, width, height,
>> > -				 viewbox_width, viewbox_height,
>> > +				 /* Sanitize the viewBox dimensions.  */
>> > +				 min (viewbox_width, 10000.),
>> > +				 min (viewbox_height, 10000.),
>> >  				 background & 0xFFFFFF,
>> >  				 SSDATA (encoded_contents)))
>> >        goto rsvg_error;
>> >
>> 
>> So, a couple of questions and comments...  
>> 
>> As mentioned in other messages, % sizes affect only the minimum sizes of
>> results, so changing those values shouldn't help.  (It's possible that
>> using * might, but only as a possible subversion of the heuristics that
>> this warning uses.)
>
> If the compiler doesn't understand that the value is being limited to
> a maximum of 5 digits, then it shouldn't attempt to emit such
> "helpful" warnings.

Is it being limited?  What is limiting it?  "%5.0f" will not limit it's
size; it will only limit its minimum size, unless I am misunderstanding
the printf specs.

>> The principled way to solve this would be to call the snprintf twice,
>> the first time with a zero-sized buffer, and then to use the return
>> value to allocate the actual buffer.  This is a pessimisation, but I
>> don't know if it's a bad one (it depends on how frequently this code
>> would be called.
>
> This is madness.  I'd rather we used a pragma to disable that
> particular warning around this part of the code than jump through
> hoops because the compiler is too stupid to understand the code it
> warns about.

Another possible option: you may be able to work around this by
declaring buffer_size to be volatile.

-- 
Michael Welsh Duggan
(md5i@md5i.com)



  reply	other threads:[~2022-02-23 21:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87ilt8hcz4.fsf.ref@yahoo.com>
2022-02-21  7:53 ` Warning in svg_load_image Po Lu
2022-02-21 13:26   ` Eli Zaretskii
2022-02-21 13:37     ` Po Lu
2022-02-21 13:51       ` Eli Zaretskii
2022-02-22  3:53         ` Po Lu
2022-02-22 12:32           ` Eli Zaretskii
2022-02-22 12:45             ` Andreas Schwab
2022-02-22 13:02             ` Po Lu
2022-02-23 17:11         ` Michael Welsh Duggan
2022-02-23 17:37           ` Eli Zaretskii
2022-02-23 21:58             ` Michael Welsh Duggan [this message]
2022-02-24  6:47               ` Eli Zaretskii
2022-02-23 22:55             ` Andreas Schwab
2022-02-24  6:53               ` Eli Zaretskii
     [not found]         ` <87pmndmrsz.fsf@md5i.com>
2022-02-24  0:50           ` Po Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735k9meho.fsf@md5i.com \
    --to=mwd@md5i.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.