all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 8435@debbugs.gnu.org
Subject: bug#8435: misuse of error ("...%d...", ...) on 64-bit hosts
Date: Sat, 09 Apr 2011 11:24:08 -0700	[thread overview]
Message-ID: <4DA0A448.7000203@cs.ucla.edu> (raw)
In-Reply-To: <83d3kvubzp.fsf@gnu.org>

On 04/09/2011 12:20 AM, Eli Zaretskii wrote:
>> Date: Fri, 08 Apr 2011 16:34:12 -0700
>> From: Paul Eggert <eggert@cs.ucla.edu>

> Then let's change doprnt to support an `int'...
> Are there any problems with this approach?

Yes: it'd be more work to do now, and will leave us with
more code to maintain afterwards.

> adding that support in other places has disadvantages that I
> mentioned in my previous message.

The disadvantages are small compared to the advantages.
Most of the changes in the patch are needed regardless
of whether doprnt is kept or discarded.  The part about
discarding doprnt shortens Emacs's code overall: it removes
283 lines (doprnt itself, plus scaffolding) and adds 17 lines
(callers adjusting to the minor differences between doprnt
and vsnprintf).  This is a clear win.

Part of the motivation here is that doprnt contains too many bugs.
I've mentioned two or three, but here's another:

                  while ('0' <= fmt[1] && fmt[1] <= '9')
                    {
                      if (n * 10 + fmt[1] - '0' < n)
                        error ("Format width or precision too large");
                      n = n * 10 + fmt[1] - '0';
                      *string++ = *++fmt;
                    }

That overflow check is clearly wrong: it will miss many
overflows.  This doprnt bug, like the others, could be fixed
by investing more time, but it's wasteful to spend time
maintaining a buggy near-copy of vsnprintf.  It's better
software engineering practice to use vsnprintf instead.





  reply	other threads:[~2011-04-09 18:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-06 19:59 bug#8435: misuse of error ("...%d...", ...) on 64-bit hosts Paul Eggert
     [not found] ` <handler.8435.B.130211997010029.ack@debbugs.gnu.org>
2011-04-07  7:33   ` Paul Eggert
2011-04-07 12:29     ` Andy Moreton
2011-04-07 18:31     ` Eli Zaretskii
2011-04-07 20:43       ` Paul Eggert
2011-04-08  8:58         ` Eli Zaretskii
2011-04-08 23:34           ` Paul Eggert
2011-04-09  7:20             ` Eli Zaretskii
2011-04-09 18:24               ` Paul Eggert [this message]
2011-04-09 18:32                 ` Eli Zaretskii
2011-04-09 19:39                   ` Paul Eggert
2011-04-09 20:21                     ` Eli Zaretskii
2011-04-10  3:52                       ` Stefan Monnier
2011-04-10  5:19                         ` Eli Zaretskii
2011-04-11  1:44                           ` Stefan Monnier
2011-04-11  2:54                             ` Eli Zaretskii
2011-04-10 17:03                       ` Paul Eggert
2011-04-09 19:28                 ` Eli Zaretskii
2011-04-09 19:43                   ` Paul Eggert
2011-04-08 23:37           ` Paul Eggert
2011-04-25  0:59             ` Daniel Colascione
2011-04-25  6:42               ` Eli Zaretskii

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=4DA0A448.7000203@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=8435@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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.