From 7a5e53262add53e06d0411361f3bcf29a7438e2f Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Wed, 23 Nov 2016 08:57:27 -0800 Subject: [PATCH] [DB] kill abs_source_file_from_path Summary: `abs_source_file_from_path` is dangerous because 1. It's not trying to make path relative to `project_root` - you can't compare two files created with two different methods 2. It's making relative paths relative to `getcwd` instead of `project_root` which is different from `from_string` function. Also remove unused `DB.inode_equal` Reviewed By: cristianoc Differential Revision: D4204891 fbshipit-source-id: c4c2f99 --- infer/src/base/DB.ml | 9 --------- infer/src/base/DB.mli | 6 ------ 2 files changed, 15 deletions(-) diff --git a/infer/src/base/DB.ml b/infer/src/base/DB.ml index d7534a9ce..813bcb0e9 100644 --- a/infer/src/base/DB.ml +++ b/infer/src/base/DB.ml @@ -56,10 +56,6 @@ let source_file_from_string path = else Absolute path -(** convert a path to a source file, turning it into an absolute path if necessary *) -let abs_source_file_from_path fname = - Absolute (filename_to_absolute fname) - let rel_path_from_abs_path root fname = let relative_complemented_fname = filename_to_relative root fname in if string_is_prefix root fname && @@ -100,11 +96,6 @@ let source_file_line_count source_file = let abs_path = source_file_to_abs_path source_file in count_newlines abs_path -let inode_equal sf1 sf2 = - let stat1 = Unix.stat (source_file_to_abs_path sf1) in - let stat2 = Unix.stat (source_file_to_abs_path sf2) in - stat1.st_dev = stat2.st_dev && stat1.st_ino = stat2.st_ino - let source_file_to_rel_path fname = match fname with | RelativeProjectRoot path -> path diff --git a/infer/src/base/DB.mli b/infer/src/base/DB.mli index 724aa9aeb..6553d0023 100644 --- a/infer/src/base/DB.mli +++ b/infer/src/base/DB.mli @@ -95,15 +95,9 @@ val source_file_line_count : source_file -> int (** equality of source files *) val source_file_equal : source_file -> source_file -> bool -(** equality of the files on disk *) -val inode_equal : source_file -> source_file -> bool - (** empty source file *) val source_file_empty : source_file -(** convert a path to a source file, turning it into an absolute path if necessary *) -val abs_source_file_from_path : string -> source_file - val source_file_from_abs_path : string -> source_file (** string encoding of a source file (including path) as a single filename *)