On Wed, Dec 24, 2025 at 2:15 PM Michael Paquier <[email protected]> wrote:

> On Tue, Dec 23, 2025 at 10:59:45AM +0800, Chao Li wrote:
> > I’ve attached a small patch along these lines. It compiles without
> > warnings, and "make check" passes on my side. What do you think?
>
> I don't think it is right.  bytestowrite is not a file offset, and the
> code has been using an int due to BufFile->nbytes.  This leads to a
> more confusing result.
> --
> Michael
>

Make sense, bytestowrite is not a file offset. So, in the current code,
availbytes is not a file offset either, but it is defined as pgoff_t, which
has the same confusion, right? Also bytestowrite is casted to pgoff_t, it's
the same confusion again.

How about using "ssize_t" for both bytestowrite and availbytes? It's still
signed, broader than int, and the odd type casts are eliminated.

In win32_port.h:
```
#ifndef _WIN64
typedef long ssize_t;
#else
typedef __int64 ssize_t;
#endif
```

Best regards,
==
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment: v2-0001-buffile-use-ssize_t-for-bytestowrite-in-BufFileDu.patch
Description: Binary data

Reply via email to