aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2011-06-14 11:57:19 -0700
committerPaul Eggert2011-06-14 11:57:19 -0700
commitf66c7cf8f794d6f7fd9ccb8794ffc519e4e89795 (patch)
tree0de26b21c827049c7fa2485204ecf0e2d632b849 /src/alloc.c
parenta1759b76246a21c7c07dc2ee00b8db792715104c (diff)
downloademacs-f66c7cf8f794d6f7fd9ccb8794ffc519e4e89795.tar.gz
emacs-f66c7cf8f794d6f7fd9ccb8794ffc519e4e89795.zip
Variadic C functions now count arguments with ptrdiff_t.
This partly undoes my 2011-03-30 change, which replaced int with size_t. Back then I didn't know that the Emacs coding style prefers signed int. Also, in the meantime I found a few more instances where arguments were being counted with int, which may truncate counts on 64-bit machines, or EMACS_INT, which may be unnecessarily wide. * lisp.h (struct Lisp_Subr.function.aMANY) (DEFUN_ARGS_MANY, internal_condition_case_n, safe_call): Arg counts are now ptrdiff_t, not size_t. All variadic functions and their callers changed accordingly. (struct gcpro.nvars): Now size_t, not size_t. All uses changed. * bytecode.c (exec_byte_code): Check maxdepth for overflow, to avoid potential buffer overrun. Don't assume arg counts fit in 'int'. * callint.c (Fcall_interactively): Check arg count for overflow, to avoid potential buffer overrun. Use signed char, not 'int', for 'varies' array, so that we needn't bother to check its size calculation for overflow. * editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args. * eval.c (apply_lambda): * fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length. (struct textprop_rec.argnum): Now ptrdiff_t, not int. All uses changed. (mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/alloc.c b/src/alloc.c
index fd2884af1c3..56e8eb4d465 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2697,7 +2697,7 @@ DEFUN ("list", Flist, Slist, 0, MANY, 0,
2697 doc: /* Return a newly created list with specified arguments as elements. 2697 doc: /* Return a newly created list with specified arguments as elements.
2698Any number of arguments, even zero arguments, are allowed. 2698Any number of arguments, even zero arguments, are allowed.
2699usage: (list &rest OBJECTS) */) 2699usage: (list &rest OBJECTS) */)
2700 (size_t nargs, register Lisp_Object *args) 2700 (ptrdiff_t nargs, Lisp_Object *args)
2701{ 2701{
2702 register Lisp_Object val; 2702 register Lisp_Object val;
2703 val = Qnil; 2703 val = Qnil;
@@ -2913,10 +2913,10 @@ DEFUN ("vector", Fvector, Svector, 0, MANY, 0,
2913 doc: /* Return a newly created vector with specified arguments as elements. 2913 doc: /* Return a newly created vector with specified arguments as elements.
2914Any number of arguments, even zero arguments, are allowed. 2914Any number of arguments, even zero arguments, are allowed.
2915usage: (vector &rest OBJECTS) */) 2915usage: (vector &rest OBJECTS) */)
2916 (register size_t nargs, Lisp_Object *args) 2916 (ptrdiff_t nargs, Lisp_Object *args)
2917{ 2917{
2918 register Lisp_Object len, val; 2918 register Lisp_Object len, val;
2919 register size_t i; 2919 ptrdiff_t i;
2920 register struct Lisp_Vector *p; 2920 register struct Lisp_Vector *p;
2921 2921
2922 XSETFASTINT (len, nargs); 2922 XSETFASTINT (len, nargs);
@@ -2944,15 +2944,15 @@ argument to catch the left-over arguments. If such an integer is used, the
2944arguments will not be dynamically bound but will be instead pushed on the 2944arguments will not be dynamically bound but will be instead pushed on the
2945stack before executing the byte-code. 2945stack before executing the byte-code.
2946usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) 2946usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */)
2947 (register size_t nargs, Lisp_Object *args) 2947 (ptrdiff_t nargs, Lisp_Object *args)
2948{ 2948{
2949 register Lisp_Object len, val; 2949 register Lisp_Object len, val;
2950 register size_t i; 2950 ptrdiff_t i;
2951 register struct Lisp_Vector *p; 2951 register struct Lisp_Vector *p;
2952 2952
2953 XSETFASTINT (len, nargs); 2953 XSETFASTINT (len, nargs);
2954 if (!NILP (Vpurify_flag)) 2954 if (!NILP (Vpurify_flag))
2955 val = make_pure_vector ((EMACS_INT) nargs); 2955 val = make_pure_vector (nargs);
2956 else 2956 else
2957 val = Fmake_vector (len, Qnil); 2957 val = Fmake_vector (len, Qnil);
2958 2958
@@ -4238,7 +4238,7 @@ static void
4238check_gcpros (void) 4238check_gcpros (void)
4239{ 4239{
4240 struct gcpro *p; 4240 struct gcpro *p;
4241 size_t i; 4241 ptrdiff_t i;
4242 4242
4243 for (p = gcprolist; p; p = p->next) 4243 for (p = gcprolist; p; p = p->next)
4244 for (i = 0; i < p->nvars; ++i) 4244 for (i = 0; i < p->nvars; ++i)
@@ -4848,7 +4848,7 @@ returns nil, because real GC can't be done. */)
4848{ 4848{
4849 register struct specbinding *bind; 4849 register struct specbinding *bind;
4850 char stack_top_variable; 4850 char stack_top_variable;
4851 register size_t i; 4851 ptrdiff_t i;
4852 int message_p; 4852 int message_p;
4853 Lisp_Object total[8]; 4853 Lisp_Object total[8];
4854 int count = SPECPDL_INDEX (); 4854 int count = SPECPDL_INDEX ();