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/lisp.h | |
| 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/lisp.h')
| -rw-r--r-- | src/lisp.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lisp.h b/src/lisp.h index 3f6a84f8fa3..83534e55433 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1039,7 +1039,7 @@ struct Lisp_Subr | |||
| 1039 | Lisp_Object (*a7) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); | 1039 | Lisp_Object (*a7) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); |
| 1040 | Lisp_Object (*a8) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); | 1040 | Lisp_Object (*a8) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); |
| 1041 | Lisp_Object (*aUNEVALLED) (Lisp_Object args); | 1041 | Lisp_Object (*aUNEVALLED) (Lisp_Object args); |
| 1042 | Lisp_Object (*aMANY) (size_t, Lisp_Object *); | 1042 | Lisp_Object (*aMANY) (ptrdiff_t, Lisp_Object *); |
| 1043 | } function; | 1043 | } function; |
| 1044 | short min_args, max_args; | 1044 | short min_args, max_args; |
| 1045 | const char *symbol_name; | 1045 | const char *symbol_name; |
| @@ -1896,7 +1896,7 @@ typedef struct { | |||
| 1896 | 1896 | ||
| 1897 | /* Note that the weird token-substitution semantics of ANSI C makes | 1897 | /* Note that the weird token-substitution semantics of ANSI C makes |
| 1898 | this work for MANY and UNEVALLED. */ | 1898 | this work for MANY and UNEVALLED. */ |
| 1899 | #define DEFUN_ARGS_MANY (size_t, Lisp_Object *) | 1899 | #define DEFUN_ARGS_MANY (ptrdiff_t, Lisp_Object *) |
| 1900 | #define DEFUN_ARGS_UNEVALLED (Lisp_Object) | 1900 | #define DEFUN_ARGS_UNEVALLED (Lisp_Object) |
| 1901 | #define DEFUN_ARGS_0 (void) | 1901 | #define DEFUN_ARGS_0 (void) |
| 1902 | #define DEFUN_ARGS_1 (Lisp_Object) | 1902 | #define DEFUN_ARGS_1 (Lisp_Object) |
| @@ -2161,7 +2161,7 @@ struct gcpro | |||
| 2161 | volatile Lisp_Object *var; | 2161 | volatile Lisp_Object *var; |
| 2162 | 2162 | ||
| 2163 | /* Number of consecutive protected variables. */ | 2163 | /* Number of consecutive protected variables. */ |
| 2164 | size_t nvars; | 2164 | ptrdiff_t nvars; |
| 2165 | 2165 | ||
| 2166 | #ifdef DEBUG_GCPRO | 2166 | #ifdef DEBUG_GCPRO |
| 2167 | int level; | 2167 | int level; |
| @@ -2922,9 +2922,9 @@ EXFUN (Frun_hooks, MANY); | |||
| 2922 | EXFUN (Frun_hook_with_args, MANY); | 2922 | EXFUN (Frun_hook_with_args, MANY); |
| 2923 | EXFUN (Frun_hook_with_args_until_failure, MANY); | 2923 | EXFUN (Frun_hook_with_args_until_failure, MANY); |
| 2924 | extern void run_hook_with_args_2 (Lisp_Object, Lisp_Object, Lisp_Object); | 2924 | extern void run_hook_with_args_2 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 2925 | extern Lisp_Object run_hook_with_args (size_t nargs, Lisp_Object *args, | 2925 | extern Lisp_Object run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args, |
| 2926 | Lisp_Object (*funcall) | 2926 | Lisp_Object (*funcall) |
| 2927 | (size_t nargs, Lisp_Object *args)); | 2927 | (ptrdiff_t nargs, Lisp_Object *args)); |
| 2928 | EXFUN (Fprogn, UNEVALLED); | 2928 | EXFUN (Fprogn, UNEVALLED); |
| 2929 | EXFUN (Finteractive_p, 0); | 2929 | EXFUN (Finteractive_p, 0); |
| 2930 | EXFUN (Fthrow, 2) NO_RETURN; | 2930 | EXFUN (Fthrow, 2) NO_RETURN; |
| @@ -2956,7 +2956,7 @@ extern Lisp_Object internal_lisp_condition_case (Lisp_Object, Lisp_Object, Lisp_ | |||
| 2956 | extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object)); | 2956 | extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object)); |
| 2957 | extern Lisp_Object internal_condition_case_1 (Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); | 2957 | extern Lisp_Object internal_condition_case_1 (Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); |
| 2958 | extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); | 2958 | extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); |
| 2959 | extern Lisp_Object internal_condition_case_n (Lisp_Object (*) (size_t, Lisp_Object *), size_t, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object)); | 2959 | extern Lisp_Object internal_condition_case_n (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object)); |
| 2960 | extern void specbind (Lisp_Object, Lisp_Object); | 2960 | extern void specbind (Lisp_Object, Lisp_Object); |
| 2961 | extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); | 2961 | extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); |
| 2962 | extern Lisp_Object unbind_to (int, Lisp_Object); | 2962 | extern Lisp_Object unbind_to (int, Lisp_Object); |
| @@ -2966,7 +2966,7 @@ extern void verror (const char *, va_list) | |||
| 2966 | extern void do_autoload (Lisp_Object, Lisp_Object); | 2966 | extern void do_autoload (Lisp_Object, Lisp_Object); |
| 2967 | extern Lisp_Object un_autoload (Lisp_Object); | 2967 | extern Lisp_Object un_autoload (Lisp_Object); |
| 2968 | extern void init_eval_once (void); | 2968 | extern void init_eval_once (void); |
| 2969 | extern Lisp_Object safe_call (size_t, Lisp_Object *); | 2969 | extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object *); |
| 2970 | extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); | 2970 | extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); |
| 2971 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); | 2971 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 2972 | extern void init_eval (void); | 2972 | extern void init_eval (void); |
| @@ -3348,7 +3348,7 @@ extern void mark_byte_stack (void); | |||
| 3348 | #endif | 3348 | #endif |
| 3349 | extern void unmark_byte_stack (void); | 3349 | extern void unmark_byte_stack (void); |
| 3350 | extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, | 3350 | extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, |
| 3351 | Lisp_Object, int, Lisp_Object *); | 3351 | Lisp_Object, ptrdiff_t, Lisp_Object *); |
| 3352 | 3352 | ||
| 3353 | /* Defined in macros.c */ | 3353 | /* Defined in macros.c */ |
| 3354 | extern Lisp_Object Qexecute_kbd_macro; | 3354 | extern Lisp_Object Qexecute_kbd_macro; |