From 6a1a06f1506b88b769955ddc57035cf166f64ef4 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期五, 22 一月 2021 17:59:18 +0800
Subject: [PATCH] update
---
src/bus_error.cpp | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/bus_error.cpp b/src/bus_error.cpp
index c2dd63a..cf16cf2 100644
--- a/src/bus_error.cpp
+++ b/src/bus_error.cpp
@@ -13,9 +13,10 @@
static char *_bus_errlist[_bus_nerr] = {
"\0",
- "timeout",
+ "Timeout",
"The other end is not inline",
- "Key already in use"
+ "Key already in use",
+ "Network fault"
};
@@ -41,9 +42,9 @@
char *
bus_strerror(int err)
{
- int s;
+ int s, eindex;
char *buf;
-
+ eindex = err - EBUS_BASE;
/* Make first caller allocate key for thread-specific data */
s = pthread_once(&once, createKey);
@@ -64,13 +65,13 @@
err_exit(s, "pthread_setspecific");
}
- if (err < 0 || err >= _bus_nerr || _bus_errlist[err] == NULL)
+ if (eindex < 0 || eindex >= _bus_nerr || _bus_errlist[eindex] == NULL)
{
- snprintf(buf, MAX_ERROR_LEN, "Unknown error %d", err);
+ snprintf(buf, MAX_ERROR_LEN, "Unknown error %d", eindex);
}
else
{
- strncpy(buf, _bus_errlist[err], MAX_ERROR_LEN - 1);
+ strncpy(buf, _bus_errlist[eindex], MAX_ERROR_LEN - 1);
buf[MAX_ERROR_LEN - 1] = '\0'; /* Ensure null termination */
}
--
Gitblit v1.8.0