public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: libabigail@sourceware.org
Cc: Thomas Schwinge <thomas@codesourcery.com>
Subject: [PATCH] abipkgdiff: Use 'convert_path_to_relative' in 'create_abi_file_path'
Date: Fri, 10 Dec 2021 11:42:04 +0100	[thread overview]
Message-ID: <20211210104204.3248704-1-thomas@codesourcery.com> (raw)

... instead of open-coding it, insufficiently.

On one system, I have a '/home' -> 'media/[...]/home' symlink, so:

    $ readlink -f /home/thomas/.cache
    /media/[...]/home/thomas/.cache

Now:

    Thread 4 "abipkgdiff" hit Breakpoint 1, package::create_abi_file_path (this=0x5555555a7990,
        elf_file_path="/media/[...]/home/thomas/.cache/libabigail/abipkgdiff-tmp-dir-upGgLK/package1/usr/lib64/libGLU.so.1.3.1", abi_file_path="") at [...]/tools/abipkgdiff.cc:668
    668       create_abi_file_path(const string &elf_file_path,
    (gdb) n
    671         string abi_path, dir, parent;
    (gdb) n
    672         if (!abigail::tools_utils::string_suffix(elf_file_path,
    (gdb) n
    675           return false;

So we unexpectedly 'return false' here.  That's because of 'elf_file_path' as
above ('realpath'ed) vs. 'extracted_dir_path()' as follows (not 'realpath'ed):

    (gdb) print extracted_dir_path()
    $1 = "/home/thomas/.cache/libabigail/abipkgdiff-tmp-dir-upGgLK/package1"

Avoid that by just using 'convert_path_to_relative' here.

(I did not generally review the code for other such problems...)

	* tools/abipkgdiff.cc (create_abi_file_path): Use
	'convert_path_to_relative'.

Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
---
 tools/abipkgdiff.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git tools/abipkgdiff.cc tools/abipkgdiff.cc
index 7fc833b2..ef9fabf2 100644
--- tools/abipkgdiff.cc
+++ tools/abipkgdiff.cc
@@ -667,9 +667,7 @@ public:
 		       string &abi_file_path) const
   {
     string abi_path, dir, parent;
-    if (!abigail::tools_utils::string_suffix(elf_file_path,
-					     extracted_dir_path(),
-					     abi_path))
+    if (!convert_path_to_relative(elf_file_path, abi_path))
       return false;
     abi_path = extracted_dir_path() + "/abixml" + abi_path + ".abi";
     if (!abigail::tools_utils::ensure_parent_dir_created(abi_path))
-- 
2.25.1


             reply	other threads:[~2021-12-10 10:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 10:42 Thomas Schwinge [this message]
2021-12-17  9:27 ` Thomas Schwinge
2021-12-20 15:57 ` Dodji Seketeli

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=20211210104204.3248704-1-thomas@codesourcery.com \
    --to=thomas@codesourcery.com \
    --cc=libabigail@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).