w-colinp@microsoft.UUCP (Colin Plumb) (04/06/89)
The December 7 draft I have doesn't say anything about what the valid arguments to strerror() are. It says that strerror() maps the error number passed to it to an error string, but I can't find any description of what a valid error number is. Any int? Anything that any library function might put into errno? Any E* macro defined in <errno.h>? sys_nerr (described in H&S) seems to have vanished, so I don't see how I can impose any tighter bounds. (Also, H&S uses CLK_TCK where the dpANS I've got uses CLOCKS_PER_SEC. I presume CLOCKS_PER_SEC is the pANS name?) -- -Colin (uunet!microsoft!w-colinp) "Don't listen to me. I never do." - The Doctor
gwyn@smoke.BRL.MIL (Doug Gwyn ) (04/07/89)
In article <1249@microsoft.UUCP> w-colinp@microsoft.uucp (Colin Plumb) writes: >It says that strerror() maps the error number passed to it to an error >string, but I can't find any description of what a valid error number is. That's easy; anything the standard says is an error number is allowed, and anything else is up to the implementation. I.e. the non-zero value of errno, as set by some functions according to the standard, is an acceptable "error number" for strerror(). Presumably any other non-zero value that the implementation assigns to arrno is also acceptable to strerror(). The Rationale refers you to perror(), 4.9.10.4, where this connection is clearer.
scs@adam.pika.mit.edu (Steve Summit) (04/09/89)
In article <9997@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: >That's easy; anything the standard says is an error number is allowed, >and anything else is up to the implementation. I.e. the non-zero value >of errno, as set by some functions according to the standard, is an >acceptable "error number" for strerror(). So if a weird number is somehow passed to strerror, the result is undefined? This seems like asking for trouble, particularly when it's easy enough to use sprintf(tmpbuf, "Error %d", errno); as many implementations do. Having the result be implementation- defined wouldn't be too bad if it meant that the text might be different ("Error" vs. "error," perhaps) but I'd rather it not do the equivalent of sys_errlist[-123] and dump core. Steve Summit scs@adam.pika.mit.edu