GNU bug report logs -
#19634
counting MANY function args more reliably
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Tue, 20 Jan 2015 09:28:01 UTC
Severity: normal
Tags: patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19634 in the body.
You can then email your comments to 19634 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19634
; Package
emacs
.
(Tue, 20 Jan 2015 09:28:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 20 Jan 2015 09:28:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Commit ef5a526f1b51b76b0f753e0936c80743a7f4463d fixed a bug in Emacs where the C
code passed 10 arguments to a function using the MANY calling convention, but
the caller mistakenly passed 8 as the argument count, and this mistakenly
discarded the last two arguments; see <http://bugs.gnu.org/3228#63>.
To help prevent this sort of mistake in the future, I would like to install
something like the attached patch, which uses a new C macro CALLN to count these
arguments automatically. The key lines in the patch are the following additions
to lisp.h:
#define CALLMANY(f, array) (f) (ARRAYELTS (array), array)
#define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
This lets code use 'return CALLN (foo, a, b, c, d);' instead of the current
error-prone usages which are like '{ Lisp_Object args[4]; args[0] = a; args[1] =
b; args[2] = c; args[3] = d; return foo (3, args); }'. (Oops, that last '3'
should have been a '4'....)
This patch still needs a ChangeLog entry and some more testing on my part, but I
thought I'd get it out for review now.
[calln.diff (text/x-patch, attachment)]
Added tag(s) patch.
Request was from
Paul Eggert <eggert <at> cs.ucla.edu>
to
control <at> debbugs.gnu.org
.
(Tue, 20 Jan 2015 09:30:04 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19634
; Package
emacs
.
(Tue, 20 Jan 2015 16:39:01 GMT)
Full text and
rfc822 format available.
Message #10 received at 19634 <at> debbugs.gnu.org (full text, mbox):
> #define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
I like that,
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19634
; Package
emacs
.
(Thu, 22 Jan 2015 16:32:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 19634 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Tue, 20 Jan 2015 11:37:39 -0500
> Cc: 19634 <at> debbugs.gnu.org
>
> > #define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
>
> I like that,
Do we want to use this for every call to a function that accepts MANY
args, or just those where the argument is an array?
I'm asking because the proposed patch left out this part of w32fns.c:
static Lisp_Object
x_create_tip_frame (struct w32_display_info *dpyinfo,
Lisp_Object parms, Lisp_Object text)
{
[...]
Ferase_buffer ();
Finsert (1, &text); <<<<<<<<<<<<<<<<<<<<<<
and I'm not sure whether this was just an omission or this kind of
calls doesn't need to use CALLN.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19634
; Package
emacs
.
(Thu, 22 Jan 2015 17:43:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 19634 <at> debbugs.gnu.org (full text, mbox):
On 01/22/2015 08:31 AM, Eli Zaretskii wrote:
> Do we want to use this for every call to a function that accepts MANY
> args, or just those where the argument is an array?
We should use it for calls where counting the number of arguments is
likely to be error-prone.
> I'm asking because the proposed patch left out this part of w32fns.c:
>
> static Lisp_Object
> x_create_tip_frame (struct w32_display_info *dpyinfo,
> Lisp_Object parms, Lisp_Object text)
> {
> [...]
> Ferase_buffer ();
> Finsert (1, &text); <<<<<<<<<<<<<<<<<<<<<<
The patch does not affect calls like that, as they're unlikely to give
rise to the sort of typographical error that motivated the patch.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19634
; Package
emacs
.
(Thu, 22 Jan 2015 18:17:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 19634 <at> debbugs.gnu.org (full text, mbox):
> Date: Thu, 22 Jan 2015 09:42:10 -0800
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: 19634 <at> debbugs.gnu.org
>
> On 01/22/2015 08:31 AM, Eli Zaretskii wrote:
> > Do we want to use this for every call to a function that accepts MANY
> > args, or just those where the argument is an array?
>
> We should use it for calls where counting the number of arguments is
> likely to be error-prone.
>
> > I'm asking because the proposed patch left out this part of w32fns.c:
> >
> > static Lisp_Object
> > x_create_tip_frame (struct w32_display_info *dpyinfo,
> > Lisp_Object parms, Lisp_Object text)
> > {
> > [...]
> > Ferase_buffer ();
> > Finsert (1, &text); <<<<<<<<<<<<<<<<<<<<<<
>
> The patch does not affect calls like that, as they're unlikely to give
> rise to the sort of typographical error that motivated the patch.
OK, thanks.
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Sun, 25 Jan 2015 17:17:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
bug acknowledged by developer.
(Sun, 25 Jan 2015 17:17:02 GMT)
Full text and
rfc822 format available.
Message #24 received at 19634-done <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier wrote:
> I like that,
Thanks, I tested the patch on a few more platforms, rebased it to the current
master, added some commentary in response to the remarks in this bug report, and
installed the patch into the master as commit
a3689d3c661fe36df971c875760f8d500b5ae994.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 23 Feb 2015 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 121 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.