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.
This commit is contained in:
Paul Eggert 2012-06-17 23:58:00 -07:00
parent 24b0cff0ba
commit 7ea2b33947
2 changed files with 16 additions and 11 deletions

View file

@ -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

View file

@ -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