diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/common.c | 12 |
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); |