From: Moumita <dhar61595@gmail.com>
To: git@vger.kernel.org
Cc: Moumita <dhar61595@gmail.com>, Calvin Wan <calvinwan@google.com>,
Junio C Hamano <gitster@pobox.com>,
Patrick Steinhardt <ps@pks.im>, Elijah Newren <newren@gmail.com>
Subject: [PATCH 1/1] refs.c: fix -Wsign-compare warnings
Date: Sat, 8 Feb 2025 23:57:35 +0530 [thread overview]
Message-ID: <20250208182736.18133-2-dhar61595@gmail.com> (raw)
In-Reply-To: <20250208182736.18133-1-dhar61595@gmail.com>
Remove DISABLE_SIGN_COMPARE_WARNINGS from refs.c and fix integer
comparison issues that caused -Wsign-compare warnings.
Tested using `make DEVELOPER=1` and `make t` to ensure correctness.
---
refs.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/refs.c b/refs.c
index 37b8cfb90c..e5cb7acfbe 100644
--- a/refs.c
+++ b/refs.c
@@ -3,7 +3,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "advice.h"
@@ -1652,7 +1652,7 @@ const char *find_descendant_ref(const char *dirname,
* slash) and is not in skip, then we have a conflict.
*/
for (pos = string_list_find_insert_index(extras, dirname, 0);
- pos < extras->nr; pos++) {
+ (size_t)pos < extras->nr; pos++) {
const char *extra_refname = extras->items[pos].string;
if (!starts_with(extra_refname, dirname))
@@ -2304,7 +2304,8 @@ static int run_transaction_hook(struct ref_transaction *transaction,
struct child_process proc = CHILD_PROCESS_INIT;
struct strbuf buf = STRBUF_INIT;
const char *hook;
- int ret = 0, i;
+ int ret = 0;
+ size_t i ;
hook = find_hook(transaction->ref_store->repo, "reference-transaction");
if (!hook)
@@ -2635,9 +2636,9 @@ void ref_transaction_for_each_queued_update(struct ref_transaction *transaction,
ref_transaction_for_each_queued_update_fn cb,
void *cb_data)
{
- int i;
+ size_t i;
- for (i = 0; i < transaction->nr; i++) {
+ for ( i = 0; i < transaction->nr; i++) {
struct ref_update *update = transaction->updates[i];
cb(update->refname,
--
2.48.0
next prev parent reply other threads:[~2025-02-08 18:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-08 18:27 [PATCH 0/1] [GSoC] [Newbie] Fix -Wsign-compare warnings in refs.c Moumita
2025-02-08 18:27 ` Moumita [this message]
2025-02-08 19:01 ` [PATCH 1/1] refs.c: fix -Wsign-compare warnings Kristoffer Haugsbakk
2025-02-08 22:07 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250208182736.18133-2-dhar61595@gmail.com \
--to=dhar61595@gmail.com \
--cc=calvinwan@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.