abipkgdiff: Use 'convert_path_to_relative' in 'create_abi_file_path'

... 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>
This commit is contained in:
Thomas Schwinge 2021-12-10 11:42:04 +01:00 committed by Dodji Seketeli
parent 0e38678cfa
commit daf38b8231

View File

@ -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))