[V2] timezone: Fix compare_file comparison in timezone checking

Message ID 20250515114409.1456854-1-michael@amarulasolutions.com
State New
Headers show
Series
  • [V2] timezone: Fix compare_file comparison in timezone checking
Related show

Commit Message

Michael Trimarchi May 15, 2025, 11:44 a.m. UTC
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 <andrea.ricchi@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
V1->V2: Improve commit message
---
 src/timezone.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Denis Kenzior May 15, 2025, 5:51 p.m. UTC | #1
Hi Michael,

On 5/15/25 6:44 AM, Michael Trimarchi 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.
> 
> Signed-off-by: Andrea Ricchi <andrea.ricchi@amarulasolutions.com>
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>

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

> ---
> V1->V2: Improve commit message
> ---
>   src/timezone.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Regards,
-Denis

To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
patchwork-bot+connman via Amarula Linux May 15, 2025, 6 p.m. UTC | #2
Hello:

This patch was applied to connman.git (master)
by Denis Kenzior <denkenz@gmail.com>:

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.
> 
> Signed-off-by: Andrea Ricchi <andrea.ricchi@amarulasolutions.com>
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> 
> [...]

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!

Patch

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)