Re: [PATCH 1/9] xdiff: use ssize_t for dstart/dend, make them last in xdfile_t
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Oct 21, 2025, 11:32 UTC
- Message-ID
- <9eafee4d-ea94-4382-ada0-58000d229d2e@gmail.com>
- In-Reply-To
- <1fa9a7d7d1c309f2f651da351ba7bc0b36272d91.1760563101.git.gitgitgadget@gmail.com>
On 15/10/2025 22:18, Ezekiel Newren via GitGitGadget wrote:
> From: Ezekiel Newren <ezekielnewren@gmail.com> > > ssize_t is appropriate for dstart and dend because they both describe > positive or negative offsets relative to a pointer.
Isn't ptrdiff_t the appropriate type for an offset to a pointer? ssize_t is not guaranteed to be the same width as size_t (this has caused problems in the past[1]) and is only defined by POSIX, not the C standard.
Thanks
Phillip
[1] https://lore.kernel.org/git/loom.20150207T174514-727@post.gmane.org/
Show 25 quoted lines
> A future patch will move these fields to a different struct. Moving
> them to the end of xdfile_t now, means the field order of xdfile_t will
> be disturbed less.
>
> Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com>
> ---
> xdiff/xtypes.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xdiff/xtypes.h b/xdiff/xtypes.h
> index f145abba3e..3514bb1684 100644
> --- a/xdiff/xtypes.h
> +++ b/xdiff/xtypes.h
> @@ -47,10 +47,10 @@ typedef struct s_xrecord {
> typedef struct s_xdfile {
> xrecord_t *recs;
> long nrec;
> - long dstart, dend;
> bool *changed;
> long *rindex;
> long nreff;
> + ssize_t dstart, dend;
> } xdfile_t;
>
> typedef struct s_xdfenv {