diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2012-06-17 23:58:00 -0700 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-06-17 23:58:00 -0700 |
| commit | 7ea2b33947b401d506d10bf47721278a2b174410 (patch) | |
| tree | 5480d85adcb9a888e3d39701f86859e65794d716 /src | |
| parent | 24b0cff0ba42f6600db603cc2a4a6736fa5e7e92 (diff) | |
| download | emacs-7ea2b33947b401d506d10bf47721278a2b174410.tar.gz | |
Fix recently-introduced process.c problems found by static checking.
* process.c (write_queue_push, write_queue_pop, send_process):
Use ptrdiff_t, not int or EMACS_INT, for buffer lengths and offsets.
(write_queue_pop): Fix pointer signedness problem.
(send_process): Remove unused local.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/process.c | 19 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 309f4447dbc..de472ab51dd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2012-06-18 Paul Eggert <eggert@cs.ucla.edu> + + Fix recently-introduced process.c problems found by static checking. + * process.c (write_queue_push, write_queue_pop, send_process): + Use ptrdiff_t, not int or EMACS_INT, for buffer lengths and offsets. + (write_queue_pop): Fix pointer signedness problem. + (send_process): Remove unused local. + 2012-06-17 Chong Yidong <cyd@gnu.org> * xdisp.c (redisplay_internal): No need to redisplay terminal diff --git a/src/process.c b/src/process.c index 0434caf7574..cb89cae99fe 100644 --- a/src/process.c +++ b/src/process.c @@ -5393,9 +5393,9 @@ send_process_trap (int ignore) static void write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj, - const char *buf, int len, int front) + const char *buf, ptrdiff_t len, int front) { - EMACS_INT offset; + ptrdiff_t offset; Lisp_Object entry, obj; if (STRINGP (input_obj)) @@ -5423,10 +5423,10 @@ write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj, static int write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, - const char **buf, EMACS_INT *len) + const char **buf, ptrdiff_t *len) { Lisp_Object entry, offset_length; - EMACS_INT offset; + ptrdiff_t offset; if (NILP (p->write_queue)) return 0; @@ -5439,7 +5439,7 @@ write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, *len = XINT (XCDR (offset_length)); offset = XINT (XCAR (offset_length)); - *buf = SDATA (*obj) + offset; + *buf = SSDATA (*obj) + offset; return 1; } @@ -5584,7 +5584,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, do /* while !NILP (p->write_queue) */ { - EMACS_INT cur_len = -1; + ptrdiff_t cur_len = -1; const char *cur_buf; Lisp_Object cur_object; @@ -5653,8 +5653,6 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, that may allow the program to finish doing output and read more. */ { - ptrdiff_t offset = 0; - #ifdef BROKEN_PTY_READ_AFTER_EAGAIN /* A gross hack to work around a bug in FreeBSD. In the following sequence, read(2) returns @@ -5680,15 +5678,14 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, } #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ - /* Put what we should have written in - wait_queue */ + /* Put what we should have written in wait_queue. */ write_queue_push (p, cur_object, cur_buf, cur_len, 1); #ifdef EMACS_HAS_USECS wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0); #else wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0); #endif - /* reread queue, to see what is left */ + /* Reread queue, to see what is left. */ break; } else |
