From: Paul Eggert Date: Mon, 18 Jun 2012 06:58:00 +0000 (-0700) Subject: Fix recently-introduced process.c problems found by static checking. X-Git-Tag: emacs-24.2.90~1199^2~439 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7ea2b33947b401d506d10bf47721278a2b174410;p=emacs.git 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. --- 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 + + 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 * 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