From: Shawn O. Pearce Date: Tue, 13 Oct 2009 18:10:41 GMT Subject: Re: [RFC PATCH v2 01/16] pkt-line: Add strbuf based functions Message-ID: <20091013181041.GX9261@spearce.org> In-Reply-To: <4AD42C52.80205@viscovery.net> Johannes Sixt wrote: > Shawn O. Pearce schrieb: > > -int packet_read_line(int fd, char *buffer, unsigned size) > > +static int packet_length(unsigned *ret_len, const char *linelen) ... > > + *ret_len = len; > > + return 0; > > +} > > len can be signed: Valid lengths fit into a signed int. Then you can > 'return len;' on success and 'return -1;' on failure and don't need return > the result by reference. packet_read_line() ultimately converts it to int > anyway: Great catch, thanks. This is actually from a prior version of code where I was exposing this function to callers... but even then the method could have just returned int with the value because as you point out, all valid lengths fit in int and must be >= 0. -- Shawn.