diff options
| author | Paul Eggert | 2011-06-14 11:57:19 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-14 11:57:19 -0700 |
| commit | f66c7cf8f794d6f7fd9ccb8794ffc519e4e89795 (patch) | |
| tree | 0de26b21c827049c7fa2485204ecf0e2d632b849 /src/callproc.c | |
| parent | a1759b76246a21c7c07dc2ee00b8db792715104c (diff) | |
| download | emacs-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/callproc.c')
| -rw-r--r-- | src/callproc.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/callproc.c b/src/callproc.c index 7bb2ac05933..d6bad2a44e7 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -184,7 +184,7 @@ and returns a numeric exit status or a signal description string. | |||
| 184 | If you quit, the process is killed with SIGINT, or SIGKILL if you quit again. | 184 | If you quit, the process is killed with SIGINT, or SIGKILL if you quit again. |
| 185 | 185 | ||
| 186 | usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | 186 | usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) |
| 187 | (size_t nargs, register Lisp_Object *args) | 187 | (ptrdiff_t nargs, Lisp_Object *args) |
| 188 | { | 188 | { |
| 189 | Lisp_Object infile, buffer, current_dir, path; | 189 | Lisp_Object infile, buffer, current_dir, path; |
| 190 | volatile int display_p_volatile; | 190 | volatile int display_p_volatile; |
| @@ -231,7 +231,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 231 | /* Decide the coding-system for giving arguments. */ | 231 | /* Decide the coding-system for giving arguments. */ |
| 232 | { | 232 | { |
| 233 | Lisp_Object val, *args2; | 233 | Lisp_Object val, *args2; |
| 234 | size_t i; | 234 | ptrdiff_t i; |
| 235 | 235 | ||
| 236 | /* If arguments are supplied, we may have to encode them. */ | 236 | /* If arguments are supplied, we may have to encode them. */ |
| 237 | if (nargs >= 5) | 237 | if (nargs >= 5) |
| @@ -422,7 +422,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 422 | (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); | 422 | (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); |
| 423 | if (nargs > 4) | 423 | if (nargs > 4) |
| 424 | { | 424 | { |
| 425 | register size_t i; | 425 | ptrdiff_t i; |
| 426 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 426 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 427 | 427 | ||
| 428 | GCPRO5 (infile, buffer, current_dir, path, error_file); | 428 | GCPRO5 (infile, buffer, current_dir, path, error_file); |
| @@ -716,7 +716,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 716 | { | 716 | { |
| 717 | if (EQ (coding_systems, Qt)) | 717 | if (EQ (coding_systems, Qt)) |
| 718 | { | 718 | { |
| 719 | size_t i; | 719 | ptrdiff_t i; |
| 720 | 720 | ||
| 721 | SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); | 721 | SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); |
| 722 | args2[0] = Qcall_process; | 722 | args2[0] = Qcall_process; |
| @@ -944,7 +944,7 @@ and returns a numeric exit status or a signal description string. | |||
| 944 | If you quit, the process is killed with SIGINT, or SIGKILL if you quit again. | 944 | If you quit, the process is killed with SIGINT, or SIGKILL if you quit again. |
| 945 | 945 | ||
| 946 | usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &rest ARGS) */) | 946 | usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &rest ARGS) */) |
| 947 | (size_t nargs, register Lisp_Object *args) | 947 | (ptrdiff_t nargs, Lisp_Object *args) |
| 948 | { | 948 | { |
| 949 | struct gcpro gcpro1; | 949 | struct gcpro gcpro1; |
| 950 | Lisp_Object filename_string; | 950 | Lisp_Object filename_string; |
| @@ -953,7 +953,7 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r | |||
| 953 | /* Qt denotes we have not yet called Ffind_operation_coding_system. */ | 953 | /* Qt denotes we have not yet called Ffind_operation_coding_system. */ |
| 954 | Lisp_Object coding_systems; | 954 | Lisp_Object coding_systems; |
| 955 | Lisp_Object val, *args2; | 955 | Lisp_Object val, *args2; |
| 956 | size_t i; | 956 | ptrdiff_t i; |
| 957 | char *tempfile; | 957 | char *tempfile; |
| 958 | Lisp_Object tmpdir, pattern; | 958 | Lisp_Object tmpdir, pattern; |
| 959 | 959 | ||