From cb60e7c065d15ac311a94a1cb8ecce5df495b251 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Mon, 11 Mar 2013 15:50:35 +0100
Subject: [PATCH] Allow enabling of dummy error_strerror() to support some
use-cases
Enable a dummy error function to make use of error_strerror() in
third party libraries easier.
Disable if you run into name conflicts and want to really remove the
error_strerror()
(cherry picked from commit 8fe40dcd7d3b46193f74032361efb674112ee9e5)
Conflicts:
ChangeLog
programs/util/strerror.c
---
ChangeLog | 4 ++++
include/polarssl/config.h | 11 +++++++++++
library/error.c | 18 ++++++++++++++++++
3 files changed, 33 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 1d3948985..6753726a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
PolarSSL ChangeLog
+= Branch 1.1
+Changes
+ * Allow enabling of dummy error_strerror() to support some use-cases
+
= Version 1.1.5 released on 2013-01-16
Bugfix
* Fixed MPI assembly for SPARC64 platform
diff --git a/include/polarssl/config.h b/include/polarssl/config.h
index bb2e23243..110e3b4b5 100644
--- a/include/polarssl/config.h
+++ b/include/polarssl/config.h
@@ -138,6 +138,17 @@
*/
#define POLARSSL_DEBUG_MSG
+/**
+ * \def POLARSSL_ERROR_STRERROR_DUMMY
+ *
+ * Enable a dummy error function to make use of error_strerror() in
+ * third party libraries easier.
+ *
+ * Disable if you run into name conflicts and want to really remove the
+ * error_strerror()
+ */
+#define POLARSSL_ERROR_STRERROR_DUMMY
+
/**
* \def POLARSSL_GENPRIME
*
diff --git a/library/error.c b/library/error.c
index 792b90235..452f45881 100644
--- a/library/error.c
+++ b/library/error.c
@@ -509,4 +509,22 @@ void error_strerror( int ret, char *buf, size_t buflen )
snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
}
+#else /* POLARSSL_ERROR_C */
+
+#if defined(POLARSSL_ERROR_STRERROR_DUMMY)
+
+#include
+
+/*
+ * Provide an non-function in case POLARSSL_ERROR_C is not defined
+ */
+void error_strerror( int ret, char *buf, size_t buflen )
+{
+ ((void) ret);
+
+ if( buflen > 0 )
+ buf[0] = '\0';
+}
+
+#endif /* POLARSSL_ERROR_STRERROR_DUMMY */
#endif /* POLARSSL_ERROR_C */