[PATCH GSoC v19 06/13] connect: use unsigned int for hash_algo_by_name() calls
- From
Pablo Sabater <pabloosabaterr@gmail.com>
- Date
- Jul 17, 2026, 15:05 UTC
- Message-ID
- <20260717-ps-eric-work-rebase-v19-6-d4faee35764b@gmail.com>
- In-Reply-To
- <20260717-ps-eric-work-rebase-v19-0-d4faee35764b@gmail.com>
hash_algo_by_name() returns "unsigned int", but multiple variables that store its return are assigned as "int".
Change hash_algo_by_name() variables type to match its return type, also make it const because they are never modified.
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com> --- connect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/connect.c b/connect.c index 31e5ab958b..9d236e7bba 100644 --- a/connect.c +++ b/connect.c @@ -248,7 +248,7 @@ static void process_capabilities(struct packet_reader *reader, size_t *linelen) feat_val = server_feature_value("object-format", &feat_len); if (feat_val) { char *hash_name = xstrndup(feat_val, feat_len); - int hash_algo = hash_algo_by_name(hash_name); + const unsigned int hash_algo = hash_algo_by_name(hash_name); if (hash_algo != GIT_HASH_UNKNOWN) reader->hash_algo = &hash_algos[hash_algo]; free(hash_name); @@ -496,7 +496,7 @@ static void send_capabilities(int fd_out, struct packet_reader *reader) packet_write_fmt(fd_out, "agent=%s", git_user_agent_sanitized()); if (server_feature_v2("object-format", &hash_name)) { - int hash_algo = hash_algo_by_name(hash_name); + const unsigned int hash_algo = hash_algo_by_name(hash_name); if (hash_algo == GIT_HASH_UNKNOWN) die(_("unknown object format '%s' specified by server"), hash_name); reader->hash_algo = &hash_algos[hash_algo]; @@ -722,7 +722,7 @@ void write_fetch_command_and_capabilities(struct strbuf *req_buf, } if (server_feature_v2("object-format", &hash_name)) { - int hash_algo = hash_algo_by_name(hash_name); + const unsigned int hash_algo = hash_algo_by_name(hash_name); if (hash_algo_by_ptr(the_hash_algo) != hash_algo) die(_("mismatched algorithms: client %s; server %s"), the_hash_algo->name, hash_name);
-- 2.54.0