[PATCH] Improve NNTPconnect error reporting

Russ Allbery rra at stanford.edu
Mon Jun 7 17:08:03 UTC 2010

Ian Jackson <ijackson at chiark.greenend.org.uk> writes:
> Russ Allbery writes ("Re: [PATCH] Improve NNTPconnect error reporting"):

>> A string buffer seems to be about the right level of complexity, at
>> least.  The only thing that makes me leery of it is that there's no good
>> way to size that buffer; one just has to take a guess at what would be big
>> enough.

> Yes.  But OTOH the whole thing is already full of fixed-size buffers
> so we wouldn't be making it much worse :-).

Well, NNTPconnect is, indeed, but network isn't.  There are parts of INN's
code that are kind of ugly and parts that are newer and cleaner, and I try
to keep the ugly bits from infecting the newer bits until we can rewrite
the ugly bits.  :)

>> On UNIX, you can probably get away with passing in a char ** and
>> allocating the error buffer on the fly, but I'd rather not go that
>> route just in case the INN version of this code is ever reunified with
>> the version that I use on other projects, since that breaks on Windows
>> without adding a corresponding function to free the error buffer.

> That would be acceptable I guess.  But are we allowed to use asprintf ?

Yes, INN provides asprintf if it's not available.  And the more I think
about it, the more it may make sense to just use asprintf and then provide
a separate function to free the error string.

Proper error handling is always the hardest part of writing in C.

Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

More information about the inn-workers mailing list