1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Remove rangechecks on errno; just call strerror unconditionally. This

eliminates a raft of portability issues, including whether sys_nerr
exists, whether the platform has any valid negative errnos, etc.  The
downside is minimal: errno shouldn't ever contain an invalid value anyway,
and if it does, reasonably modern versions of strerror will not choke.
This rangecheck idea seemed good at the time, but it's clearly a net loss,
and I apologize to all concerned for having ever put it in.
This commit is contained in:
Tom Lane
2001-01-22 23:28:52 +00:00
parent 60b282fd26
commit e9c936ff38
6 changed files with 53 additions and 130 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.78 2001/01/21 00:59:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.79 2001/01/22 23:28:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -43,10 +43,6 @@
extern int errno;
#ifdef HAVE_SYS_NERR
extern int sys_nerr;
#endif
extern CommandDest whereToSendOutput;
#ifdef ENABLE_SYSLOG
@ -139,14 +135,7 @@ elog(int lev, const char *fmt, ...)
return; /* ignore debug msgs if noplace to send */
/* Save error str before calling any function that might change errno */
if (errno >= 0
#ifdef HAVE_SYS_NERR
&& errno <= sys_nerr
#endif
)
errorstr = strerror(errno);
else
errorstr = NULL;
errorstr = strerror(errno);
/*
* Some strerror()s return an empty string for out-of-range errno.
* This is ANSI C spec compliant, but not exactly useful.

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.34 2001/01/21 00:59:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.35 2001/01/22 23:28:52 tgl Exp $
*
* NOTE
* XXX this code needs improvement--check for state violations and
@ -26,10 +26,6 @@
extern int errno;
#ifdef HAVE_SYS_NERR
extern int sys_nerr;
#endif
static void ExcUnCaught(Exception *excP, ExcDetail detail, ExcData data,
ExcMessage message);
@ -115,14 +111,7 @@ ExcPrint(Exception *excP,
#endif
/* Save error str before calling any function that might change errno */
if (errno >= 0
#ifdef HAVE_SYS_NERR
&& errno <= sys_nerr
#endif
)
errorstr = strerror(errno);
else
errorstr = NULL;
errorstr = strerror(errno);
/*
* Some strerror()s return an empty string for out-of-range errno.
* This is ANSI C spec compliant, but not exactly useful.

View File

@ -8,7 +8,7 @@
* or in config.h afterwards. Of course, if you edit config.h, then your
* changes will be overwritten the next time you run configure.
*
* $Id: config.h.in,v 1.156 2001/01/19 23:43:35 petere Exp $
* $Id: config.h.in,v 1.157 2001/01/22 23:28:52 tgl Exp $
*/
#ifndef CONFIG_H
@ -617,9 +617,6 @@ extern void srandom(unsigned int seed);
/* Define if you have the optreset variable */
#undef HAVE_INT_OPTRESET
/* Define if you have the sys_nerr global variable */
#undef HAVE_SYS_NERR
/* Define if you have strtoll() */
#undef HAVE_STRTOLL