errno

Clarence Dold dold at mitisft.Convergent.COM
Mon Jun 17 12:59:00 AEST 1991


in article <1991Jun15.151924.24619 at thunder.mcrcim.mcgill.edu>, mouse at thunder.mcrcim.mcgill.edu (der Mouse) says:
...
> Third, you should check that errno is within the range [0..sys_nerr),
> because the sys_errlist table may lag the system for new error codes.
...
>  printf("errno is %d\n",save_errno);
>  if ((save_errno >= 0) && (save_errno < sys_nerr))
>     printf("%s\n",sys_errlist[save_errno]);
>  else
>     printf("Unknown error code %d\n",save_errno);
> }

printf("Errno %d: %s\n", want_err, 
	want_err <= sys_nerr ? sys_errlist[want_err] : "Out of range" );

I like this one because it's one of the few places where the " ? : "
construct looks correct to me.

-- 
---
Clarence A Dold - dold at tsmiti.Convergent.COM
               ...pyramid!ctnews!tsmiti!dold



More information about the Comp.unix.questions mailing list