Re: [PATCH 4/4] ALLOC_GROW: avoid -Wsign-compare warnings

2 messages, 2 authors, 2017-09-22 · open the first message on its own page

Re: [PATCH 4/4] ALLOC_GROW: avoid -Wsign-compare warnings

From: Junio C Hamano <hidden>
Date: 2017-09-22 04:20:52

Ramsay Jones [off-list ref] writes:
Signed-off-by: Ramsay Jones <redacted>
---
 builtin/pack-objects.c |  4 ++--
 config.c               |  2 +-
 diff.c                 |  2 +-
 line-log.c             | 18 +++++++++---------
 line-log.h             |  2 +-
 revision.c             |  2 +-
 tree-walk.c            |  3 +--
 7 files changed, 16 insertions(+), 17 deletions(-)
Thanks.  

I did not spot any questionable conversion (e.g. "something that
used to be signed was because it wanted to store -1 as a sentinel"
would be broken if we just change that to unsigned) by going over
the places these variables and fields are actually used.

A review of a patch like this involves reading through 10x more
lines than we see in the above diffstat, and producing it would most
likely have taken the same amount of effort, at least.  Very much
appreciated.
quoted hunk
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index a57b4f058..a6ee653bf 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2563,8 +2563,8 @@ struct in_pack_object {
 };
 
 struct in_pack {
-	int alloc;
-	int nr;
+	unsigned int alloc;
+	unsigned int  nr;
This is a bit questionable ;-) but it is something I can locally
tweak easily.

Re: [PATCH 4/4] ALLOC_GROW: avoid -Wsign-compare warnings

From: Ramsay Jones <hidden>
Date: 2017-09-22 15:36:32


On 22/09/17 05:20, Junio C Hamano wrote:
quoted
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index a57b4f058..a6ee653bf 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2563,8 +2563,8 @@ struct in_pack_object {
 };
 
 struct in_pack {
-	int alloc;
-	int nr;
+	unsigned int alloc;
+	unsigned int  nr;
This is a bit questionable ;-) but it is something I can locally
tweak easily.
Heh, it took me a minute to see what you were referring to! ;-)
Yep, sorry, I don't know how I managed to add the extra space.
(I don't think I can blame vim - PEBKAC).

ATB,
Ramsay Jones

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help