From 585d85491eda08039489af55b295660a97a2e81c Mon Sep 17 00:00:00 2001
From: Warlockbugs <warlockbugs@outlook.com>
Date: Sun, 8 Dec 2024 03:57:47 +0300
Subject: [PATCH] Fix gcc/clang warnings for git_id helper utility

---
 contrib/git_id/git_id.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/contrib/git_id/git_id.cpp b/contrib/git_id/git_id.cpp
index 8e452139bbc..af22a923ad6 100644
--- a/contrib/git_id/git_id.cpp
+++ b/contrib/git_id/git_id.cpp
@@ -164,8 +164,8 @@ bool find_path()
 
     // don't count the root
     int count_fwd = 0, count_back = 0;
-    for (ptr = cur_path - 1; ptr = strchr(ptr + 1, '/'); count_fwd++);
-    for (ptr = cur_path - 1; ptr = strchr(ptr + 1, '\\'); count_back++);
+    for (ptr = cur_path - 1; (ptr = strchr(ptr + 1, '/')); count_fwd++);
+    for (ptr = cur_path - 1; (ptr = strchr(ptr + 1, '\\')); count_back++);
     int count = std::max(count_fwd, count_back);
 
     char path[MAX_PATH];
@@ -177,7 +177,7 @@ bool find_path()
             chdir(cur_path);
             return true;
         }
-        strncat(path_prefix, "../", MAX_PATH);
+        strncat(path_prefix, "../", (MAX_PATH-1));
 
         ptr = strrchr(base_path, '\\');
         if (ptr) *ptr = '\0';
@@ -219,6 +219,7 @@ bool fetch_origin()
     // use the public clone url if present because the private may require a password
     snprintf(cmd, MAX_CMD, "git fetch %s %s", (origins[1][0] ? origins[1] : origins[0]), remote_branch);
     int ret = system(cmd);
+    (void)ret; // silence unused variable warning
     return true;
 }