Skip to content

Commit

Permalink
Fix gcc/clang warnings for git_id helper utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Warlockbugs committed Dec 8, 2024
1 parent 7d6e49a commit 4668233
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contrib/git_id/git_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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';
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 4668233

Please sign in to comment.