aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-07-16 09:39:42 -0700
committerPaul Eggert2013-07-16 09:39:42 -0700
commita9757f6a03cce5ff2931b1125a9a2249573c8e1c (patch)
tree540a3b5b9e4fc657ed85749d5ef10b5a125ce1c3 /src
parentc43843aa1ad80cc0e4f6dc2ab523727b10b10a22 (diff)
downloademacs-a9757f6a03cce5ff2931b1125a9a2249573c8e1c.tar.gz
emacs-a9757f6a03cce5ff2931b1125a9a2249573c8e1c.zip
* fileio.c (report_file_errno): Fix errno reporting bug.
If the file name is neither null nor a pair, package it up as a singleton list. All callers changed, both to this function and to report_file_error. This fixes a bug where the memory allocator invoked by list1 set errno so that the immediately following report_file_error reported the wrong errno value.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/callproc.c19
-rw-r--r--src/dired.c4
-rw-r--r--src/dispnew.c2
-rw-r--r--src/doc.c2
-rw-r--r--src/fileio.c92
-rw-r--r--src/gfilenotify.c2
-rw-r--r--src/keyboard.c2
-rw-r--r--src/print.c3
-rw-r--r--src/process.c8
-rw-r--r--src/unexaix.c2
-rw-r--r--src/unexcoff.c2
12 files changed, 74 insertions, 71 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3f597ec63b1..0c96e4b901b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
12013-07-16 Paul Eggert <eggert@cs.ucla.edu> 12013-07-16 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * 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
5 singleton list. All callers changed, both to this function and to
6 report_file_error. This fixes a bug where the memory allocator
7 invoked by list1 set errno so that the immediately following
8 report_file_error reported the wrong errno value.
9
3 Fix minor problems found by --enable-gcc-warnings. 10 Fix minor problems found by --enable-gcc-warnings.
4 * frame.c (Fhandle_focus_in, Fhandle_focus_out): Return a value. 11 * frame.c (Fhandle_focus_in, Fhandle_focus_out): Return a value.
5 * keyboard.c (kbd_buffer_get_event): Remove unused local. 12 * keyboard.c (kbd_buffer_get_event): Remove unused local.
diff --git a/src/callproc.c b/src/callproc.c
index facaac60f2a..f53750372d5 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -392,7 +392,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
392 392
393 if (NILP (Ffile_accessible_directory_p (current_dir))) 393 if (NILP (Ffile_accessible_directory_p (current_dir)))
394 report_file_error ("Setting current directory", 394 report_file_error ("Setting current directory",
395 list1 (BVAR (current_buffer, directory))); 395 BVAR (current_buffer, directory));
396 396
397 if (STRING_MULTIBYTE (infile)) 397 if (STRING_MULTIBYTE (infile))
398 infile = ENCODE_FILE (infile); 398 infile = ENCODE_FILE (infile);
@@ -409,8 +409,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
409 409
410 filefd = emacs_open (SSDATA (infile), O_RDONLY, 0); 410 filefd = emacs_open (SSDATA (infile), O_RDONLY, 0);
411 if (filefd < 0) 411 if (filefd < 0)
412 report_file_error ("Opening process input file", 412 report_file_error ("Opening process input file", DECODE_FILE (infile));
413 list1 (DECODE_FILE (infile)));
414 413
415 if (STRINGP (output_file)) 414 if (STRINGP (output_file))
416 { 415 {
@@ -422,7 +421,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
422 int open_errno = errno; 421 int open_errno = errno;
423 output_file = DECODE_FILE (output_file); 422 output_file = DECODE_FILE (output_file);
424 report_file_errno ("Opening process output file", 423 report_file_errno ("Opening process output file",
425 list1 (output_file), open_errno); 424 output_file, open_errno);
426 } 425 }
427 if (STRINGP (error_file) || NILP (error_file)) 426 if (STRINGP (error_file) || NILP (error_file))
428 output_to_buffer = 0; 427 output_to_buffer = 0;
@@ -440,8 +439,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
440 { 439 {
441 int openp_errno = errno; 440 int openp_errno = errno;
442 emacs_close (filefd); 441 emacs_close (filefd);
443 report_file_errno ("Searching for program", 442 report_file_errno ("Searching for program", args[0], openp_errno);
444 list1 (args[0]), openp_errno);
445 } 443 }
446 } 444 }
447 445
@@ -506,7 +504,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
506 int open_errno = errno; 504 int open_errno = errno;
507 emacs_close (filefd); 505 emacs_close (filefd);
508 report_file_errno ("Opening process output file", 506 report_file_errno ("Opening process output file",
509 list1 (build_string (tempfile)), open_errno); 507 build_string (tempfile), open_errno);
510 } 508 }
511 } 509 }
512 else 510 else
@@ -563,8 +561,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
563 error_file = build_string (NULL_DEVICE); 561 error_file = build_string (NULL_DEVICE);
564 else if (STRINGP (error_file)) 562 else if (STRINGP (error_file))
565 error_file = DECODE_FILE (error_file); 563 error_file = DECODE_FILE (error_file);
566 report_file_errno ("Cannot redirect stderr", 564 report_file_errno ("Cannot redirect stderr", error_file, open_errno);
567 list1 (error_file), open_errno);
568 } 565 }
569 566
570#ifdef MSDOS /* MW, July 1993 */ 567#ifdef MSDOS /* MW, July 1993 */
@@ -596,7 +593,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
596 unlink (tempfile); 593 unlink (tempfile);
597 emacs_close (filefd); 594 emacs_close (filefd);
598 report_file_errno ("Cannot re-open temporary file", 595 report_file_errno ("Cannot re-open temporary file",
599 list1 (build_string (tempfile)), open_errno); 596 build_string (tempfile), open_errno);
600 } 597 }
601 } 598 }
602 else 599 else
@@ -1027,7 +1024,7 @@ create_temp_file (ptrdiff_t nargs, Lisp_Object *args)
1027#endif 1024#endif
1028 if (fd < 0) 1025 if (fd < 0)
1029 report_file_error ("Failed to open temporary file using pattern", 1026 report_file_error ("Failed to open temporary file using pattern",
1030 list1 (pattern)); 1027 pattern);
1031 emacs_close (fd); 1028 emacs_close (fd);
1032 } 1029 }
1033 1030
diff --git a/src/dired.c b/src/dired.c
index ecce47ab415..42baa915348 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -185,7 +185,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
185 185
186 d = open_directory (SSDATA (dirfilename), &fd); 186 d = open_directory (SSDATA (dirfilename), &fd);
187 if (d == NULL) 187 if (d == NULL)
188 report_file_error ("Opening directory", list1 (directory)); 188 report_file_error ("Opening directory", directory);
189 189
190 /* Unfortunately, we can now invoke expand-file-name and 190 /* Unfortunately, we can now invoke expand-file-name and
191 file-attributes on filenames, both of which can throw, so we must 191 file-attributes on filenames, both of which can throw, so we must
@@ -488,7 +488,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
488 488
489 d = open_directory (SSDATA (encoded_dir), &fd); 489 d = open_directory (SSDATA (encoded_dir), &fd);
490 if (!d) 490 if (!d)
491 report_file_error ("Opening directory", list1 (dirname)); 491 report_file_error ("Opening directory", dirname);
492 492
493 record_unwind_protect (directory_files_internal_unwind, 493 record_unwind_protect (directory_files_internal_unwind,
494 make_save_pointer (d)); 494 make_save_pointer (d));
diff --git a/src/dispnew.c b/src/dispnew.c
index 89496304baf..ef75ed6d176 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5619,7 +5619,7 @@ FILE = nil means just close any termscript file currently open. */)
5619 file = Fexpand_file_name (file, Qnil); 5619 file = Fexpand_file_name (file, Qnil);
5620 tty->termscript = emacs_fopen (SSDATA (file), "w"); 5620 tty->termscript = emacs_fopen (SSDATA (file), "w");
5621 if (tty->termscript == 0) 5621 if (tty->termscript == 0)
5622 report_file_error ("Opening termscript", list1 (file)); 5622 report_file_error ("Opening termscript", file);
5623 } 5623 }
5624 return Qnil; 5624 return Qnil;
5625} 5625}
diff --git a/src/doc.c b/src/doc.c
index 04af74102ef..92c7b2c6dc9 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -609,7 +609,7 @@ the same file name is found in the `doc-directory'. */)
609 609
610 fd = emacs_open (name, O_RDONLY, 0); 610 fd = emacs_open (name, O_RDONLY, 0);
611 if (fd < 0) 611 if (fd < 0)
612 report_file_error ("Opening doc string file", list1 (build_string (name))); 612 report_file_error ("Opening doc string file", build_string (name));
613 Vdoc_file_name = filename; 613 Vdoc_file_name = filename;
614 filled = 0; 614 filled = 0;
615 pos = 0; 615 pos = 0;
diff --git a/src/fileio.c b/src/fileio.c
index b87455d151e..ae9c15a0164 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -160,11 +160,16 @@ static bool e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t,
160 160
161 161
162/* Signal a file-access failure. STRING describes the failure, 162/* Signal a file-access failure. STRING describes the failure,
163 DATA the file that was involved, and ERRORNO the errno value. */ 163 NAME the file involved, and ERRORNO the errno value.
164
165 If NAME is neither null nor a pair, package it up as a singleton
166 list before reporting it; this saves report_file_errno's caller the
167 trouble of preserving errno before calling list1. */
164 168
165void 169void
166report_file_errno (char const *string, Lisp_Object data, int errorno) 170report_file_errno (char const *string, Lisp_Object name, int errorno)
167{ 171{
172 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
168 Lisp_Object errstring; 173 Lisp_Object errstring;
169 char *str; 174 char *str;
170 175
@@ -198,10 +203,13 @@ report_file_errno (char const *string, Lisp_Object data, int errorno)
198 } 203 }
199} 204}
200 205
206/* Signal a file-access failure that set errno. STRING describes the
207 failure, NAME the file involved. */
208
201void 209void
202report_file_error (char const *string, Lisp_Object data) 210report_file_error (char const *string, Lisp_Object name)
203{ 211{
204 report_file_errno (string, data, errno); 212 report_file_errno (string, name, errno);
205} 213}
206 214
207Lisp_Object 215Lisp_Object
@@ -749,7 +757,7 @@ make_temp_name (Lisp_Object prefix, bool base64_p)
749 dog-slow, but also useless since eventually nil would 757 dog-slow, but also useless since eventually nil would
750 have to be returned anyway. */ 758 have to be returned anyway. */
751 report_file_error ("Cannot create temporary name for prefix", 759 report_file_error ("Cannot create temporary name for prefix",
752 list1 (prefix)); 760 prefix);
753 /* not reached */ 761 /* not reached */
754 } 762 }
755 } 763 }
@@ -2019,7 +2027,7 @@ entries (depending on how Emacs was built). */)
2019 { 2027 {
2020 acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS); 2028 acl = acl_get_file (SDATA (encoded_file), ACL_TYPE_ACCESS);
2021 if (acl == NULL && acl_errno_valid (errno)) 2029 if (acl == NULL && acl_errno_valid (errno))
2022 report_file_error ("Getting ACL", list1 (file)); 2030 report_file_error ("Getting ACL", file);
2023 } 2031 }
2024 if (!CopyFile (SDATA (encoded_file), 2032 if (!CopyFile (SDATA (encoded_file),
2025 SDATA (encoded_newname), 2033 SDATA (encoded_newname),
@@ -2058,7 +2066,7 @@ entries (depending on how Emacs was built). */)
2058 bool fail = 2066 bool fail =
2059 acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0; 2067 acl_set_file (SDATA (encoded_newname), ACL_TYPE_ACCESS, acl) != 0;
2060 if (fail && acl_errno_valid (errno)) 2068 if (fail && acl_errno_valid (errno))
2061 report_file_error ("Setting ACL", list1 (newname)); 2069 report_file_error ("Setting ACL", newname);
2062 2070
2063 acl_free (acl); 2071 acl_free (acl);
2064 } 2072 }
@@ -2068,12 +2076,12 @@ entries (depending on how Emacs was built). */)
2068 immediate_quit = 0; 2076 immediate_quit = 0;
2069 2077
2070 if (ifd < 0) 2078 if (ifd < 0)
2071 report_file_error ("Opening input file", list1 (file)); 2079 report_file_error ("Opening input file", file);
2072 2080
2073 record_unwind_protect (close_file_unwind, make_number (ifd)); 2081 record_unwind_protect (close_file_unwind, make_number (ifd));
2074 2082
2075 if (fstat (ifd, &st) != 0) 2083 if (fstat (ifd, &st) != 0)
2076 report_file_error ("Input file status", list1 (file)); 2084 report_file_error ("Input file status", file);
2077 2085
2078 if (!NILP (preserve_extended_attributes)) 2086 if (!NILP (preserve_extended_attributes))
2079 { 2087 {
@@ -2082,7 +2090,7 @@ entries (depending on how Emacs was built). */)
2082 { 2090 {
2083 conlength = fgetfilecon (ifd, &con); 2091 conlength = fgetfilecon (ifd, &con);
2084 if (conlength == -1) 2092 if (conlength == -1)
2085 report_file_error ("Doing fgetfilecon", list1 (file)); 2093 report_file_error ("Doing fgetfilecon", file);
2086 } 2094 }
2087#endif 2095#endif
2088 } 2096 }
@@ -2094,7 +2102,7 @@ entries (depending on how Emacs was built). */)
2094 2102
2095 /* We can copy only regular files. */ 2103 /* We can copy only regular files. */
2096 if (!S_ISREG (st.st_mode)) 2104 if (!S_ISREG (st.st_mode))
2097 report_file_errno ("Non-regular file", list1 (file), 2105 report_file_errno ("Non-regular file", file,
2098 S_ISDIR (st.st_mode) ? EISDIR : EINVAL); 2106 S_ISDIR (st.st_mode) ? EISDIR : EINVAL);
2099 2107
2100 { 2108 {
@@ -2109,7 +2117,7 @@ entries (depending on how Emacs was built). */)
2109 new_mask); 2117 new_mask);
2110 } 2118 }
2111 if (ofd < 0) 2119 if (ofd < 0)
2112 report_file_error ("Opening output file", list1 (newname)); 2120 report_file_error ("Opening output file", newname);
2113 2121
2114 record_unwind_protect (close_file_unwind, make_number (ofd)); 2122 record_unwind_protect (close_file_unwind, make_number (ofd));
2115 2123
@@ -2117,7 +2125,7 @@ entries (depending on how Emacs was built). */)
2117 QUIT; 2125 QUIT;
2118 while ((n = emacs_read (ifd, buf, sizeof buf)) > 0) 2126 while ((n = emacs_read (ifd, buf, sizeof buf)) > 0)
2119 if (emacs_write_sig (ofd, buf, n) != n) 2127 if (emacs_write_sig (ofd, buf, n) != n)
2120 report_file_error ("I/O error", list1 (newname)); 2128 report_file_error ("I/O error", newname);
2121 immediate_quit = 0; 2129 immediate_quit = 0;
2122 2130
2123#ifndef MSDOS 2131#ifndef MSDOS
@@ -2145,8 +2153,8 @@ entries (depending on how Emacs was built). */)
2145 st.st_mode & mode_mask) 2153 st.st_mode & mode_mask)
2146 : fchmod (ofd, st.st_mode & mode_mask)) 2154 : fchmod (ofd, st.st_mode & mode_mask))
2147 { 2155 {
2148 case -2: report_file_error ("Copying permissions from", list1 (file)); 2156 case -2: report_file_error ("Copying permissions from", file);
2149 case -1: report_file_error ("Copying permissions to", list1 (newname)); 2157 case -1: report_file_error ("Copying permissions to", newname);
2150 } 2158 }
2151 } 2159 }
2152#endif /* not MSDOS */ 2160#endif /* not MSDOS */
@@ -2158,7 +2166,7 @@ entries (depending on how Emacs was built). */)
2158 bool fail = fsetfilecon (ofd, con) != 0; 2166 bool fail = fsetfilecon (ofd, con) != 0;
2159 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ 2167 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */
2160 if (fail && errno != ENOTSUP) 2168 if (fail && errno != ENOTSUP)
2161 report_file_error ("Doing fsetfilecon", list1 (newname)); 2169 report_file_error ("Doing fsetfilecon", newname);
2162 2170
2163 freecon (con); 2171 freecon (con);
2164 } 2172 }
@@ -2174,7 +2182,7 @@ entries (depending on how Emacs was built). */)
2174 } 2182 }
2175 2183
2176 if (emacs_close (ofd) < 0) 2184 if (emacs_close (ofd) < 0)
2177 report_file_error ("I/O error", list1 (newname)); 2185 report_file_error ("I/O error", newname);
2178 2186
2179 emacs_close (ifd); 2187 emacs_close (ifd);
2180 2188
@@ -2220,7 +2228,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal,
2220#else 2228#else
2221 if (mkdir (dir, 0777 & ~auto_saving_dir_umask) != 0) 2229 if (mkdir (dir, 0777 & ~auto_saving_dir_umask) != 0)
2222#endif 2230#endif
2223 report_file_error ("Creating directory", list1 (directory)); 2231 report_file_error ("Creating directory", directory);
2224 2232
2225 return Qnil; 2233 return Qnil;
2226} 2234}
@@ -2239,7 +2247,7 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal,
2239 dir = SSDATA (encoded_dir); 2247 dir = SSDATA (encoded_dir);
2240 2248
2241 if (rmdir (dir) != 0) 2249 if (rmdir (dir) != 0)
2242 report_file_error ("Removing directory", list1 (directory)); 2250 report_file_error ("Removing directory", directory);
2243 2251
2244 return Qnil; 2252 return Qnil;
2245} 2253}
@@ -2282,7 +2290,7 @@ With a prefix argument, TRASH is nil. */)
2282 encoded_file = ENCODE_FILE (filename); 2290 encoded_file = ENCODE_FILE (filename);
2283 2291
2284 if (unlink (SSDATA (encoded_file)) < 0) 2292 if (unlink (SSDATA (encoded_file)) < 0)
2285 report_file_error ("Removing old name", list1 (filename)); 2293 report_file_error ("Removing old name", filename);
2286 return Qnil; 2294 return Qnil;
2287} 2295}
2288 2296
@@ -2719,7 +2727,7 @@ If there is no error, returns nil. */)
2719 encoded_filename = ENCODE_FILE (absname); 2727 encoded_filename = ENCODE_FILE (absname);
2720 2728
2721 if (faccessat (AT_FDCWD, SSDATA (encoded_filename), R_OK, AT_EACCESS) != 0) 2729 if (faccessat (AT_FDCWD, SSDATA (encoded_filename), R_OK, AT_EACCESS) != 0)
2722 report_file_error (SSDATA (string), list1 (filename)); 2730 report_file_error (SSDATA (string), filename);
2723 2731
2724 return Qnil; 2732 return Qnil;
2725} 2733}
@@ -3054,14 +3062,14 @@ or if Emacs was not compiled with SELinux support. */)
3054 != 0); 3062 != 0);
3055 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ 3063 /* See http://debbugs.gnu.org/11245 for ENOTSUP. */
3056 if (fail && errno != ENOTSUP) 3064 if (fail && errno != ENOTSUP)
3057 report_file_error ("Doing lsetfilecon", list1 (absname)); 3065 report_file_error ("Doing lsetfilecon", absname);
3058 3066
3059 context_free (parsed_con); 3067 context_free (parsed_con);
3060 freecon (con); 3068 freecon (con);
3061 return fail ? Qnil : Qt; 3069 return fail ? Qnil : Qt;
3062 } 3070 }
3063 else 3071 else
3064 report_file_error ("Doing lgetfilecon", list1 (absname)); 3072 report_file_error ("Doing lgetfilecon", absname);
3065 } 3073 }
3066#endif 3074#endif
3067 3075
@@ -3151,7 +3159,7 @@ support. */)
3151 acl = acl_from_text (SSDATA (acl_string)); 3159 acl = acl_from_text (SSDATA (acl_string));
3152 if (acl == NULL) 3160 if (acl == NULL)
3153 { 3161 {
3154 report_file_error ("Converting ACL", list1 (absname)); 3162 report_file_error ("Converting ACL", absname);
3155 return Qnil; 3163 return Qnil;
3156 } 3164 }
3157 3165
@@ -3161,7 +3169,7 @@ support. */)
3161 acl) 3169 acl)
3162 != 0); 3170 != 0);
3163 if (fail && acl_errno_valid (errno)) 3171 if (fail && acl_errno_valid (errno))
3164 report_file_error ("Setting ACL", list1 (absname)); 3172 report_file_error ("Setting ACL", absname);
3165 3173
3166 acl_free (acl); 3174 acl_free (acl);
3167 return fail ? Qnil : Qt; 3175 return fail ? Qnil : Qt;
@@ -3221,7 +3229,7 @@ symbolic notation, like the `chmod' command from GNU Coreutils. */)
3221 encoded_absname = ENCODE_FILE (absname); 3229 encoded_absname = ENCODE_FILE (absname);
3222 3230
3223 if (chmod (SSDATA (encoded_absname), XINT (mode) & 07777) < 0) 3231 if (chmod (SSDATA (encoded_absname), XINT (mode) & 07777) < 0)
3224 report_file_error ("Doing chmod", list1 (absname)); 3232 report_file_error ("Doing chmod", absname);
3225 3233
3226 return Qnil; 3234 return Qnil;
3227} 3235}
@@ -3287,7 +3295,7 @@ Use the current time if TIMESTAMP is nil. TIMESTAMP is in the format of
3287 if (file_directory_p (SSDATA (encoded_absname))) 3295 if (file_directory_p (SSDATA (encoded_absname)))
3288 return Qnil; 3296 return Qnil;
3289#endif 3297#endif
3290 report_file_error ("Setting file times", list1 (absname)); 3298 report_file_error ("Setting file times", absname);
3291 } 3299 }
3292 } 3300 }
3293 3301
@@ -3553,7 +3561,7 @@ by calling `format-decode', which see. */)
3553 { 3561 {
3554 save_errno = errno; 3562 save_errno = errno;
3555 if (NILP (visit)) 3563 if (NILP (visit))
3556 report_file_error ("Opening input file", list1 (orig_filename)); 3564 report_file_error ("Opening input file", orig_filename);
3557 mtime = time_error_value (save_errno); 3565 mtime = time_error_value (save_errno);
3558 st.st_size = -1; 3566 st.st_size = -1;
3559 if (!NILP (Vcoding_system_for_read)) 3567 if (!NILP (Vcoding_system_for_read))
@@ -3568,7 +3576,7 @@ by calling `format-decode', which see. */)
3568 record_unwind_protect (close_file_unwind, make_number (fd)); 3576 record_unwind_protect (close_file_unwind, make_number (fd));
3569 3577
3570 if (fstat (fd, &st) != 0) 3578 if (fstat (fd, &st) != 0)
3571 report_file_error ("Input file status", list1 (orig_filename)); 3579 report_file_error ("Input file status", orig_filename);
3572 mtime = get_stat_mtime (&st); 3580 mtime = get_stat_mtime (&st);
3573 3581
3574 /* This code will need to be changed in order to work on named 3582 /* This code will need to be changed in order to work on named
@@ -3682,7 +3690,7 @@ by calling `format-decode', which see. */)
3682 int ntail; 3690 int ntail;
3683 if (lseek (fd, - (1024 * 3), SEEK_END) < 0) 3691 if (lseek (fd, - (1024 * 3), SEEK_END) < 0)
3684 report_file_error ("Setting file position", 3692 report_file_error ("Setting file position",
3685 list1 (orig_filename)); 3693 orig_filename);
3686 ntail = emacs_read (fd, read_buf + nread, 1024 * 3); 3694 ntail = emacs_read (fd, read_buf + nread, 1024 * 3);
3687 nread = ntail < 0 ? ntail : nread + ntail; 3695 nread = ntail < 0 ? ntail : nread + ntail;
3688 } 3696 }
@@ -3726,8 +3734,7 @@ by calling `format-decode', which see. */)
3726 3734
3727 /* Rewind the file for the actual read done later. */ 3735 /* Rewind the file for the actual read done later. */
3728 if (lseek (fd, 0, SEEK_SET) < 0) 3736 if (lseek (fd, 0, SEEK_SET) < 0)
3729 report_file_error ("Setting file position", 3737 report_file_error ("Setting file position", orig_filename);
3730 list1 (orig_filename));
3731 } 3738 }
3732 } 3739 }
3733 3740
@@ -3793,8 +3800,7 @@ by calling `format-decode', which see. */)
3793 if (beg_offset != 0) 3800 if (beg_offset != 0)
3794 { 3801 {
3795 if (lseek (fd, beg_offset, SEEK_SET) < 0) 3802 if (lseek (fd, beg_offset, SEEK_SET) < 0)
3796 report_file_error ("Setting file position", 3803 report_file_error ("Setting file position", orig_filename);
3797 list1 (orig_filename));
3798 } 3804 }
3799 3805
3800 immediate_quit = 1; 3806 immediate_quit = 1;
@@ -3866,8 +3872,7 @@ by calling `format-decode', which see. */)
3866 /* How much can we scan in the next step? */ 3872 /* How much can we scan in the next step? */
3867 trial = min (curpos, sizeof read_buf); 3873 trial = min (curpos, sizeof read_buf);
3868 if (lseek (fd, curpos - trial, SEEK_SET) < 0) 3874 if (lseek (fd, curpos - trial, SEEK_SET) < 0)
3869 report_file_error ("Setting file position", 3875 report_file_error ("Setting file position", orig_filename);
3870 list1 (orig_filename));
3871 3876
3872 total_read = nread = 0; 3877 total_read = nread = 0;
3873 while (total_read < trial) 3878 while (total_read < trial)
@@ -3987,8 +3992,7 @@ by calling `format-decode', which see. */)
3987 CONVERSION_BUFFER. */ 3992 CONVERSION_BUFFER. */
3988 3993
3989 if (lseek (fd, beg_offset, SEEK_SET) < 0) 3994 if (lseek (fd, beg_offset, SEEK_SET) < 0)
3990 report_file_error ("Setting file position", 3995 report_file_error ("Setting file position", orig_filename);
3991 list1 (orig_filename));
3992 3996
3993 inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ 3997 inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */
3994 unprocessed = 0; /* Bytes not processed in previous loop. */ 3998 unprocessed = 0; /* Bytes not processed in previous loop. */
@@ -4168,8 +4172,7 @@ by calling `format-decode', which see. */)
4168 if (beg_offset != 0 || !NILP (replace)) 4172 if (beg_offset != 0 || !NILP (replace))
4169 { 4173 {
4170 if (lseek (fd, beg_offset, SEEK_SET) < 0) 4174 if (lseek (fd, beg_offset, SEEK_SET) < 0)
4171 report_file_error ("Setting file position", 4175 report_file_error ("Setting file position", orig_filename);
4172 list1 (orig_filename));
4173 } 4176 }
4174 4177
4175 /* In the following loop, HOW_MUCH contains the total bytes read so 4178 /* In the following loop, HOW_MUCH contains the total bytes read so
@@ -4574,8 +4577,7 @@ by calling `format-decode', which see. */)
4574 && EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS) 4577 && EMACS_NSECS (current_buffer->modtime) == NONEXISTENT_MODTIME_NSECS)
4575 { 4578 {
4576 /* If visiting nonexistent file, return nil. */ 4579 /* If visiting nonexistent file, return nil. */
4577 report_file_errno ("Opening input file", list1 (orig_filename), 4580 report_file_errno ("Opening input file", orig_filename, save_errno);
4578 save_errno);
4579 } 4581 }
4580 4582
4581 if (read_quit) 4583 if (read_quit)
@@ -4901,8 +4903,7 @@ This calls `write-region-annotate-functions' at the start, and
4901 if (!auto_saving) unlock_file (lockname); 4903 if (!auto_saving) unlock_file (lockname);
4902#endif /* CLASH_DETECTION */ 4904#endif /* CLASH_DETECTION */
4903 UNGCPRO; 4905 UNGCPRO;
4904 report_file_errno ("Opening output file", list1 (filename), 4906 report_file_errno ("Opening output file", filename, open_errno);
4905 open_errno);
4906 } 4907 }
4907 4908
4908 record_unwind_protect (close_file_unwind, make_number (desc)); 4909 record_unwind_protect (close_file_unwind, make_number (desc));
@@ -4917,8 +4918,7 @@ This calls `write-region-annotate-functions' at the start, and
4917 if (!auto_saving) unlock_file (lockname); 4918 if (!auto_saving) unlock_file (lockname);
4918#endif /* CLASH_DETECTION */ 4919#endif /* CLASH_DETECTION */
4919 UNGCPRO; 4920 UNGCPRO;
4920 report_file_errno ("Lseek error", list1 (filename), 4921 report_file_errno ("Lseek error", filename, lseek_errno);
4921 lseek_errno);
4922 } 4922 }
4923 } 4923 }
4924 4924
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 47b645bc075..8f13c72df81 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -173,7 +173,7 @@ will be reported only in case of the 'moved' event. */)
173 CHECK_STRING (file); 173 CHECK_STRING (file);
174 file = Fdirectory_file_name (Fexpand_file_name (file, Qnil)); 174 file = Fdirectory_file_name (Fexpand_file_name (file, Qnil));
175 if (NILP (Ffile_exists_p (file))) 175 if (NILP (Ffile_exists_p (file)))
176 report_file_error ("File does not exist", list1 (file)); 176 report_file_error ("File does not exist", file);
177 177
178 CHECK_LIST (flags); 178 CHECK_LIST (flags);
179 179
diff --git a/src/keyboard.c b/src/keyboard.c
index e852fb65cdd..e67da06ec23 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10128,7 +10128,7 @@ The file will be closed when Emacs exits. */)
10128 file = Fexpand_file_name (file, Qnil); 10128 file = Fexpand_file_name (file, Qnil);
10129 dribble = emacs_fopen (SSDATA (file), "w"); 10129 dribble = emacs_fopen (SSDATA (file), "w");
10130 if (dribble == 0) 10130 if (dribble == 0)
10131 report_file_error ("Opening dribble", list1 (file)); 10131 report_file_error ("Opening dribble", file);
10132 } 10132 }
10133 return Qnil; 10133 return Qnil;
10134} 10134}
diff --git a/src/print.c b/src/print.c
index 464fd459320..55659414b05 100644
--- a/src/print.c
+++ b/src/print.c
@@ -770,8 +770,7 @@ append to existing target file. */)
770 { 770 {
771 stderr = initial_stderr_stream; 771 stderr = initial_stderr_stream;
772 initial_stderr_stream = NULL; 772 initial_stderr_stream = NULL;
773 report_file_error ("Cannot open debugging output stream", 773 report_file_error ("Cannot open debugging output stream", file);
774 list1 (file));
775 } 774 }
776 } 775 }
777 return Qnil; 776 return Qnil;
diff --git a/src/process.c b/src/process.c
index 125a9389341..b51e3bab033 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1397,7 +1397,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1397 current_dir = expand_and_dir_to_file (current_dir, Qnil); 1397 current_dir = expand_and_dir_to_file (current_dir, Qnil);
1398 if (NILP (Ffile_accessible_directory_p (current_dir))) 1398 if (NILP (Ffile_accessible_directory_p (current_dir)))
1399 report_file_error ("Setting current directory", 1399 report_file_error ("Setting current directory",
1400 list1 (BVAR (current_buffer, directory))); 1400 BVAR (current_buffer, directory));
1401 1401
1402 UNGCPRO; 1402 UNGCPRO;
1403 } 1403 }
@@ -1519,7 +1519,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1519 openp (Vexec_path, program, Vexec_suffixes, &tem, make_number (X_OK)); 1519 openp (Vexec_path, program, Vexec_suffixes, &tem, make_number (X_OK));
1520 UNGCPRO; 1520 UNGCPRO;
1521 if (NILP (tem)) 1521 if (NILP (tem))
1522 report_file_error ("Searching for program", list1 (program)); 1522 report_file_error ("Searching for program", program);
1523 tem = Fexpand_file_name (tem, Qnil); 1523 tem = Fexpand_file_name (tem, Qnil);
1524 } 1524 }
1525 else 1525 else
@@ -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", list1 (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", list1 (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;
diff --git a/src/unexaix.c b/src/unexaix.c
index f97de45449e..fc1acc9ab4f 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -97,7 +97,7 @@ report_error (const char *file, int fd)
97 int err = errno; 97 int err = errno;
98 if (fd) 98 if (fd)
99 emacs_close (fd); 99 emacs_close (fd);
100 report_file_errno ("Cannot unexec", list1 (build_string (file)), err); 100 report_file_errno ("Cannot unexec", build_string (file), err);
101} 101}
102 102
103#define ERROR0(msg) report_error_1 (new, msg) 103#define ERROR0(msg) report_error_1 (new, msg)
diff --git a/src/unexcoff.c b/src/unexcoff.c
index 0b45d729710..5ac8ea8c9b0 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -130,7 +130,7 @@ report_error (const char *file, int fd)
130 int err = errno; 130 int err = errno;
131 if (fd) 131 if (fd)
132 emacs_close (fd); 132 emacs_close (fd);
133 report_file_errno ("Cannot unexec", list1 (build_string (file)), err); 133 report_file_errno ("Cannot unexec", build_string (file), err);
134} 134}
135 135
136#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 136#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1