Date: Sat, 1 Dec 2001 23:47:52 -0500 From: Garance A Drosihn <drosih@rpi.edu> To: Bruce Evans <bde@zeta.org.au>, Wes Peters <wes@softweyr.com> Cc: Bill Fenner <fenner@research.att.com>, <mike@FreeBSD.org>, <freebsd-standards@bostonradio.org> Subject: Re: strerror_r() implementation Message-ID: <p05101006b82f5ebd92e6@[128.113.24.47]> In-Reply-To: <20011202011045.F5026-100000@gamplex.bde.org> References: <20011202011045.F5026-100000@gamplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
At 1:52 AM +1100 12/2/01, Bruce Evans wrote: > > > > The last change is a whitespace error. Mustn't have any style(9) > > > > nits, right? ;^) > > > > > > I agree, so about 10 more of them in strerror() alone ;^). They > > > were in the following classes: > > > (1) missing parens around return values >> >> style(9) remains silent on this subject. Until required to do so by > >It is not silent, but not very verbose. All of the examples of returning >a value in style(9) use "return (foo)". There is a whole one such example. >It apparently didn't occur to the origianal author of style(9) that this >needed an explicit rule. In the argumentative half of my message (this here message...), I will note that style(9) also says that parenthesis should not be added unless they are necessary, and previous discussions have indicated that parentheses are not in fact necessary in C on return statements... The more I have thought about this, the more I have felt that it is better to NOT use parentheses on 'return' statements, as that makes it absolutely clear that the return statement is not a function call. And, when there are no parentheses, then it is much easier to remember to put a blank between 'return' and the value being returned ... :-) </argumentative> >I tested it a bit more and found a bug in the test code: the test of a >short buffer returns an unterminated string (as expected), and printing >this non-string using %s gives garbage. Hmm. I do not have the standards document for strerror_r(), but I am surprised that a short buffer is expected to return a string which is not null-terminated. Note that I am not arguing the point, I'm just surprised. That means all callers to strerror_r() should never treat the result as a null-terminated string, even though it usually will be null-terminated. Seems to me that is asking for trouble. I need to order a copy of the latest standards, obviously... The most modern one I have is SingleUnix v2, and that doesn't even mention strerror_r()! -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p05101006b82f5ebd92e6>