aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorPaul Eggert2011-03-29 17:39:12 -0700
committerPaul Eggert2011-03-29 17:39:12 -0700
commit77861b9528e3fbb5f406267ff298a95009530b7f (patch)
treed7eb3886831322f956d997d7bd10d034dfca5839 /src/eval.c
parentd806ab682a8e914345db3f2eede292f85745c98c (diff)
parentde6dbc14a72347f3f2a3b4f0bf3c39d6f69a425e (diff)
downloademacs-77861b9528e3fbb5f406267ff298a95009530b7f.tar.gz
emacs-77861b9528e3fbb5f406267ff298a95009530b7f.zip
Fix more problems found by GCC 4.6.0's static checks.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/src/eval.c b/src/eval.c
index 75874367f2c..26aea3df5df 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -38,9 +38,9 @@ struct backtrace
38 struct backtrace *next; 38 struct backtrace *next;
39 Lisp_Object *function; 39 Lisp_Object *function;
40 Lisp_Object *args; /* Points to vector of args. */ 40 Lisp_Object *args; /* Points to vector of args. */
41 int nargs; /* Length of vector. 41 size_t nargs; /* Length of vector.
42 If nargs is UNEVALLED, args points to slot holding 42 If nargs is (size_t) UNEVALLED, args points
43 list of unevalled args. */ 43 to slot holding list of unevalled args. */
44 char evalargs; 44 char evalargs;
45 /* Nonzero means call value of debugger when done with this operation. */ 45 /* Nonzero means call value of debugger when done with this operation. */
46 char debug_on_exit; 46 char debug_on_exit;
@@ -111,7 +111,7 @@ Lisp_Object Vsignaling_function;
111 111
112int handling_signal; 112int handling_signal;
113 113
114static Lisp_Object funcall_lambda (Lisp_Object, int, Lisp_Object*); 114static Lisp_Object funcall_lambda (Lisp_Object, size_t, Lisp_Object*);
115static void unwind_to_catch (struct catchtag *, Lisp_Object) NO_RETURN; 115static void unwind_to_catch (struct catchtag *, Lisp_Object) NO_RETURN;
116static int interactive_p (int); 116static int interactive_p (int);
117static Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, int); 117static Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, int);
@@ -553,7 +553,7 @@ interactive_p (int exclude_subrs_p)
553 looking at several frames for special forms. Skip past them. */ 553 looking at several frames for special forms. Skip past them. */
554 while (btp 554 while (btp
555 && (EQ (*btp->function, Qbytecode) 555 && (EQ (*btp->function, Qbytecode)
556 || btp->nargs == UNEVALLED)) 556 || btp->nargs == (size_t) UNEVALLED))
557 btp = btp->next; 557 btp = btp->next;
558 558
559 /* `btp' now points at the frame of the innermost function that isn't 559 /* `btp' now points at the frame of the innermost function that isn't
@@ -959,7 +959,7 @@ usage: (let VARLIST BODY...) */)
959 Lisp_Object *temps, tem; 959 Lisp_Object *temps, tem;
960 register Lisp_Object elt, varlist; 960 register Lisp_Object elt, varlist;
961 int count = SPECPDL_INDEX (); 961 int count = SPECPDL_INDEX ();
962 register int argnum; 962 register size_t argnum;
963 struct gcpro gcpro1, gcpro2; 963 struct gcpro gcpro1, gcpro2;
964 USE_SAFE_ALLOCA; 964 USE_SAFE_ALLOCA;
965 965
@@ -1508,8 +1508,8 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object),
1508 and ARGS as second argument. */ 1508 and ARGS as second argument. */
1509 1509
1510Lisp_Object 1510Lisp_Object
1511internal_condition_case_n (Lisp_Object (*bfun) (int, Lisp_Object*), 1511internal_condition_case_n (Lisp_Object (*bfun) (size_t, Lisp_Object *),
1512 int nargs, 1512 size_t nargs,
1513 Lisp_Object *args, 1513 Lisp_Object *args,
1514 Lisp_Object handlers, 1514 Lisp_Object handlers,
1515 Lisp_Object (*hfun) (Lisp_Object)) 1515 Lisp_Object (*hfun) (Lisp_Object))
@@ -2201,7 +2201,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0,
2201 { 2201 {
2202 /* Pass a vector of evaluated arguments. */ 2202 /* Pass a vector of evaluated arguments. */
2203 Lisp_Object *vals; 2203 Lisp_Object *vals;
2204 register int argnum = 0; 2204 register size_t argnum = 0;
2205 USE_SAFE_ALLOCA; 2205 USE_SAFE_ALLOCA;
2206 2206
2207 SAFE_ALLOCA_LISP (vals, XINT (numargs)); 2207 SAFE_ALLOCA_LISP (vals, XINT (numargs));
@@ -2330,9 +2330,9 @@ DEFUN ("apply", Fapply, Sapply, 2, MANY, 0,
2330Then return the value FUNCTION returns. 2330Then return the value FUNCTION returns.
2331Thus, (apply '+ 1 2 '(3 4)) returns 10. 2331Thus, (apply '+ 1 2 '(3 4)) returns 10.
2332usage: (apply FUNCTION &rest ARGUMENTS) */) 2332usage: (apply FUNCTION &rest ARGUMENTS) */)
2333 (int nargs, Lisp_Object *args) 2333 (size_t nargs, Lisp_Object *args)
2334{ 2334{
2335 register int i, numargs; 2335 register size_t i, numargs;
2336 register Lisp_Object spread_arg; 2336 register Lisp_Object spread_arg;
2337 register Lisp_Object *funcall_args; 2337 register Lisp_Object *funcall_args;
2338 Lisp_Object fun, retval; 2338 Lisp_Object fun, retval;
@@ -2372,7 +2372,7 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
2372 if (numargs < XSUBR (fun)->min_args 2372 if (numargs < XSUBR (fun)->min_args
2373 || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) 2373 || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs))
2374 goto funcall; /* Let funcall get the error. */ 2374 goto funcall; /* Let funcall get the error. */
2375 else if (XSUBR (fun)->max_args > numargs) 2375 else if (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args > numargs)
2376 { 2376 {
2377 /* Avoid making funcall cons up a yet another new vector of arguments 2377 /* Avoid making funcall cons up a yet another new vector of arguments
2378 by explicitly supplying nil's for optional values. */ 2378 by explicitly supplying nil's for optional values. */
@@ -2413,12 +2413,8 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
2413 2413
2414/* Run hook variables in various ways. */ 2414/* Run hook variables in various ways. */
2415 2415
2416Lisp_Object run_hook_with_args (int, Lisp_Object *,
2417 Lisp_Object (*funcall)
2418 (int nargs, Lisp_Object *args));
2419
2420static Lisp_Object 2416static Lisp_Object
2421funcall_nil (int nargs, Lisp_Object *args) 2417funcall_nil (size_t nargs, Lisp_Object *args)
2422{ 2418{
2423 Ffuncall (nargs, args); 2419 Ffuncall (nargs, args);
2424 return Qnil; 2420 return Qnil;
@@ -2439,10 +2435,10 @@ hook; they should use `run-mode-hooks' instead.
2439Do not use `make-local-variable' to make a hook variable buffer-local. 2435Do not use `make-local-variable' to make a hook variable buffer-local.
2440Instead, use `add-hook' and specify t for the LOCAL argument. 2436Instead, use `add-hook' and specify t for the LOCAL argument.
2441usage: (run-hooks &rest HOOKS) */) 2437usage: (run-hooks &rest HOOKS) */)
2442 (int nargs, Lisp_Object *args) 2438 (size_t nargs, Lisp_Object *args)
2443{ 2439{
2444 Lisp_Object hook[1]; 2440 Lisp_Object hook[1];
2445 register int i; 2441 register size_t i;
2446 2442
2447 for (i = 0; i < nargs; i++) 2443 for (i = 0; i < nargs; i++)
2448 { 2444 {
@@ -2468,7 +2464,7 @@ as that may change.
2468Do not use `make-local-variable' to make a hook variable buffer-local. 2464Do not use `make-local-variable' to make a hook variable buffer-local.
2469Instead, use `add-hook' and specify t for the LOCAL argument. 2465Instead, use `add-hook' and specify t for the LOCAL argument.
2470usage: (run-hook-with-args HOOK &rest ARGS) */) 2466usage: (run-hook-with-args HOOK &rest ARGS) */)
2471 (int nargs, Lisp_Object *args) 2467 (size_t nargs, Lisp_Object *args)
2472{ 2468{
2473 return run_hook_with_args (nargs, args, funcall_nil); 2469 return run_hook_with_args (nargs, args, funcall_nil);
2474} 2470}
@@ -2488,13 +2484,13 @@ However, if they all return nil, we return nil.
2488Do not use `make-local-variable' to make a hook variable buffer-local. 2484Do not use `make-local-variable' to make a hook variable buffer-local.
2489Instead, use `add-hook' and specify t for the LOCAL argument. 2485Instead, use `add-hook' and specify t for the LOCAL argument.
2490usage: (run-hook-with-args-until-success HOOK &rest ARGS) */) 2486usage: (run-hook-with-args-until-success HOOK &rest ARGS) */)
2491 (int nargs, Lisp_Object *args) 2487 (size_t nargs, Lisp_Object *args)
2492{ 2488{
2493 return run_hook_with_args (nargs, args, Ffuncall); 2489 return run_hook_with_args (nargs, args, Ffuncall);
2494} 2490}
2495 2491
2496static Lisp_Object 2492static Lisp_Object
2497funcall_not (int nargs, Lisp_Object *args) 2493funcall_not (size_t nargs, Lisp_Object *args)
2498{ 2494{
2499 return NILP (Ffuncall (nargs, args)) ? Qt : Qnil; 2495 return NILP (Ffuncall (nargs, args)) ? Qt : Qnil;
2500} 2496}
@@ -2513,13 +2509,13 @@ Then we return nil. However, if they all return non-nil, we return non-nil.
2513Do not use `make-local-variable' to make a hook variable buffer-local. 2509Do not use `make-local-variable' to make a hook variable buffer-local.
2514Instead, use `add-hook' and specify t for the LOCAL argument. 2510Instead, use `add-hook' and specify t for the LOCAL argument.
2515usage: (run-hook-with-args-until-failure HOOK &rest ARGS) */) 2511usage: (run-hook-with-args-until-failure HOOK &rest ARGS) */)
2516 (int nargs, Lisp_Object *args) 2512 (size_t nargs, Lisp_Object *args)
2517{ 2513{
2518 return NILP (run_hook_with_args (nargs, args, funcall_not)) ? Qt : Qnil; 2514 return NILP (run_hook_with_args (nargs, args, funcall_not)) ? Qt : Qnil;
2519} 2515}
2520 2516
2521static Lisp_Object 2517static Lisp_Object
2522run_hook_wrapped_funcall (int nargs, Lisp_Object *args) 2518run_hook_wrapped_funcall (size_t nargs, Lisp_Object *args)
2523{ 2519{
2524 Lisp_Object tmp = args[0], ret; 2520 Lisp_Object tmp = args[0], ret;
2525 args[0] = args[1]; 2521 args[0] = args[1];
@@ -2537,11 +2533,11 @@ it calls WRAP-FUNCTION with arguments FUN and ARGS.
2537As soon as a call to WRAP-FUNCTION returns non-nil, `run-hook-wrapped' 2533As soon as a call to WRAP-FUNCTION returns non-nil, `run-hook-wrapped'
2538aborts and returns that value. 2534aborts and returns that value.
2539usage: (run-hook-wrapped HOOK WRAP-FUNCTION &rest ARGS) */) 2535usage: (run-hook-wrapped HOOK WRAP-FUNCTION &rest ARGS) */)
2540 (int nargs, Lisp_Object *args) 2536 (size_t nargs, Lisp_Object *args)
2541{ 2537{
2542 return run_hook_with_args (nargs, args, run_hook_wrapped_funcall); 2538 return run_hook_with_args (nargs, args, run_hook_wrapped_funcall);
2543} 2539}
2544 2540
2545/* ARGS[0] should be a hook symbol. 2541/* ARGS[0] should be a hook symbol.
2546 Call each of the functions in the hook value, passing each of them 2542 Call each of the functions in the hook value, passing each of them
2547 as arguments all the rest of ARGS (all NARGS - 1 elements). 2543 as arguments all the rest of ARGS (all NARGS - 1 elements).
@@ -2550,8 +2546,8 @@ usage: (run-hook-wrapped HOOK WRAP-FUNCTION &rest ARGS) */)
2550 except that it isn't necessary to gcpro ARGS[0]. */ 2546 except that it isn't necessary to gcpro ARGS[0]. */
2551 2547
2552Lisp_Object 2548Lisp_Object
2553run_hook_with_args (int nargs, Lisp_Object *args, 2549run_hook_with_args (size_t nargs, Lisp_Object *args,
2554 Lisp_Object (*funcall) (int nargs, Lisp_Object *args)) 2550 Lisp_Object (*funcall) (size_t nargs, Lisp_Object *args))
2555{ 2551{
2556 Lisp_Object sym, val, ret = Qnil; 2552 Lisp_Object sym, val, ret = Qnil;
2557 struct gcpro gcpro1, gcpro2, gcpro3; 2553 struct gcpro gcpro1, gcpro2, gcpro3;
@@ -2791,16 +2787,16 @@ DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
2791Return the value that function returns. 2787Return the value that function returns.
2792Thus, (funcall 'cons 'x 'y) returns (x . y). 2788Thus, (funcall 'cons 'x 'y) returns (x . y).
2793usage: (funcall FUNCTION &rest ARGUMENTS) */) 2789usage: (funcall FUNCTION &rest ARGUMENTS) */)
2794 (int nargs, Lisp_Object *args) 2790 (size_t nargs, Lisp_Object *args)
2795{ 2791{
2796 Lisp_Object fun, original_fun; 2792 Lisp_Object fun, original_fun;
2797 Lisp_Object funcar; 2793 Lisp_Object funcar;
2798 int numargs = nargs - 1; 2794 size_t numargs = nargs - 1;
2799 Lisp_Object lisp_numargs; 2795 Lisp_Object lisp_numargs;
2800 Lisp_Object val; 2796 Lisp_Object val;
2801 struct backtrace backtrace; 2797 struct backtrace backtrace;
2802 register Lisp_Object *internal_args; 2798 register Lisp_Object *internal_args;
2803 register int i; 2799 register size_t i;
2804 2800
2805 QUIT; 2801 QUIT;
2806 if ((consing_since_gc > gc_cons_threshold 2802 if ((consing_since_gc > gc_cons_threshold
@@ -2953,21 +2949,21 @@ static Lisp_Object
2953apply_lambda (Lisp_Object fun, Lisp_Object args, int eval_flag) 2949apply_lambda (Lisp_Object fun, Lisp_Object args, int eval_flag)
2954{ 2950{
2955 Lisp_Object args_left; 2951 Lisp_Object args_left;
2956 Lisp_Object numargs; 2952 size_t numargs;
2957 register Lisp_Object *arg_vector; 2953 register Lisp_Object *arg_vector;
2958 struct gcpro gcpro1, gcpro2, gcpro3; 2954 struct gcpro gcpro1, gcpro2, gcpro3;
2959 register int i; 2955 register size_t i;
2960 register Lisp_Object tem; 2956 register Lisp_Object tem;
2961 USE_SAFE_ALLOCA; 2957 USE_SAFE_ALLOCA;
2962 2958
2963 numargs = Flength (args); 2959 numargs = XINT (Flength (args));
2964 SAFE_ALLOCA_LISP (arg_vector, XINT (numargs)); 2960 SAFE_ALLOCA_LISP (arg_vector, numargs);
2965 args_left = args; 2961 args_left = args;
2966 2962
2967 GCPRO3 (*arg_vector, args_left, fun); 2963 GCPRO3 (*arg_vector, args_left, fun);
2968 gcpro1.nvars = 0; 2964 gcpro1.nvars = 0;
2969 2965
2970 for (i = 0; i < XINT (numargs);) 2966 for (i = 0; i < numargs; )
2971 { 2967 {
2972 tem = Fcar (args_left), args_left = Fcdr (args_left); 2968 tem = Fcar (args_left), args_left = Fcdr (args_left);
2973 if (eval_flag) tem = Feval (tem); 2969 if (eval_flag) tem = Feval (tem);
@@ -2983,7 +2979,7 @@ apply_lambda (Lisp_Object fun, Lisp_Object args, int eval_flag)
2983 backtrace_list->nargs = i; 2979 backtrace_list->nargs = i;
2984 } 2980 }
2985 backtrace_list->evalargs = 0; 2981 backtrace_list->evalargs = 0;
2986 tem = funcall_lambda (fun, XINT (numargs), arg_vector); 2982 tem = funcall_lambda (fun, numargs, arg_vector);
2987 2983
2988 /* Do the debug-on-exit now, while arg_vector still exists. */ 2984 /* Do the debug-on-exit now, while arg_vector still exists. */
2989 if (backtrace_list->debug_on_exit) 2985 if (backtrace_list->debug_on_exit)
@@ -2999,11 +2995,13 @@ apply_lambda (Lisp_Object fun, Lisp_Object args, int eval_flag)
2999 FUN must be either a lambda-expression or a compiled-code object. */ 2995 FUN must be either a lambda-expression or a compiled-code object. */
3000 2996
3001static Lisp_Object 2997static Lisp_Object
3002funcall_lambda (Lisp_Object fun, int nargs, register Lisp_Object *arg_vector) 2998funcall_lambda (Lisp_Object fun, size_t nargs,
2999 register Lisp_Object *arg_vector)
3003{ 3000{
3004 Lisp_Object val, syms_left, next; 3001 Lisp_Object val, syms_left, next;
3005 int count = SPECPDL_INDEX (); 3002 int count = SPECPDL_INDEX ();
3006 int i, optional, rest; 3003 size_t i;
3004 int optional, rest;
3007 3005
3008 if (CONSP (fun)) 3006 if (CONSP (fun))
3009 { 3007 {
@@ -3323,7 +3321,6 @@ Output stream used is value of `standard-output'. */)
3323 (void) 3321 (void)
3324{ 3322{
3325 register struct backtrace *backlist = backtrace_list; 3323 register struct backtrace *backlist = backtrace_list;
3326 register int i;
3327 Lisp_Object tail; 3324 Lisp_Object tail;
3328 Lisp_Object tem; 3325 Lisp_Object tem;
3329 struct gcpro gcpro1; 3326 struct gcpro gcpro1;
@@ -3338,7 +3335,7 @@ Output stream used is value of `standard-output'. */)
3338 while (backlist) 3335 while (backlist)
3339 { 3336 {
3340 write_string (backlist->debug_on_exit ? "* " : " ", 2); 3337 write_string (backlist->debug_on_exit ? "* " : " ", 2);
3341 if (backlist->nargs == UNEVALLED) 3338 if (backlist->nargs == (size_t) UNEVALLED)
3342 { 3339 {
3343 Fprin1 (Fcons (*backlist->function, *backlist->args), Qnil); 3340 Fprin1 (Fcons (*backlist->function, *backlist->args), Qnil);
3344 write_string ("\n", -1); 3341 write_string ("\n", -1);
@@ -3348,11 +3345,12 @@ Output stream used is value of `standard-output'. */)
3348 tem = *backlist->function; 3345 tem = *backlist->function;
3349 Fprin1 (tem, Qnil); /* This can QUIT. */ 3346 Fprin1 (tem, Qnil); /* This can QUIT. */
3350 write_string ("(", -1); 3347 write_string ("(", -1);
3351 if (backlist->nargs == MANY) 3348 if (backlist->nargs == (size_t) MANY)
3352 { 3349 {
3350 int i;
3353 for (tail = *backlist->args, i = 0; 3351 for (tail = *backlist->args, i = 0;
3354 !NILP (tail); 3352 !NILP (tail);
3355 tail = Fcdr (tail), i++) 3353 tail = Fcdr (tail), i = 1)
3356 { 3354 {
3357 if (i) write_string (" ", -1); 3355 if (i) write_string (" ", -1);
3358 Fprin1 (Fcar (tail), Qnil); 3356 Fprin1 (Fcar (tail), Qnil);
@@ -3360,6 +3358,7 @@ Output stream used is value of `standard-output'. */)
3360 } 3358 }
3361 else 3359 else
3362 { 3360 {
3361 size_t i;
3363 for (i = 0; i < backlist->nargs; i++) 3362 for (i = 0; i < backlist->nargs; i++)
3364 { 3363 {
3365 if (i) write_string (" ", -1); 3364 if (i) write_string (" ", -1);
@@ -3389,7 +3388,7 @@ If NFRAMES is more than the number of frames, the value is nil. */)
3389 (Lisp_Object nframes) 3388 (Lisp_Object nframes)
3390{ 3389{
3391 register struct backtrace *backlist = backtrace_list; 3390 register struct backtrace *backlist = backtrace_list;
3392 register int i; 3391 register EMACS_INT i;
3393 Lisp_Object tem; 3392 Lisp_Object tem;
3394 3393
3395 CHECK_NATNUM (nframes); 3394 CHECK_NATNUM (nframes);
@@ -3400,11 +3399,11 @@ If NFRAMES is more than the number of frames, the value is nil. */)
3400 3399
3401 if (!backlist) 3400 if (!backlist)
3402 return Qnil; 3401 return Qnil;
3403 if (backlist->nargs == UNEVALLED) 3402 if (backlist->nargs == (size_t) UNEVALLED)
3404 return Fcons (Qnil, Fcons (*backlist->function, *backlist->args)); 3403 return Fcons (Qnil, Fcons (*backlist->function, *backlist->args));
3405 else 3404 else
3406 { 3405 {
3407 if (backlist->nargs == MANY) 3406 if (backlist->nargs == (size_t) MANY)
3408 tem = *backlist->args; 3407 tem = *backlist->args;
3409 else 3408 else
3410 tem = Flist (backlist->nargs, backlist->args); 3409 tem = Flist (backlist->nargs, backlist->args);
@@ -3418,17 +3417,18 @@ void
3418mark_backtrace (void) 3417mark_backtrace (void)
3419{ 3418{
3420 register struct backtrace *backlist; 3419 register struct backtrace *backlist;
3421 register int i; 3420 register size_t i;
3422 3421
3423 for (backlist = backtrace_list; backlist; backlist = backlist->next) 3422 for (backlist = backtrace_list; backlist; backlist = backlist->next)
3424 { 3423 {
3425 mark_object (*backlist->function); 3424 mark_object (*backlist->function);
3426 3425
3427 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY) 3426 if (backlist->nargs == (size_t) UNEVALLED
3428 i = 0; 3427 || backlist->nargs == (size_t) MANY)
3428 i = 1;
3429 else 3429 else
3430 i = backlist->nargs - 1; 3430 i = backlist->nargs;
3431 for (; i >= 0; i--) 3431 while (i--)
3432 mark_object (backlist->args[i]); 3432 mark_object (backlist->args[i]);
3433 } 3433 }
3434} 3434}