diff mbox series

abipkgdiff: Use 'convert_path_to_relative' in 'create_abi_file_path'

Message ID 20211210104204.3248704-1-thomas@codesourcery.com
State Committed
Headers show
Series abipkgdiff: Use 'convert_path_to_relative' in 'create_abi_file_path' | expand

Commit Message

Thomas Schwinge Dec. 10, 2021, 10:42 a.m. UTC
... 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(-)

Comments

Thomas Schwinge Dec. 17, 2021, 9:27 a.m. UTC | #1
Hi!

Ping.


Grüße
 Thomas


On 2021-12-10T11:42:04+0100, I wrote:
> ... 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
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
Dodji Seketeli Dec. 20, 2021, 3:57 p.m. UTC | #2
Thomas Schwinge <thomas@codesourcery.com> a écrit:

[...]

>
> 	* tools/abipkgdiff.cc (create_abi_file_path): Use
> 	'convert_path_to_relative'.
>
> Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>

Applied to master, thanks!

[...]

Cheers,
diff mbox series

Patch

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