Hello,

Upon review of the revised patch, the principal technical concerns
identified in the previous review remain unaddressed.
 - RPC atomicity: The implementation continues to split a single write
operation into multiple RPCs, contrary to the single-RPC
   approach discussed in the preceding correspondence.
 - RPC size constraint: Replacing INT32_MAX with UINT32_MAX is inconsistent
with the maximum signed value of
  mach_msg_type_number_t, as clarified by Samuel.
 - Offset arithmetic and output parameter semantics: The potential offset
overflow and the modification of *nbytes prior
   to successful RPC completion remain unresolved.
 - Coding standards: The nested function indentation previously identified
by Samuel has not been corrected. The revised diff
   additionally introduces redundant blank lines and trailing whitespace.

The implementation should be simplified to perform a single bounded RPC and
return a short write where necessary. This
approach would eliminate the need for explicit offset advancement,
cumulative byte accounting, and error handling across multiple RPCs.

Please address the outstanding technical concerns and ensure compliance
with the glibc coding standards before submitting a subsequent
 revision. Running git diff --check is also recommended.

This assessment is limited to static analysis of the supplied diff. No
compilation or runtime testing has been performed.

Best regards,
Alperen Erkan

On Sat, Nov 28, 2026 at 4:45 PM Ahmed Khider <[email protected]> wrote:

> ---
>  hurd/fd-write.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 41 insertions(+), 8 deletions(-)
>
> diff --git a/hurd/fd-write.c b/hurd/fd-write.c
> index 2dc2eedf..e3434130 100644
> --- a/hurd/fd-write.c
> +++ b/hurd/fd-write.c
> @@ -18,6 +18,7 @@
>
>  #include <errno.h>
>  #include <unistd.h>
> +#include <stdint.h>
>  #include <hurd.h>
>  #include <hurd/fd.h>
>
> @@ -27,20 +28,52 @@ _hurd_fd_write (struct hurd_fd *fd,
>  {
>    error_t err;
>    vm_size_t wrote;
> +  size_t wbytes = *nbytes;
> +  size_t tbytes = 0;
>
> +
>    error_t writefd (io_t port)
> +  {
> +    return __io_write (port, buf, *nbytes, offset, &wrote);
> +  }
> +
> +
> +  do
>      {
> -      return __io_write (port, buf, *nbytes, offset, &wrote);
> -    }
> +      *nbytes = wbytes > UINT32_MAX ? UINT32_MAX : wbytes;
> +
> +
> +      err = HURD_FD_PORT_USE_CANCEL (fd, _hurd_ctty_output (port, ctty,
> writefd));
> +      if (err)
> +       {
> +         if (tbytes > 0)
> +           {
> +             *nbytes = tbytes;
> +             return 0;
> +           }
> +         return err;
> +       }
>
> -  err = HURD_FD_PORT_USE_CANCEL (fd, _hurd_ctty_output (port, ctty,
> writefd));
> -  if (err)
> -    return err;
> +
> +      if (__glibc_unlikely (wrote > *nbytes))  /* Sanity check for bogus
> server.  */
> +       return EGRATUITOUS;
> +
> +
> +      tbytes += wrote;
> +      wbytes -= wrote;
> +      buf = (const char*) buf + wrote;
> +
> +      if (offset != -1)
> +       offset += wrote;
> +
> +      if (wrote < *nbytes)
> +        break;
> +
> +    }
> +  while (wbytes != 0);
>
> -  if (__glibc_unlikely (wrote > *nbytes))      /* Sanity check for bogus
> server.  */
> -    return EGRATUITOUS;
>
> -  *nbytes = wrote;
> +  *nbytes = tbytes;
>
>    return 0;
>  }
> --
> 2.47.3
>
>
>

Reply via email to