aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-07-16 11:30:52 -0700
committerPaul Eggert2013-07-16 11:30:52 -0700
commit4e604a5d70c4f26abe8bb3494346c598389906b3 (patch)
tree6842a74fd23245cde0e5e4a97aa42ca32c119a0f /src
parenta9757f6a03cce5ff2931b1125a9a2249573c8e1c (diff)
downloademacs-4e604a5d70c4f26abe8bb3494346c598389906b3.tar.gz
emacs-4e604a5d70c4f26abe8bb3494346c598389906b3.zip
Be simpler and more consistent about reporting I/O errors.
* fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region): Say "Read error" and "Write error", rather than "I/O error", or "IO error reading", or "IO error writing", when a read or write error occurs. * process.c (Fmake_network_process, wait_reading_process_output) (send_process, Fprocess_send_eof, wait_reading_process_output): Capitalize diagnostics consistently. Put "failed foo" at the start of the diagnostic, so that we don't capitalize the function name "foo". Consistently say "failed" for such diagnostics. * sysdep.c, w32.c (serial_open): Now accepts Lisp string, not C string. All callers changed. This is so it can use report_file_error. * sysdep.c (serial_open, serial_configure): Capitalize I/O diagnostics consistently as above.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog16
-rw-r--r--src/fileio.c22
-rw-r--r--src/process.c18
-rw-r--r--src/sysdep.c16
-rw-r--r--src/systty.h2
-rw-r--r--src/w32.c3
6 files changed, 42 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0c96e4b901b..f234fef84a6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,21 @@
12013-07-16 Paul Eggert <eggert@cs.ucla.edu> 12013-07-16 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Be simpler and more consistent about reporting I/O errors.
4 * fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region):
5 Say "Read error" and "Write error", rather than "I/O error", or
6 "IO error reading", or "IO error writing", when a read or write
7 error occurs.
8 * process.c (Fmake_network_process, wait_reading_process_output)
9 (send_process, Fprocess_send_eof, wait_reading_process_output):
10 Capitalize diagnostics consistently. Put "failed foo" at the
11 start of the diagnostic, so that we don't capitalize the
12 function name "foo". Consistently say "failed" for such
13 diagnostics.
14 * sysdep.c, w32.c (serial_open): Now accepts Lisp string, not C string.
15 All callers changed. This is so it can use report_file_error.
16 * sysdep.c (serial_open, serial_configure): Capitalize I/O
17 diagnostics consistently as above.
18
3 * fileio.c (report_file_errno): Fix errno reporting bug. 19 * fileio.c (report_file_errno): Fix errno reporting bug.
4 If the file name is neither null nor a pair, package it up as a 20 If the file name is neither null nor a pair, package it up as a
5 singleton list. All callers changed, both to this function and to 21 singleton list. All callers changed, both to this function and to
diff --git a/src/fileio.c b/src/fileio.c
index ae9c15a0164..fba28f09273 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2125,7 +2125,7 @@ entries (depending on how Emacs was built). */)
2125 QUIT; 2125 QUIT;
2126 while ((n = emacs_read (ifd, buf, sizeof buf)) > 0) 2126 while ((n = emacs_read (ifd, buf, sizeof buf)) > 0)
2127 if (emacs_write_sig (ofd, buf, n) != n) 2127 if (emacs_write_sig (ofd, buf, n) != n)
2128 report_file_error ("I/O error", newname); 2128 report_file_error ("Write error", newname);
2129 immediate_quit = 0; 2129 immediate_quit = 0;
2130 2130
2131#ifndef MSDOS 2131#ifndef MSDOS
@@ -2182,7 +2182,7 @@ entries (depending on how Emacs was built). */)
2182 } 2182 }
2183 2183
2184 if (emacs_close (ofd) < 0) 2184 if (emacs_close (ofd) < 0)
2185 report_file_error ("I/O error", newname); 2185 report_file_error ("Write error", newname);
2186 2186
2187 emacs_close (ifd); 2187 emacs_close (ifd);
2188 2188
@@ -3697,8 +3697,7 @@ by calling `format-decode', which see. */)
3697 } 3697 }
3698 3698
3699 if (nread < 0) 3699 if (nread < 0)
3700 error ("IO error reading %s: %s", 3700 report_file_error ("Read error", orig_filename);
3701 SDATA (orig_filename), emacs_strerror (errno));
3702 else if (nread > 0) 3701 else if (nread > 0)
3703 { 3702 {
3704 struct buffer *prev = current_buffer; 3703 struct buffer *prev = current_buffer;
@@ -3813,8 +3812,7 @@ by calling `format-decode', which see. */)
3813 3812
3814 nread = emacs_read (fd, read_buf, sizeof read_buf); 3813 nread = emacs_read (fd, read_buf, sizeof read_buf);
3815 if (nread < 0) 3814 if (nread < 0)
3816 error ("IO error reading %s: %s", 3815 report_file_error ("Read error", orig_filename);
3817 SSDATA (orig_filename), emacs_strerror (errno));
3818 else if (nread == 0) 3816 else if (nread == 0)
3819 break; 3817 break;
3820 3818
@@ -3879,8 +3877,7 @@ by calling `format-decode', which see. */)
3879 { 3877 {
3880 nread = emacs_read (fd, read_buf + total_read, trial - total_read); 3878 nread = emacs_read (fd, read_buf + total_read, trial - total_read);
3881 if (nread < 0) 3879 if (nread < 0)
3882 error ("IO error reading %s: %s", 3880 report_file_error ("Read error", orig_filename);
3883 SDATA (orig_filename), emacs_strerror (errno));
3884 else if (nread == 0) 3881 else if (nread == 0)
3885 break; 3882 break;
3886 total_read += nread; 3883 total_read += nread;
@@ -4030,8 +4027,7 @@ by calling `format-decode', which see. */)
4030 deferred_remove_unwind_protect = 1; 4027 deferred_remove_unwind_protect = 1;
4031 4028
4032 if (this < 0) 4029 if (this < 0)
4033 error ("IO error reading %s: %s", 4030 report_file_error ("Read error", orig_filename);
4034 SDATA (orig_filename), emacs_strerror (errno));
4035 4031
4036 if (unprocessed > 0) 4032 if (unprocessed > 0)
4037 { 4033 {
@@ -4277,8 +4273,7 @@ by calling `format-decode', which see. */)
4277 specpdl_ptr--; 4273 specpdl_ptr--;
4278 4274
4279 if (how_much < 0) 4275 if (how_much < 0)
4280 error ("IO error reading %s: %s", 4276 report_file_error ("Read error", orig_filename);
4281 SDATA (orig_filename), emacs_strerror (errno));
4282 4277
4283 /* Make the text read part of the buffer. */ 4278 /* Make the text read part of the buffer. */
4284 GAP_SIZE -= inserted; 4279 GAP_SIZE -= inserted;
@@ -5071,8 +5066,7 @@ This calls `write-region-annotate-functions' at the start, and
5071 } 5066 }
5072 5067
5073 if (! ok) 5068 if (! ok)
5074 error ("IO error writing %s: %s", SDATA (filename), 5069 report_file_errno ("Write error", filename, save_errno);
5075 emacs_strerror (save_errno));
5076 5070
5077 if (visiting) 5071 if (visiting)
5078 { 5072 {
diff --git a/src/process.c b/src/process.c
index b51e3bab033..fe843ca2d93 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2573,7 +2573,7 @@ usage: (make-serial-process &rest ARGS) */)
2573 record_unwind_protect (make_serial_process_unwind, proc); 2573 record_unwind_protect (make_serial_process_unwind, proc);
2574 p = XPROCESS (proc); 2574 p = XPROCESS (proc);
2575 2575
2576 fd = serial_open (SSDATA (port)); 2576 fd = serial_open (port);
2577 p->infd = fd; 2577 p->infd = fd;
2578 p->outfd = fd; 2578 p->outfd = fd;
2579 if (fd > max_process_desc) 2579 if (fd > max_process_desc)
@@ -3257,16 +3257,16 @@ usage: (make-network-process &rest ARGS) */)
3257 if (errno == EINTR) 3257 if (errno == EINTR)
3258 goto retry_select; 3258 goto retry_select;
3259 else 3259 else
3260 report_file_error ("select failed", Qnil); 3260 report_file_error ("Failed select", Qnil);
3261 } 3261 }
3262 eassert (sc > 0); 3262 eassert (sc > 0);
3263 3263
3264 len = sizeof xerrno; 3264 len = sizeof xerrno;
3265 eassert (FD_ISSET (s, &fdset)); 3265 eassert (FD_ISSET (s, &fdset));
3266 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) < 0) 3266 if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) < 0)
3267 report_file_error ("getsockopt failed", Qnil); 3267 report_file_error ("Failed getsockopt", Qnil);
3268 if (xerrno) 3268 if (xerrno)
3269 report_file_errno ("error during connect", Qnil, xerrno); 3269 report_file_errno ("Failed connect", Qnil, xerrno);
3270 break; 3270 break;
3271 } 3271 }
3272#endif /* !WINDOWSNT */ 3272#endif /* !WINDOWSNT */
@@ -4624,7 +4624,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4624 else if (xerrno == EBADF) 4624 else if (xerrno == EBADF)
4625 emacs_abort (); 4625 emacs_abort ();
4626 else 4626 else
4627 error ("select error: %s", emacs_strerror (xerrno)); 4627 report_file_errno ("Failed select", Qnil, xerrno);
4628 } 4628 }
4629 4629
4630 if (no_avail) 4630 if (no_avail)
@@ -5466,7 +5466,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5466 if (rv >= 0) 5466 if (rv >= 0)
5467 written = rv; 5467 written = rv;
5468 else if (errno == EMSGSIZE) 5468 else if (errno == EMSGSIZE)
5469 report_file_error ("sending datagram", proc); 5469 report_file_error ("Sending datagram", proc);
5470 } 5470 }
5471 else 5471 else
5472#endif 5472#endif
@@ -5543,7 +5543,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5543 } 5543 }
5544 else 5544 else
5545 /* This is a real error. */ 5545 /* This is a real error. */
5546 report_file_error ("writing to process", proc); 5546 report_file_error ("Writing to process", proc);
5547 } 5547 }
5548 cur_buf += written; 5548 cur_buf += written;
5549 cur_len -= written; 5549 cur_len -= written;
@@ -6037,7 +6037,7 @@ process has been transmitted to the serial port. */)
6037 { 6037 {
6038#ifndef WINDOWSNT 6038#ifndef WINDOWSNT
6039 if (tcdrain (XPROCESS (proc)->outfd) != 0) 6039 if (tcdrain (XPROCESS (proc)->outfd) != 0)
6040 error ("tcdrain() failed: %s", emacs_strerror (errno)); 6040 report_file_error ("Failed tcdrain", Qnil);
6041#endif /* not WINDOWSNT */ 6041#endif /* not WINDOWSNT */
6042 /* Do nothing on Windows because writes are blocking. */ 6042 /* Do nothing on Windows because writes are blocking. */
6043 } 6043 }
@@ -6733,7 +6733,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6733 if (xerrno == EINTR) 6733 if (xerrno == EINTR)
6734 FD_ZERO (&waitchannels); 6734 FD_ZERO (&waitchannels);
6735 else 6735 else
6736 error ("select error: %s", emacs_strerror (xerrno)); 6736 report_file_errno ("Failed select", Qnil, xerrno);
6737 } 6737 }
6738 6738
6739 /* Check for keyboard input */ 6739 /* Check for keyboard input */
diff --git a/src/sysdep.c b/src/sysdep.c
index 82f490e9538..465d271abca 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2436,14 +2436,11 @@ safe_strsignal (int code)
2436#ifndef DOS_NT 2436#ifndef DOS_NT
2437/* For make-serial-process */ 2437/* For make-serial-process */
2438int 2438int
2439serial_open (char *port) 2439serial_open (Lisp_Object port)
2440{ 2440{
2441 int fd = emacs_open (port, O_RDWR | O_NOCTTY | O_NONBLOCK, 0); 2441 int fd = emacs_open (SSDATA (port), O_RDWR | O_NOCTTY | O_NONBLOCK, 0);
2442 if (fd < 0) 2442 if (fd < 0)
2443 { 2443 report_file_error ("Opening serial port", port);
2444 error ("Could not open %s: %s",
2445 port, emacs_strerror (errno));
2446 }
2447#ifdef TIOCEXCL 2444#ifdef TIOCEXCL
2448 ioctl (fd, TIOCEXCL, (char *) 0); 2445 ioctl (fd, TIOCEXCL, (char *) 0);
2449#endif 2446#endif
@@ -2491,7 +2488,7 @@ serial_configure (struct Lisp_Process *p,
2491 /* Read port attributes and prepare default configuration. */ 2488 /* Read port attributes and prepare default configuration. */
2492 err = tcgetattr (p->outfd, &attr); 2489 err = tcgetattr (p->outfd, &attr);
2493 if (err != 0) 2490 if (err != 0)
2494 error ("tcgetattr() failed: %s", emacs_strerror (errno)); 2491 report_file_error ("Failed tcgetattr", Qnil);
2495 cfmakeraw (&attr); 2492 cfmakeraw (&attr);
2496#if defined (CLOCAL) 2493#if defined (CLOCAL)
2497 attr.c_cflag |= CLOCAL; 2494 attr.c_cflag |= CLOCAL;
@@ -2508,8 +2505,7 @@ serial_configure (struct Lisp_Process *p,
2508 CHECK_NUMBER (tem); 2505 CHECK_NUMBER (tem);
2509 err = cfsetspeed (&attr, XINT (tem)); 2506 err = cfsetspeed (&attr, XINT (tem));
2510 if (err != 0) 2507 if (err != 0)
2511 error ("cfsetspeed(%"pI"d) failed: %s", XINT (tem), 2508 report_file_error ("Failed cfsetspeed", tem);
2512 emacs_strerror (errno));
2513 childp2 = Fplist_put (childp2, QCspeed, tem); 2509 childp2 = Fplist_put (childp2, QCspeed, tem);
2514 2510
2515 /* Configure bytesize. */ 2511 /* Configure bytesize. */
@@ -2631,7 +2627,7 @@ serial_configure (struct Lisp_Process *p,
2631 /* Activate configuration. */ 2627 /* Activate configuration. */
2632 err = tcsetattr (p->outfd, TCSANOW, &attr); 2628 err = tcsetattr (p->outfd, TCSANOW, &attr);
2633 if (err != 0) 2629 if (err != 0)
2634 error ("tcsetattr() failed: %s", emacs_strerror (errno)); 2630 report_file_error ("Failed tcsetattr", Qnil);
2635 2631
2636 childp2 = Fplist_put (childp2, QCsummary, build_string (summary)); 2632 childp2 = Fplist_put (childp2, QCsummary, build_string (summary));
2637 pset_childp (p, childp2); 2633 pset_childp (p, childp2);
diff --git a/src/systty.h b/src/systty.h
index 6d38c980725..b735971c66f 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -79,5 +79,5 @@ struct emacs_tty {
79}; 79};
80 80
81/* From sysdep.c or w32.c */ 81/* From sysdep.c or w32.c */
82extern int serial_open (char *); 82extern int serial_open (Lisp_Object);
83extern void serial_configure (struct Lisp_Process *, Lisp_Object); 83extern void serial_configure (struct Lisp_Process *, Lisp_Object);
diff --git a/src/w32.c b/src/w32.c
index 1a3d81bbffc..fb2d7c75972 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -7707,8 +7707,9 @@ globals_of_w32 (void)
7707 7707
7708/* For make-serial-process */ 7708/* For make-serial-process */
7709int 7709int
7710serial_open (char *port) 7710serial_open (Lisp_Object port_obj)
7711{ 7711{
7712 char *port = SSDATA (port_obj);
7712 HANDLE hnd; 7713 HANDLE hnd;
7713 child_process *cp; 7714 child_process *cp;
7714 int fd = -1; 7715 int fd = -1;