Skip to contentSkip to conversation

timezone: Fix compare_file comparison in timezone checking

PATCH Applied Michael Trimarchi 3 participants 3 messages May 15, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 timezone: Fix compare_file comparison in timezone checking

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.

---
V1->V2: Improve commit message

---
 src/timezone.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/timezone.c +2 -2
index 89c44895..fba8b925 100644
@@ -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)
Signature · 1 line
2.43.0
#1 lore raw

Hi Michael,

Quoted 7 lines · Michael Trimarchi

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.

No Signed-off-by used by ConnMan, I dropped these.

Quoted 5 lines

---
V1->V2: Improve commit message

---
  src/timezone.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Regards,
-Denis

#2 lore raw
In reply to Michael Trimarchi
This patch was applied to connman.git (master) by Denis Kenzior <[email protected]>:

Hello:

This patch was applied to connman.git (master)
by Denis Kenzior <[email protected]>:

Quoted 9 lines · On Thu, 15 May 2025 13:44:09 +0200 you wrote:

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.

[...]

Here is the summary with links:
- [V2] timezone: Fix compare_file comparison in timezone checking

    https://git.kernel.org/pub/scm/network/connman/connman.git/?id=f20ccd19a62b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html