[PATCH V2] timezone: Fix compare_file comparison in timezone checking

Michael Trimarchi <[email protected]> Thu, 15 May 2025 13:44:09 +0200
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
The original condition incorrectly returned -1 when the real path and the
provided pathname matched, due to a flawed use of `g_strcmp0`. This patch
corrects the logic to return 0 (success) when the paths match, ensuring
proper file comparison behavior.

Signed-off-by: Andrea Ricchi <[email protected]>
Signed-off-by: Michael Trimarchi <[email protected]>
---
V1->V2: Improve commit message
---
 src/timezone.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/timezone.c b/src/timezone.c
index 89c44895..fba8b925 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -124,8 +124,8 @@ static int compare_file(void *src_map, struct stat *src_st,
 
 	DBG("real path %s path name %s", real_path, pathname);
 
-	if (real_path && g_strcmp0(real_path, pathname))
-		return -1;
+	if (real_path && !g_strcmp0(real_path, pathname))
+		return 0;
 
 	fd = open(pathname, O_RDONLY | O_CLOEXEC);
 	if (fd < 0)
-- 
2.43.0