This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] objcopy should delete its output on error


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)


Attachment: binutils-mainline-objcopy-del-output.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]