summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_api.c
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2013-06-14 14:07:40 -0700
committerAlan Antonuk <alan.antonuk@gmail.com>2013-06-14 14:07:40 -0700
commitac1d9057c3b4bb33a7e336a119af543b4f6ca55e (patch)
treeb74d1c1dc38fbe2fdac4639c287856936eaaa895 /librabbitmq/amqp_api.c
parentf43244721d1ad557a0e5e24a8fdc5a27c6da79af (diff)
downloadrabbitmq-c-ac1d9057c3b4bb33a7e336a119af543b4f6ca55e.tar.gz
ABI compat fix for +-ve vals in amqp_error_string
To preserve ABI, map positive error codes into the negative error-code domain in the amqp_error_string() function. This will preserve compat with older code-bases that do amqp_error_string(-returnval) Note: the function is marked as deprecated so the user will still get a warning when compiling code that uses this function.
Diffstat (limited to 'librabbitmq/amqp_api.c')
-rw-r--r--librabbitmq/amqp_api.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/librabbitmq/amqp_api.c b/librabbitmq/amqp_api.c
index 8be44ad..8e037e1 100644
--- a/librabbitmq/amqp_api.c
+++ b/librabbitmq/amqp_api.c
@@ -128,6 +128,16 @@ const char *amqp_error_string2(int code)
char *amqp_error_string(int code)
{
+ /* Previously sometimes clients had to flip the sign on a return value from a
+ * function to get the correct error code. Now, all error codes are negative.
+ * To keep people's legacy code running correctly, we map all error codes to
+ * negative values.
+ *
+ * This is only done with this deprecated function.
+ */
+ if (code > 0) {
+ code = -code;
+ }
return strdup(amqp_error_string2(code));
}