summaryrefslogtreecommitdiff
path: root/src/conn/api_strerror.c
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2015-02-02 19:20:33 -0500
committerKeith Bostic <keith@wiredtiger.com>2015-02-02 19:20:33 -0500
commita26d87a53eb2ac2dcae9312b7979499c34c11613 (patch)
tree38b6553705ee8396d7ac52eef9ebbb5026850e04 /src/conn/api_strerror.c
parent8545c4b3b7f5ed306215c82f1ad1cbe3664f0c50 (diff)
downloadmongo-a26d87a53eb2ac2dcae9312b7979499c34c11613.tar.gz
Replace wiredtiger_strerror_r with WT_SESSION.strerror, reference #1516.
Diffstat (limited to 'src/conn/api_strerror.c')
-rw-r--r--src/conn/api_strerror.c39
1 files changed, 10 insertions, 29 deletions
diff --git a/src/conn/api_strerror.c b/src/conn/api_strerror.c
index 396ae7a3e0f..07302f5cf20 100644
--- a/src/conn/api_strerror.c
+++ b/src/conn/api_strerror.c
@@ -5,7 +5,7 @@
/*
* Historically, there was only the wiredtiger_strerror call because the POSIX
* port didn't need anything more complex; Windows requires memory allocation
- * of error strings, so we added the wiredtiger_strerror_r call. Because we
+ * of error strings, so we added the WT_SESSION.strerror method. Because we
* want wiredtiger_strerror to continue to be as thread-safe as possible, errors
* are split into three categories: WiredTiger constant strings, system constant
* strings and Everything Else, and we check constant strings before Everything
@@ -16,8 +16,8 @@
* __wiredtiger_error --
* Return a constant string for the WiredTiger errors.
*/
-static const char *
-__wiredtiger_error(int error)
+const char *
+__wt_wiredtiger_error(int error)
{
switch (error) {
case WT_ROLLBACK:
@@ -47,34 +47,15 @@ wiredtiger_strerror(int error)
const char *p;
/* Check for a constant string. */
- if ((p = __wiredtiger_error(error)) != NULL ||
- (p = __wt_strerror(error)) != NULL)
+ if ((p = __wt_wiredtiger_error(error)) != NULL)
+ return (p);
+ if ((p = __wt_strerror(error)) != NULL)
return (p);
/* Else, fill in the non-thread-safe static buffer. */
- if (wiredtiger_strerror_r(error, buf, sizeof(buf)) != 0)
- (void)snprintf(buf, sizeof(buf), "error return: %d", error);
-
- return (buf);
-}
-
-/*
- * wiredtiger_strerror_r --
- * Return a string for any error value, thread-safe version.
- */
-int
-wiredtiger_strerror_r(int error, char *buf, size_t buflen)
-{
- const char *p;
-
- /* Require at least 2 bytes, printable character and trailing nul. */
- if (buflen < 2)
- return (ENOMEM);
-
- /* Check for a constant string. */
- if ((p = __wiredtiger_error(error)) != NULL ||
- (p = __wt_strerror(error)) != NULL)
- return (snprintf(buf, buflen, "%s", p) > 0 ? 0 : ENOMEM);
+ if (snprintf(buf, sizeof(buf), "error return: %d", error) > 0)
+ return (buf);
- return (__wt_strerror_r(error, buf, buflen));
+ /* OK, we're done. */
+ return ("Unable to return error string");
}