bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] getline & getline_safe


From: Derek Robert Price
Subject: Re: [Bug-gnulib] getline & getline_safe
Date: Thu, 24 Jul 2003 12:21:38 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1

Bruno Haible wrote:

Derek Robert Price wrote:
+# define GETNDELIM_NO_LIMIT (ssize_t)-1
Totally confusing types: the limit is an upper bound for the size of an
array or count, so it should be 'size_t'. The getndelim2() argument called
limit is of type 'int'. And this macro is of type 'ssize_t'. Better let
the caller use 'size_t' everywhere.
No I'm not.  Or at least I may not have been consistent about updating
my types, but it should be ssize_t everywhere, if the return type is to
be ssize_t.  Don't forget that I wrote this to use limit as a maximum
number of characters.  If the number of characters read is returned as
an ssize_t then the number of characters to read should be passed in as
an ssize_t as well.

The same argument could also be applied to the read() and write()
functions. These functions accept a 'size_t count' value in the
range 0 .. SSIZE_MAX. Still the argument type is not an ssize_t,
in order to discourage people from passing negative values.

Okay, that makes sense.

Derek

--
               *8^)

Email: address@hidden

Get CVS support at <http://ximbiot.com>!
--
Don't confuse me with the facts, my mind's already made up!





reply via email to

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