diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-12-06 11:27:23 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-12-06 12:20:03 +0100 |
commit | 25435e4ad87aa484ce0d9d2adf3aa407f0241704 (patch) | |
tree | 409e01b59503d135bd25b772561f39ba376962c4 /diagnose.c | |
parent | csum-file: fix -Wsign-compare warning on 32-bit platform (diff) | |
download | git-25435e4ad87aa484ce0d9d2adf3aa407f0241704.tar.xz git-25435e4ad87aa484ce0d9d2adf3aa407f0241704.zip |
pkt-line: fix -Wsign-compare warning on 32 bit platform
Similar to the preceding commit, we get a warning in `get_packet_data()`
on 32 bit platforms due to our lenient use of `ssize_t`. This function
is kind of curious though: we accept an `unsigned size` of bytes to
read, then store the actual number of bytes read in an `ssize_t` and
return it as an `int`. This is a whole lot of integer conversions, and
in theory these can cause us to overflow when the passed-in size is
larger than `ssize_t`, which on 32 bit platforms is implemented as an
`int`.
None of the callers of that function even care about the number of bytes
we have read, so returning that number is moot anyway. Refactor the
function such that it only returns an error code, which plugs the
potential overflow. While at it, convert the passed-in size parameter to
be of type `size_t`.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diagnose.c')
0 files changed, 0 insertions, 0 deletions