summaryrefslogtreecommitdiff
path: root/sha1-file.c
diff options
context:
space:
mode:
authorTorsten Bögershausen <tboegi@web.de>2018-11-11 07:05:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-12 07:43:52 (GMT)
commitca473cef9140f55d68d6758fe226ef47c216669c (patch)
tree62b470517f2f74c50c9204431d2a8d5354d7a4e8 /sha1-file.c
parent8858448bb49332d353febc078ce4a3abcc962efe (diff)
downloadgit-ca473cef9140f55d68d6758fe226ef47c216669c.zip
git-ca473cef9140f55d68d6758fe226ef47c216669c.tar.gz
git-ca473cef9140f55d68d6758fe226ef47c216669c.tar.bz2
Upcast size_t variables to uintmax_t when printing
When printing variables which contain a size, today "unsigned long" is used at many places. In order to be able to change the type from "unsigned long" into size_t some day in the future, we need to have a way to print 64 bit variables on a system that has "unsigned long" defined to be 32 bit, like Win64. Upcast all those variables into uintmax_t before they are printed. This is to prepare for a bigger change, when "unsigned long" will be converted into size_t for variables which may be > 4Gib. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1-file.c')
-rw-r--r--sha1-file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sha1-file.c b/sha1-file.c
index dd0b6aa..4a67e0e 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -833,7 +833,7 @@ int check_object_signature(const struct object_id *oid, void *map,
return -1;
/* Generate the header */
- hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(obj_type), size) + 1;
+ hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %"PRIuMAX , type_name(obj_type), (uintmax_t)size) + 1;
/* Sha1.. */
the_hash_algo->init_fn(&c);
@@ -1492,7 +1492,7 @@ static void write_object_file_prepare(const void *buf, unsigned long len,
git_hash_ctx c;
/* Generate the header */
- *hdrlen = xsnprintf(hdr, *hdrlen, "%s %lu", type, len)+1;
+ *hdrlen = xsnprintf(hdr, *hdrlen, "%s %"PRIuMAX , type, (uintmax_t)len)+1;
/* Sha1.. */
the_hash_algo->init_fn(&c);
@@ -1758,7 +1758,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
buf = read_object(oid->hash, &type, &len);
if (!buf)
return error(_("cannot read sha1_file for %s"), oid_to_hex(oid));
- hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;
+ hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %"PRIuMAX , type_name(type), (uintmax_t)len) + 1;
ret = write_loose_object(oid, hdr, hdrlen, buf, len, mtime);
free(buf);