public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "mark at klomp dot org" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug tools/21522] eu-strip generates empty output if there is nothing to do
Date: Wed, 07 Jun 2017 12:13:00 -0000	[thread overview]
Message-ID: <bug-21522-10460-c7XEuE9N2I@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-21522-10460@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=21522

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
We seem to never remove the output file if we created it, but couldn't finish
it (either because there is nothing to do or some error occurred). We should
always remove it in that case.

Testing the following:

diff --git a/src/strip.c b/src/strip.c
index f747441..c5dbc9c 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -1063,8 +1063,11 @@ handle_elf (int fd, Elf *elf, const char *prefix, const
char *fname,

   /* Test whether we are doing anything at all.  */
   if (cnt == idx)
-    /* Nope, all removable sections are already gone.  */
-    goto fail_close;
+    {
+      /* Nope, all removable sections are already gone.  */
+      result = 1;
+      goto fail_close;
+    }

   /* Create the reference to the file with the debug info.  */
   if (debug_fname != NULL && !remove_shdrs)
@@ -2226,7 +2229,11 @@ cannot set access and modification date of '%s'"),

   /* Close the file descriptor if we created a new file.  */
   if (output_fname != NULL)
-    close (fd);
+    {
+      close (fd);
+      if (result != 0)
+       unlink (output_fname);
+    }

   return result;
 }

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  reply	other threads:[~2017-06-02 13:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 14:37 [Bug tools/21522] New: " paulo.cesar.pereira.de.andrade at gmail dot com
2017-06-07 12:13 ` mark at klomp dot org [this message]
2017-06-13 14:20 ` [Bug tools/21522] " mark at klomp dot org
2017-06-14 18:50 ` mark at klomp dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-21522-10460-c7XEuE9N2I@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).