[PATCH] objcopy should delete its output on error

Jan Beulich JBeulich@novell.com
Tue Apr 26 14:00:00 GMT 2005


Built and tested on i686-pc-linux-gnu.

Jan

binutils/
2005-04-26  Jan Beulich  <jbeulich@novell.com>

	* objcopy.c (copy_file): Don't delete output upon error here.
	(copy_main): Delete output upon error.

--- /home/jbeulich/src/binutils/mainline/2005-04-26/binutils/objcopy.c	2005-04-26 15:08:08.000000000 +0200
+++ 2005-04-26/binutils/objcopy.c	2005-04-26 15:43:14.000000000 +0200
@@ -1731,7 +1731,6 @@ copy_file (const char *input_filename, c
   else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching))
     {
       bfd *obfd;
-      bfd_boolean delete;
     do_copy:
 
       /* bfd_get_target does not return the correct value until
@@ -1743,7 +1742,8 @@ copy_file (const char *input_filename, c
       if (obfd == NULL)
 	RETURN_NONFATAL (output_filename);
 
-      delete = ! copy_object (ibfd, obfd);
+      if (! copy_object (ibfd, obfd))
+	status = 1;
 
       if (!bfd_close (obfd))
 	RETURN_NONFATAL (output_filename);
@@ -1751,11 +1751,6 @@ copy_file (const char *input_filename, c
       if (!bfd_close (ibfd))
 	RETURN_NONFATAL (input_filename);
 
-      if (delete)
-	{
-	  unlink_if_ordinary (output_filename);
-	  status = 1;
-	}
     }
   else
     {
@@ -3054,6 +3049,8 @@ copy_main (int argc, char *argv[])
 
       if (status == 0 && preserve_dates)
 	set_times (output_filename, &statbuf);
+      else if (status != 0)
+	unlink_if_ordinary (output_filename);
     }
 
   if (change_warn)


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: binutils-mainline-objcopy-del-output.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20050426/c12f0984/attachment.ksh>


More information about the Binutils mailing list