summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorGary Mills <gary_mills@fastmail.fm>2012-10-13 10:17:57 -0500
committerRichard Lowe <richlowe@richlowe.net>2012-10-15 20:11:47 -0400
commitace0359e9b3ac0b4bb7ddb51ae9138de3df33789 (patch)
tree640b2ad481890dded93e6163c8f8be1069b63782 /usr/src
parent4c6ae46166796718de10c1839ffe0569daa48250 (diff)
downloadillumos-joyent-ace0359e9b3ac0b4bb7ddb51ae9138de3df33789.tar.gz
72 _tx_error needs to preserve the errno value it is supposed to display
Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/lib/libnsl/nsl/t_error.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/usr/src/lib/libnsl/nsl/t_error.c b/usr/src/lib/libnsl/nsl/t_error.c
index cc316dea2a..4bd7448e07 100644
--- a/usr/src/lib/libnsl/nsl/t_error.c
+++ b/usr/src/lib/libnsl/nsl/t_error.c
@@ -26,10 +26,9 @@
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright (c) 2012 Gary Mills
*/
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */
-
#include "mt.h"
#include <xti.h>
#include <errno.h>
@@ -42,21 +41,19 @@ int
_tx_error(const char *s, int api_semantics)
{
const char *c;
- int n;
+ int errnum = errno; /* In case a system call fails. */
c = t_strerror(t_errno);
if (s != NULL && *s != '\0') {
- n = strlen(s);
- if (n) {
- (void) write(2, s, (unsigned)n);
- (void) write(2, ": ", 2);
- }
+ (void) write(2, s, strlen(s));
+ (void) write(2, ": ", 2);
}
- (void) write(2, c, (unsigned)strlen(c));
+ (void) write(2, c, strlen(c));
if (t_errno == TSYSERR) {
+ c = strerror(errnum);
(void) write(2, ": ", 2);
- perror("");
- } else
- (void) write(2, "\n", 1);
+ (void) write(2, c, strlen(c));
+ }
+ (void) write(2, "\n", 1);
return (0);
}