summaryrefslogtreecommitdiff
path: root/lib/error.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-08-04 19:35:24 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-08-04 19:35:24 +0000
commita617eff5dcdf06d0ef5ea2e989908e75de177066 (patch)
treea8a0f1b741da4730790b4e90bb7baea928ac4d40 /lib/error.c
parentb3f620dd47e5600fba9825835734892b7a7d562a (diff)
downloadcoreutils-a617eff5dcdf06d0ef5ea2e989908e75de177066.tar.xz
Work around bug in OpenBSD 3.4 sterror_r: it
sometimes returns a positive errno value even when it succeeds. (print_errno_message) [!LIBC]: Fall back on strerror if __strerror_r fails.
Diffstat (limited to 'lib/error.c')
-rw-r--r--lib/error.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/error.c b/lib/error.c
index 1149235a1..5a5e126b0 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -1,5 +1,5 @@
/* Error handler for noninteractive utilities
- Copyright (C) 1990-1998, 2000-2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1990-1998, 2000-2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@@ -106,7 +106,7 @@ extern char *program_name;
static void
print_errno_message (int errnum)
{
- char const *s;
+ char const *s = NULL;
#if defined HAVE_STRERROR_R || _LIBC
char errbuf[1024];
@@ -115,15 +115,11 @@ print_errno_message (int errnum)
# else
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
s = errbuf;
- else
- s = 0;
# endif
-#else
- s = strerror (errnum);
#endif
#if !_LIBC
- if (! s)
+ if (! s && ! (s = strerror (errnum)))
s = _("Unknown system error");
#endif