poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2] libpoke: free the buffer of stream device only in read mo


From: Jose E. Marchesi
Subject: Re: [PATCH v2] libpoke: free the buffer of stream device only in read mode
Date: Sun, 18 Oct 2020 18:50:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> Hi Mohammad.
>> 
>> > diff --git a/libpoke/ios-buffer.c b/libpoke/ios-buffer.c
>> > index f3e1ad63..a2bdbb99 100644
>> > --- a/libpoke/ios-buffer.c
>> > +++ b/libpoke/ios-buffer.c
>> > @@ -76,6 +76,9 @@ int
>> >  ios_buffer_free (struct ios_buffer *buffer)
>> >  {
>> >    struct ios_buffer_chunk *chunk, *chunk_next;
>> > +
>> > +  assert(buffer != NULL);
>> > +
>> >    for (int i = 0; i < IOB_BUCKET_COUNT; i++)
>> >      {
>> >        chunk = buffer->chunks[i];
>> 
>> Even if we avoid calling ios_buffer_free in ios_dev_stream_close, I
>> think it is always a good idea for the destructors to safely do nothing
>> if NULL is passed.  This is more according to the usual C semantics of
>> `free'.
>> 
>
> OK. I'll change the assertion to:
>
> ```c
> if (buffer == NULL)
>   return 1;
> ```
>
> Is this OK?

Yes, but since ios_buffer_free can't fail, please also change it to
return `void' instead of `int'.

>> On the other hand, do you have a savannah account?
>
> Yes. mnabipoor.

Ok, now you should have write access to the repo.
Welcome on board :)



reply via email to

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