[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
minor removal of duplicate code and addition of != 0 in copy.c
From: |
Paul Eggert |
Subject: |
minor removal of duplicate code and addition of != 0 in copy.c |
Date: |
Wed, 18 Oct 2006 22:23:48 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
I installed this:
2006-10-18 Paul Eggert <address@hidden>
* src/copy.c (copy_reg): Rewrite slightly to avoid duplicte code
when opening dst_name.
(copy_reg, copy_internal): Use (SYSCALL != 0) rather than plain
(SYSCALL) to test for failure in a system call.
--- src/copy.c 18 Oct 2006 22:33:06 -0000 1.217
+++ src/copy.c 19 Oct 2006 05:21:08 -0000
@@ -260,7 +260,7 @@ copy_reg (char const *src_name, char con
return false;
}
- if (fstat (source_desc, &src_open_sb))
+ if (fstat (source_desc, &src_open_sb) != 0)
{
error (0, errno, _("cannot fstat %s"), quote (src_name));
return_val = false;
@@ -280,11 +280,7 @@ copy_reg (char const *src_name, char con
/* These semantics are required for cp.
The if-block will be taken in move_mode. */
- if (*new_dst)
- {
- dest_desc = open (dst_name, O_WRONLY | O_CREAT | O_BINARY, dst_mode);
- }
- else
+ if (! *new_dst)
{
dest_desc = open (dst_name, O_WRONLY | O_TRUNC | O_BINARY, dst_mode);
@@ -301,12 +297,12 @@ copy_reg (char const *src_name, char con
/* Tell caller that the destination file was unlinked. */
*new_dst = true;
-
- /* Try the open again, but this time with different flags. */
- dest_desc = open (dst_name, O_WRONLY | O_CREAT | O_BINARY, dst_mode);
}
}
+ if (*new_dst)
+ dest_desc = open (dst_name, O_WRONLY | O_CREAT | O_BINARY, dst_mode);
+
if (dest_desc < 0)
{
error (0, errno, _("cannot create regular file %s"), quote (dst_name));
@@ -314,7 +310,7 @@ copy_reg (char const *src_name, char con
goto close_src_desc;
}
- if (fstat (dest_desc, &sb))
+ if (fstat (dest_desc, &sb) != 0)
{
error (0, errno, _("cannot fstat %s"), quote (dst_name));
return_val = false;
@@ -1580,8 +1576,8 @@ copy_internal (char const *src_name, cha
/* If either stat call fails, it's ok not to report
the failure and say dst_name is in the current
directory. Other things will fail later. */
- || stat (".", &dot_sb)
- || stat (dst_parent, &dst_parent_sb)
+ || stat (".", &dot_sb) != 0
+ || stat (dst_parent, &dst_parent_sb) != 0
|| SAME_INODE (dot_sb, dst_parent_sb));
free (dst_parent);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- minor removal of duplicate code and addition of != 0 in copy.c,
Paul Eggert <=