Git fork

git-compat-util.h: implement checked size_t to uint32_t conversion

In a similar fashion as other checked cast functions in this header
(such as `cast_size_t_to_ulong()` and `cast_size_t_to_int()`), implement
a checked cast function for going from a size_t to a uint32_t value.

This function will be utilized in a future commit which needs to make
such a conversion.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Taylor Blau and committed by
Junio C Hamano
ed9f4148 b96289a1

+9
+9
git-compat-util.h
··· 1013 1013 return (unsigned long)a; 1014 1014 } 1015 1015 1016 + static inline uint32_t cast_size_t_to_uint32_t(size_t a) 1017 + { 1018 + if (a != (uint32_t)a) 1019 + die("object too large to read on this platform: %" 1020 + PRIuMAX" is cut off to %u", 1021 + (uintmax_t)a, (uint32_t)a); 1022 + return (uint32_t)a; 1023 + } 1024 + 1016 1025 static inline int cast_size_t_to_int(size_t a) 1017 1026 { 1018 1027 if (a > INT_MAX)