-if ((dstfd =
- openat(ddfd, CCS filename, O_RDWR|O_CREAT|O_EXCL, SPOOL_MODE)) < 0)
- {
- addr->transport_return = DEFER;
- addr->basic_errno = errno;
- addr->message = string_sprintf("%s transport opening file: %s "
- "failed with error: %s", tb->name, dstpath, strerror(errno));
- return FALSE;
- }
-
-fchmod(dstfd, SPOOL_MODE);
-
-if (!(dst_file = fdopen(dstfd, "wb")))
- {
- addr->transport_return = DEFER;
- addr->basic_errno = errno;
- addr->message = string_sprintf("%s transport opening file fd: %s "
- "failed with error: %s", tb->name, dstpath, strerror(errno));
- (void) close(dstfd);
- return FALSE;
- }
-
-if (is_hdr_file)
- if ((srcfd = openat(sdfd, CCS filename, O_RDONLY)) < 0)
- {
- addr->basic_errno = errno;
- addr->message = string_sprintf("%s transport opening file: %s "
- "failed with error: %s", tb->name, srcpath, strerror(errno));
- goto bad;
- }
-
-if (!(src_file = fdopen(srcfd, "rb")))
- {
- addr->basic_errno = errno;
- addr->message = string_sprintf("%s transport opening file fd: "
- "%s failed with error: %s", tb->name, srcpath, strerror(errno));
- if (is_hdr_file) (void) close(srcfd);
- goto bad;
- }
-
-if (!copy_spool_file(dst_file, src_file))
- {
- addr->message = string_sprintf("%s transport creating file: "
- "%s failed with error: %s", tb->name, dstpath, strerror(errno));
- if (is_hdr_file) (void) fclose(src_file);
- goto bad;
- }
-
-if (is_hdr_file) (void) fclose(src_file);
-(void) fclose(dst_file);
-
-return TRUE;
-
-bad:
- addr->transport_return = DEFER;
- (void) fclose(dst_file);
- return FALSE;
+if ( (s = dstpath,
+ (dstfd = openat(ddfd, CCS filename, O_RDWR|O_CREAT|O_EXCL, SPOOL_MODE))
+ < 0
+ )
+ || is_hdr_file
+ && (s = srcpath, (srcfd = openat(sdfd, CCS filename, O_RDONLY)) < 0)
+ )
+ op = US"opening";
+
+else
+ if (s = dstpath, fchmod(dstfd, SPOOL_MODE) != 0)
+ op = US"setting perms on";
+ else
+ if (!copy_spool_file(dstfd, srcfd))
+ op = US"creating";
+ else
+ return TRUE;
+
+addr->basic_errno = errno;
+addr->message = string_sprintf("%s transport %s file: %s failed with error: %s",
+ tb->name, op, s, strerror(errno));
+addr->transport_return = DEFER;
+return FALSE;