diff options
author | Andreas Gruenbacher <agruen@gnu.org> | 2015-02-28 14:00:42 +0100 |
---|---|---|
committer | Andreas Gruenbacher <agruen@gnu.org> | 2015-02-28 21:10:34 +0100 |
commit | c5da382c0baa822606236fe65527c027c1250822 (patch) | |
tree | b783161b57a4af2c31af90b5febdf5b61f04bd4e | |
parent | d55ab5b9416a8103dc90c4323261a0d5c58ee046 (diff) | |
download | patch-c5da382c0baa822606236fe65527c027c1250822.tar.gz |
Move error reporting out of make_tempfile()
* src/util.c (make_tempfile): Remove error reporting here.
* src/inp.c (plan_b): Readd error reporting here.
* src/patch.c (main): Likewise.
* src/pch.c (open_patch_file): Likewise.
-rw-r--r-- | src/inp.c | 2 | ||||
-rw-r--r-- | src/patch.c | 4 | ||||
-rw-r--r-- | src/pch.c | 5 | ||||
-rw-r--r-- | src/util.c | 2 |
4 files changed, 10 insertions, 3 deletions
@@ -365,6 +365,8 @@ plan_b (char const *filename) { tifd = make_tempfile (&TMPINNAME, 'i', NULL, O_RDWR | O_BINARY, S_IRUSR | S_IWUSR); + if (tifd == -1) + pfatal ("Can't create temporary file %s", TMPINNAME); TMPINNAME_needs_removal = true; } i = 0; diff --git a/src/patch.c b/src/patch.c index 6b41f79..42d0267 100644 --- a/src/patch.c +++ b/src/patch.c @@ -309,6 +309,8 @@ main (int argc, char **argv) outfd = make_tempfile (&TMPOUTNAME, 'o', outname, O_WRONLY | binary_transput, instat.st_mode & S_IRWXUGO); + if (outfd == -1) + pfatal ("Can't create temporary file %s", TMPOUTNAME); TMPOUTNAME_needs_removal = true; if (diff_type == ED_DIFF) { outstate.zero_output = false; @@ -1586,6 +1588,8 @@ init_reject (char const *outname) int fd; fd = make_tempfile (&TMPREJNAME, 'r', outname, O_WRONLY | binary_transput, 0666); + if (fd == -1) + pfatal ("Can't create temporary file %s", TMPREJNAME); TMPREJNAME_needs_removal = true; rejfp = fdopen (fd, binary_transput ? "wb" : "w"); if (! rejfp) @@ -138,8 +138,11 @@ open_patch_file (char const *filename) else { size_t charsread; - int fd = make_tempfile (&TMPPATNAME, 'p', NULL, O_RDWR | O_BINARY, 0); + int fd; FILE *read_pfp = pfp; + fd = make_tempfile (&TMPPATNAME, 'p', NULL, O_RDWR | O_BINARY, 0); + if (fd == -1) + pfatal ("Can't create temporary file %s", TMPPATNAME); TMPPATNAME_needs_removal = true; pfp = fdopen (fd, "w+b"); if (! pfp) @@ -1660,8 +1660,6 @@ make_tempfile (char const **name, char letter, char const *real_name, sprintf (template, "%s/p%cXXXXXX", tmpdir, letter); } fd = try_tempname(template, 0, &args, try_safe_open); - if (fd == -1) - pfatal ("Can't create temporary file %s", template); *name = template; return fd; } |