From daf38b8231605578b0bd48dfd6bc3ad0fe55a2b2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 10 Dec 2021 11:42:04 +0100 Subject: [PATCH] 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 --- tools/abipkgdiff.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc index 7fc833b2..ef9fabf2 100644 --- a/tools/abipkgdiff.cc +++ b/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))