diff options
| author | Paul Eggert | 2012-06-17 23:58:00 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-06-17 23:58:00 -0700 |
| commit | 7ea2b33947b401d506d10bf47721278a2b174410 (patch) | |
| tree | 5480d85adcb9a888e3d39701f86859e65794d716 /src/process.c | |
| parent | 24b0cff0ba42f6600db603cc2a4a6736fa5e7e92 (diff) | |
| download | emacs-7ea2b33947b401d506d10bf47721278a2b174410.tar.gz emacs-7ea2b33947b401d506d10bf47721278a2b174410.zip | |
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/process.c')
| -rw-r--r-- | src/process.c | 19 |
1 files changed, 8 insertions, 11 deletions
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) | |||
| 5393 | 5393 | ||
| 5394 | static void | 5394 | static void |
| 5395 | write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj, | 5395 | write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj, |
| 5396 | const char *buf, int len, int front) | 5396 | const char *buf, ptrdiff_t len, int front) |
| 5397 | { | 5397 | { |
| 5398 | EMACS_INT offset; | 5398 | ptrdiff_t offset; |
| 5399 | Lisp_Object entry, obj; | 5399 | Lisp_Object entry, obj; |
| 5400 | 5400 | ||
| 5401 | if (STRINGP (input_obj)) | 5401 | if (STRINGP (input_obj)) |
| @@ -5423,10 +5423,10 @@ write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj, | |||
| 5423 | 5423 | ||
| 5424 | static int | 5424 | static int |
| 5425 | write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, | 5425 | write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, |
| 5426 | const char **buf, EMACS_INT *len) | 5426 | const char **buf, ptrdiff_t *len) |
| 5427 | { | 5427 | { |
| 5428 | Lisp_Object entry, offset_length; | 5428 | Lisp_Object entry, offset_length; |
| 5429 | EMACS_INT offset; | 5429 | ptrdiff_t offset; |
| 5430 | 5430 | ||
| 5431 | if (NILP (p->write_queue)) | 5431 | if (NILP (p->write_queue)) |
| 5432 | return 0; | 5432 | return 0; |
| @@ -5439,7 +5439,7 @@ write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, | |||
| 5439 | 5439 | ||
| 5440 | *len = XINT (XCDR (offset_length)); | 5440 | *len = XINT (XCDR (offset_length)); |
| 5441 | offset = XINT (XCAR (offset_length)); | 5441 | offset = XINT (XCAR (offset_length)); |
| 5442 | *buf = SDATA (*obj) + offset; | 5442 | *buf = SSDATA (*obj) + offset; |
| 5443 | 5443 | ||
| 5444 | return 1; | 5444 | return 1; |
| 5445 | } | 5445 | } |
| @@ -5584,7 +5584,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, | |||
| 5584 | 5584 | ||
| 5585 | do /* while !NILP (p->write_queue) */ | 5585 | do /* while !NILP (p->write_queue) */ |
| 5586 | { | 5586 | { |
| 5587 | EMACS_INT cur_len = -1; | 5587 | ptrdiff_t cur_len = -1; |
| 5588 | const char *cur_buf; | 5588 | const char *cur_buf; |
| 5589 | Lisp_Object cur_object; | 5589 | Lisp_Object cur_object; |
| 5590 | 5590 | ||
| @@ -5653,8 +5653,6 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, | |||
| 5653 | that may allow the program | 5653 | that may allow the program |
| 5654 | to finish doing output and read more. */ | 5654 | to finish doing output and read more. */ |
| 5655 | { | 5655 | { |
| 5656 | ptrdiff_t offset = 0; | ||
| 5657 | |||
| 5658 | #ifdef BROKEN_PTY_READ_AFTER_EAGAIN | 5656 | #ifdef BROKEN_PTY_READ_AFTER_EAGAIN |
| 5659 | /* A gross hack to work around a bug in FreeBSD. | 5657 | /* A gross hack to work around a bug in FreeBSD. |
| 5660 | In the following sequence, read(2) returns | 5658 | In the following sequence, read(2) returns |
| @@ -5680,15 +5678,14 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, | |||
| 5680 | } | 5678 | } |
| 5681 | #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ | 5679 | #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ |
| 5682 | 5680 | ||
| 5683 | /* Put what we should have written in | 5681 | /* Put what we should have written in wait_queue. */ |
| 5684 | wait_queue */ | ||
| 5685 | write_queue_push (p, cur_object, cur_buf, cur_len, 1); | 5682 | write_queue_push (p, cur_object, cur_buf, cur_len, 1); |
| 5686 | #ifdef EMACS_HAS_USECS | 5683 | #ifdef EMACS_HAS_USECS |
| 5687 | wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0); | 5684 | wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0); |
| 5688 | #else | 5685 | #else |
| 5689 | wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0); | 5686 | wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0); |
| 5690 | #endif | 5687 | #endif |
| 5691 | /* reread queue, to see what is left */ | 5688 | /* Reread queue, to see what is left. */ |
| 5692 | break; | 5689 | break; |
| 5693 | } | 5690 | } |
| 5694 | else | 5691 | else |