poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] ios: call `fflush' on output streams


From: Jose E. Marchesi
Subject: Re: [PATCH] ios: call `fflush' on output streams
Date: Fri, 03 Feb 2023 01:29:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Mohammad.
Thanks for the patch.

> diff --git a/libpoke/ios-dev-stream.c b/libpoke/ios-dev-stream.c
> index 952af51e..873833be 100644
> --- a/libpoke/ios-dev-stream.c
> +++ b/libpoke/ios-dev-stream.c
> @@ -249,12 +249,14 @@ static int
>  ios_dev_stream_flush (void *iod, ios_dev_off offset)
>  {
>    struct ios_dev_stream *sio = iod;
> +
> +  if (sio->flags & IOS_F_WRITE)
> +    fflush (sio->file);
>    if (sio->flags & IOS_F_READ
>        && offset > ios_buffer_get_begin_offset (sio->buffer)
>        && offset <= ios_buffer_get_end_offset (sio->buffer))
>      return ios_buffer_forget_till (sio->buffer, offset);
> -  else
> -    return IOS_OK;
> +  return IOS_OK;
>  }

I think a stream IOS must have either IOS_F_WRITE or IOS_F_READ set, but
not both, right?

In that case, wouldn't the code be more clear if you put the fflush in
the `else' part?  You could also put an `assert (sio->flags &
IOS_F_WRITE)' there.

WDYT?



reply via email to

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