[systemd-devel] [PATCH] util: arg 'nbytes' of loop_read/write should be of type ssize_t

fykcee1 at gmail.com fykcee1 at gmail.com
Mon May 2 20:04:14 PDT 2011


2011/5/3 Kay Sievers <kay.sievers at vrfy.org>:
> On Tue, May 3, 2011 at 03:00, fykcee1 at gmail.com <fykcee1 at gmail.com> wrote:
>> 2011/5/3 Kay Sievers <kay.sievers at vrfy.org>
>>>
>>> On Mon, May 2, 2011 at 05:18, fykcee1 at gmail.com <fykcee1 at gmail.com> wrote:
>>> >  loop_read/write will try to fill/read 'nbytes' of caller supplying buffer.
>>> > This argument is currently of type size_t, which is always true
>>> > for loop quit condition "while (nbytes > 0)", hence we change it to
>>> > type ssize_t here.
>>>
>>> Where would that be useful? It's the size of the buffer supplied to
>>> the function, just like read() itself has.
>> Note "while(nbytes > 0)" is equal to "while(true)"
>
> Why? nbytes can be zero, and then it's false. It's counting down with
> every read().
Sorry, I didn't notice nbytes will never  be smaller  than
k(http://cgit.freedesktop.org/systemd/tree/src/util.c#n2667).

Thank you and sorry for noise here.



-- 
Regards,
- cee1


More information about the systemd-devel mailing list