diff options
| author | Paul Eggert | 2013-07-16 21:37:27 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-07-16 21:37:27 -0700 |
| commit | b648c16370ca72e3b68678db41b29e62accb708c (patch) | |
| tree | a6d5dad9e4b7beb95c1957e56ca1498df93766e2 /src | |
| parent | b1dc4084264128eb303198f8b5cb6d70ee3b3034 (diff) | |
| download | emacs-b648c16370ca72e3b68678db41b29e62accb708c.tar.gz emacs-b648c16370ca72e3b68678db41b29e62accb708c.zip | |
A few more minor file errno-reporting bugs.
* callproc.c (Fcall_process):
* doc.c (Fsnarf_documentation):
* fileio.c (Frename_file, Fadd_name_to_file, Fmake_symbolic_link):
* process.c (set_socket_option):
Don't let a constructor trash errno.
* doc.c: Include <errno.h>.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/callproc.c | 6 | ||||
| -rw-r--r-- | src/doc.c | 7 | ||||
| -rw-r--r-- | src/fileio.c | 19 | ||||
| -rw-r--r-- | src/process.c | 7 |
5 files changed, 41 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 62529d8d778..23334449ef3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-07-17 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | A few more minor file errno-reporting bugs. | ||
| 4 | * callproc.c (Fcall_process): | ||
| 5 | * doc.c (Fsnarf_documentation): | ||
| 6 | * fileio.c (Frename_file, Fadd_name_to_file, Fmake_symbolic_link): | ||
| 7 | * process.c (set_socket_option): | ||
| 8 | Don't let a constructor trash errno. | ||
| 9 | * doc.c: Include <errno.h>. | ||
| 10 | |||
| 1 | 2013-07-16 Juanma Barranquero <lekktu@gmail.com> | 11 | 2013-07-16 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 12 | ||
| 3 | * w32fns.c (unwind_create_tip_frame): Fix declaration. | 13 | * w32fns.c (unwind_create_tip_frame): Fix declaration. |
diff --git a/src/callproc.c b/src/callproc.c index 85ebf449e43..e0040ada609 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -405,7 +405,11 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) * | |||
| 405 | 405 | ||
| 406 | filefd = emacs_open (SSDATA (infile), O_RDONLY, 0); | 406 | filefd = emacs_open (SSDATA (infile), O_RDONLY, 0); |
| 407 | if (filefd < 0) | 407 | if (filefd < 0) |
| 408 | report_file_error ("Opening process input file", DECODE_FILE (infile)); | 408 | { |
| 409 | int open_errno = errno; | ||
| 410 | report_file_errno ("Opening process input file", DECODE_FILE (infile), | ||
| 411 | open_errno); | ||
| 412 | } | ||
| 409 | 413 | ||
| 410 | if (STRINGP (output_file)) | 414 | if (STRINGP (output_file)) |
| 411 | { | 415 | { |
| @@ -21,6 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 21 | 21 | ||
| 22 | #include <config.h> | 22 | #include <config.h> |
| 23 | 23 | ||
| 24 | #include <errno.h> | ||
| 24 | #include <sys/types.h> | 25 | #include <sys/types.h> |
| 25 | #include <sys/file.h> /* Must be after sys/types.h for USG. */ | 26 | #include <sys/file.h> /* Must be after sys/types.h for USG. */ |
| 26 | #include <fcntl.h> | 27 | #include <fcntl.h> |
| @@ -609,7 +610,11 @@ the same file name is found in the `doc-directory'. */) | |||
| 609 | 610 | ||
| 610 | fd = emacs_open (name, O_RDONLY, 0); | 611 | fd = emacs_open (name, O_RDONLY, 0); |
| 611 | if (fd < 0) | 612 | if (fd < 0) |
| 612 | report_file_error ("Opening doc string file", build_string (name)); | 613 | { |
| 614 | int open_errno = errno; | ||
| 615 | report_file_errno ("Opening doc string file", build_string (name), | ||
| 616 | open_errno); | ||
| 617 | } | ||
| 613 | Vdoc_file_name = filename; | 618 | Vdoc_file_name = filename; |
| 614 | filled = 0; | 619 | filled = 0; |
| 615 | pos = 0; | 620 | pos = 0; |
diff --git a/src/fileio.c b/src/fileio.c index b74b0ca91c2..06a0db2316f 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -204,7 +204,9 @@ report_file_errno (char const *string, Lisp_Object name, int errorno) | |||
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | /* Signal a file-access failure that set errno. STRING describes the | 206 | /* Signal a file-access failure that set errno. STRING describes the |
| 207 | failure, NAME the file involved. */ | 207 | failure, NAME the file involved. When invoking this function, take |
| 208 | care to not use arguments such as build_string ("foo") that involve | ||
| 209 | side effects that may set errno. */ | ||
| 208 | 210 | ||
| 209 | void | 211 | void |
| 210 | report_file_error (char const *string, Lisp_Object name) | 212 | report_file_error (char const *string, Lisp_Object name) |
| @@ -2371,7 +2373,8 @@ This is what happens in interactive use with M-x. */) | |||
| 2371 | INTEGERP (ok_if_already_exists), 0, 0); | 2373 | INTEGERP (ok_if_already_exists), 0, 0); |
| 2372 | if (rename (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) | 2374 | if (rename (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) |
| 2373 | { | 2375 | { |
| 2374 | if (errno == EXDEV) | 2376 | int rename_errno = errno; |
| 2377 | if (rename_errno == EXDEV) | ||
| 2375 | { | 2378 | { |
| 2376 | ptrdiff_t count; | 2379 | ptrdiff_t count; |
| 2377 | symlink_target = Ffile_symlink_p (file); | 2380 | symlink_target = Ffile_symlink_p (file); |
| @@ -2397,7 +2400,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2397 | unbind_to (count, Qnil); | 2400 | unbind_to (count, Qnil); |
| 2398 | } | 2401 | } |
| 2399 | else | 2402 | else |
| 2400 | report_file_error ("Renaming", list2 (file, newname)); | 2403 | report_file_errno ("Renaming", list2 (file, newname), rename_errno); |
| 2401 | } | 2404 | } |
| 2402 | UNGCPRO; | 2405 | UNGCPRO; |
| 2403 | return Qnil; | 2406 | return Qnil; |
| @@ -2451,7 +2454,10 @@ This is what happens in interactive use with M-x. */) | |||
| 2451 | 2454 | ||
| 2452 | unlink (SSDATA (newname)); | 2455 | unlink (SSDATA (newname)); |
| 2453 | if (link (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) | 2456 | if (link (SSDATA (encoded_file), SSDATA (encoded_newname)) < 0) |
| 2454 | report_file_error ("Adding new name", list2 (file, newname)); | 2457 | { |
| 2458 | int link_errno = errno; | ||
| 2459 | report_file_errno ("Adding new name", list2 (file, newname), link_errno); | ||
| 2460 | } | ||
| 2455 | 2461 | ||
| 2456 | UNGCPRO; | 2462 | UNGCPRO; |
| 2457 | return Qnil; | 2463 | return Qnil; |
| @@ -2510,6 +2516,7 @@ This happens for interactive use with M-x. */) | |||
| 2510 | if (symlink (SSDATA (encoded_filename), SSDATA (encoded_linkname)) < 0) | 2516 | if (symlink (SSDATA (encoded_filename), SSDATA (encoded_linkname)) < 0) |
| 2511 | { | 2517 | { |
| 2512 | /* If we didn't complain already, silently delete existing file. */ | 2518 | /* If we didn't complain already, silently delete existing file. */ |
| 2519 | int symlink_errno; | ||
| 2513 | if (errno == EEXIST) | 2520 | if (errno == EEXIST) |
| 2514 | { | 2521 | { |
| 2515 | unlink (SSDATA (encoded_linkname)); | 2522 | unlink (SSDATA (encoded_linkname)); |
| @@ -2527,7 +2534,9 @@ This happens for interactive use with M-x. */) | |||
| 2527 | build_string ("Symbolic links are not supported")); | 2534 | build_string ("Symbolic links are not supported")); |
| 2528 | } | 2535 | } |
| 2529 | 2536 | ||
| 2530 | report_file_error ("Making symbolic link", list2 (filename, linkname)); | 2537 | symlink_errno = errno; |
| 2538 | report_file_errno ("Making symbolic link", list2 (filename, linkname), | ||
| 2539 | symlink_errno); | ||
| 2531 | } | 2540 | } |
| 2532 | UNGCPRO; | 2541 | UNGCPRO; |
| 2533 | return Qnil; | 2542 | return Qnil; |
diff --git a/src/process.c b/src/process.c index 42a625b7e55..7c63964aee6 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -2321,7 +2321,12 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val) | |||
| 2321 | } | 2321 | } |
| 2322 | 2322 | ||
| 2323 | if (ret < 0) | 2323 | if (ret < 0) |
| 2324 | report_file_error ("Cannot set network option", list2 (opt, val)); | 2324 | { |
| 2325 | int setsockopt_errno = errno; | ||
| 2326 | report_file_errno ("Cannot set network option", list2 (opt, val), | ||
| 2327 | setsockopt_errno); | ||
| 2328 | } | ||
| 2329 | |||
| 2325 | return (1 << sopt->optbit); | 2330 | return (1 << sopt->optbit); |
| 2326 | } | 2331 | } |
| 2327 | 2332 | ||