git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] git-compat-util.h: xsize_t() - avoid -Wsign-compare warnings
@ 2017-09-21 16:46 Ramsay Jones
  2017-09-21 18:49 ` Torsten Bögershausen
  0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2017-09-21 16:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, GIT Mailing-list


Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 git-compat-util.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 9bc15b036..cedad4d58 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -898,9 +898,11 @@ static inline char *xstrdup_or_null(const char *str)
 
 static inline size_t xsize_t(off_t len)
 {
-	if (len > (size_t) len)
+	size_t size = (size_t) len;
+
+	if (len != (off_t) size)
 		die("Cannot handle files this big");
-	return (size_t)len;
+	return size;
 }
 
 __attribute__((format (printf, 3, 4)))
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-21 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-21 16:46 [PATCH 1/4] git-compat-util.h: xsize_t() - avoid -Wsign-compare warnings Ramsay Jones
2017-09-21 18:49 ` Torsten Bögershausen
2017-09-21 18:57   ` Stefan Beller
2017-09-21 19:02   ` Ramsay Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).