diff options
| author | Paul Eggert | 2014-08-10 14:06:07 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-08-10 14:06:07 -0700 |
| commit | db2f09ab1be010a06a88269d39fb14c191452f1c (patch) | |
| tree | 9dff72ca6473a09b347605572ce004c4edbde58b /lib | |
| parent | f22bc725a1c8294fc042f6a9541be01a177755f6 (diff) | |
| download | emacs-db2f09ab1be010a06a88269d39fb14c191452f1c.tar.gz emacs-db2f09ab1be010a06a88269d39fb14c191452f1c.zip | |
Simplify previous patch.
Fixes: debbugs:18232
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/save-cwd.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/save-cwd.c b/lib/save-cwd.c index fd746584fa8..833783cbab0 100644 --- a/lib/save-cwd.c +++ b/lib/save-cwd.c | |||
| @@ -50,14 +50,14 @@ | |||
| 50 | you're still using an obsolete system with these problems, please | 50 | you're still using an obsolete system with these problems, please |
| 51 | send email to the maintainer of this code. */ | 51 | send email to the maintainer of this code. */ |
| 52 | 52 | ||
| 53 | #if !defined HAVE_FCHDIR && !defined fchdir | ||
| 54 | # define fchdir(fd) (-1) | ||
| 55 | #endif | ||
| 56 | |||
| 53 | int | 57 | int |
| 54 | save_cwd (struct saved_cwd *cwd) | 58 | save_cwd (struct saved_cwd *cwd) |
| 55 | { | 59 | { |
| 56 | #ifdef HAVE_FCHDIR | ||
| 57 | cwd->desc = open (".", O_SEARCH | O_CLOEXEC); | 60 | cwd->desc = open (".", O_SEARCH | O_CLOEXEC); |
| 58 | #else | ||
| 59 | cwd->desc = -1; | ||
| 60 | #endif | ||
| 61 | /* The 'name' member is present only to minimize differences from | 61 | /* The 'name' member is present only to minimize differences from |
| 62 | gnulib. Initialize it to zero, if only to simplify debugging. */ | 62 | gnulib. Initialize it to zero, if only to simplify debugging. */ |
| 63 | cwd->name = 0; | 63 | cwd->name = 0; |
| @@ -71,16 +71,14 @@ save_cwd (struct saved_cwd *cwd) | |||
| 71 | int | 71 | int |
| 72 | restore_cwd (const struct saved_cwd *cwd) | 72 | restore_cwd (const struct saved_cwd *cwd) |
| 73 | { | 73 | { |
| 74 | #ifdef HAVE_FCHDIR | ||
| 75 | /* Restore the previous directory if possible, to avoid tying down | 74 | /* Restore the previous directory if possible, to avoid tying down |
| 76 | the file system of the new directory (Bug#18232). */ | 75 | the file system of the new directory (Bug#18232). |
| 76 | Don't worry if fchdir fails, as Emacs doesn't care what the | ||
| 77 | working directory is. The fchdir call is inside an 'if' merely to | ||
| 78 | pacify compilers that complain if fchdir's return value is ignored. */ | ||
| 77 | if (fchdir (cwd->desc) == 0) | 79 | if (fchdir (cwd->desc) == 0) |
| 78 | return 0; | 80 | return 0; |
| 79 | 81 | ||
| 80 | /* Don't worry if fchdir fails, as Emacs doesn't care what the | ||
| 81 | working directory is. The fchdir call is inside an 'if' merely to | ||
| 82 | pacify compilers that complain if fchdir's return value is ignored. */ | ||
| 83 | #endif | ||
| 84 | return 0; | 82 | return 0; |
| 85 | } | 83 | } |
| 86 | 84 | ||