summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonyg@rabbitmq.com>2010-08-20 12:44:20 -0400
committerTony Garnock-Jones <tonyg@rabbitmq.com>2010-08-20 12:44:20 -0400
commit2e75da40586564221977ab01b8afdac9daf36377 (patch)
tree5ad7c46ee2e136da3482e92c04061daefe6f9277
parent3915a16292cb95b37ff958cc219bd937490623dd (diff)
downloadrabbitmq-c-github-ask-bug23163.tar.gz
Harmonize uses of die_amqp_error: it now expects the result code, with negative meaning errorbug23163
-rw-r--r--tools/common.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/common.c b/tools/common.c
index c5bda77..f8b6985 100644
--- a/tools/common.c
+++ b/tools/common.c
@@ -94,13 +94,13 @@ void die_amqp_error(int err, const char *fmt, ...)
va_list ap;
char *errstr;
- if (err <= 0)
+ if (err >= 0)
return;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
- fprintf(stderr, ": %s\n", errstr = amqp_error_string(err));
+ fprintf(stderr, ": %s\n", errstr = amqp_error_string(-err));
free(errstr);
exit(1);
}
@@ -219,7 +219,7 @@ amqp_connection_state_t make_connection(void)
}
s = amqp_open_socket(host, port ? port : 5672);
- die_amqp_error(-s, "opening socket to %s", amqp_server);
+ die_amqp_error(s, "opening socket to %s", amqp_server);
conn = amqp_new_connection();
amqp_set_sockfd(conn, s);
@@ -244,7 +244,7 @@ void close_connection(amqp_connection_state_t conn)
"closing connection");
res = amqp_destroy_connection(conn);
- die_amqp_error(-res, "closing connection");
+ die_amqp_error(res, "closing connection");
}
amqp_bytes_t read_all(int fd)
@@ -295,7 +295,7 @@ void copy_body(amqp_connection_state_t conn, int fd)
amqp_frame_t frame;
int res = amqp_simple_wait_frame(conn, &frame);
- die_amqp_error(-res, "waiting for header frame");
+ die_amqp_error(res, "waiting for header frame");
if (frame.frame_type != AMQP_FRAME_HEADER)
die("expected header, got frame type 0x%X",
frame.frame_type);
@@ -303,7 +303,7 @@ void copy_body(amqp_connection_state_t conn, int fd)
body_remaining = frame.payload.properties.body_size;
while (body_remaining) {
res = amqp_simple_wait_frame(conn, &frame);
- die_amqp_error(-res, "waiting for body frame");
+ die_amqp_error(res, "waiting for body frame");
if (frame.frame_type != AMQP_FRAME_BODY)
die("expected body, got frame type 0x%X",
frame.frame_type);