bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: io.c incompatible pointer between public.read_func and ssize_t(*)()


From: arnold
Subject: Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23
Date: Sun, 11 Aug 2024 09:16:33 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

Eli Zaretskii <eliz@gnu.org> wrote:

> The comment you are removing clearly says that the issue the cast is
> trying to solve is with ancient systems whose prototype of 'read'
> either doesn't exist or is not identical/compatible with 'readfunc'.

The comment was out of sync with the code. Once upon a time the
code was

        static ssize_t (*readfunc)() = NULL;

but at some point I changed it to

        static ssize_t (*readfunc)(int, void *, size_t) = NULL;

`git blame' tells me the comment is from 2010 but the code was
changed in 2021.  The current patch simply updates the code in
other places.

> If this is the issue, then a trivial wrapper around 'read' is IMO
> cleaner:
>
>   static ssize_t wrap_read (int fd, void *buf, size_t size)
>   {
>      return read (fd, buf, size);
>   }

If read has different argument or return types on some system,
that will just generate warnings.

I think things are better without a wrapper.

> Casts are less clean, and can even be dangerous if the actual
> signature is really different.

In the case of read(), I don't think there's anything to worry about.

Probably at some point I'll be able to get rid of the casts entirely.
My concern is for the more outlying systems like VMS on IBM z/OS.

Thanks,

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]