Path: utzoo!utgpu!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.sources.d Subject: Re: Inapproprtiae ioctl for user (Re: Comments on INSERT.c) Message-ID: <859@auspex.UUCP> Date: 18 Jan 89 06:18:19 GMT References: <308@twwells.uucp> <852@auspex.UUCP> <2765@ficc.uu.net> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 37 >The place to look is where you call perror. Then you trace back from >there to see how you might get to the call with an invalid perror. And get lost in the code. The problem is that the call that set "errno" to a non-zero value was probably some "isatty" call somewhere not connected with the call to "errstring" (which, BTW, contains no call to "perror", it uses "sys_errlist" directly, so if you decide to look where you call "perror" you're not going to be very successful). >> fix - "errno = 0" statements are liberally sprinkled throughout the >> source). > >Which sounds like you've got some incredibly poor design here. *I* don't have *any* design here; I didn't write "sendmail". There are probably people who might agree with you about its design (but I'm going to ask them not to start a debate on the merits of "sendmail", or the quality of its design, here - it's nice that you (generic) have an opinion on the subject, but please don't let it piddle on the carpet). In this particular case, part of the problem is that the "giveresponse" routine doesn't take an error number as an argument - it uses "errno" as a global variable. However, it uses both "errno" and "h_errno", and you could probably spend some time prowling through the code to figure out which one should be passed and when. In addition, it's not clear that the code that calls "giveresponse" would necessarily *know* whether to pass "errno" or 0 to a "giveresponse" that took an error number as an argument; the error it's going to use in the response came from some lower-level routine, and that error might be due to a procedure call that failed and set "errno", or it might not. A better analogy than the leg injury given earlier might be a pain in the chest; is it a heart attack, or heartburn, or...? The fact that it's a chest pain localizes it somewhat, but just because two problems cause pain in the chest doesn't mean they're particularly related.