Commit b51789ac by Etienne Samson Committed by Patrick Steinhardt

transports: make use of the `GIT_CONTAINER_OF` macro

parent 2e246474
...@@ -1144,7 +1144,7 @@ static int http_stream_write_chunked( ...@@ -1144,7 +1144,7 @@ static int http_stream_write_chunked(
const char *buffer, const char *buffer,
size_t len) size_t len)
{ {
http_stream *s = (http_stream *)stream; http_stream *s = GIT_CONTAINER_OF(stream, http_stream, parent);
http_subtransport *t = OWNING_SUBTRANSPORT(s); http_subtransport *t = OWNING_SUBTRANSPORT(s);
assert(t->connected); assert(t->connected);
...@@ -1218,7 +1218,7 @@ static int http_stream_write_single( ...@@ -1218,7 +1218,7 @@ static int http_stream_write_single(
const char *buffer, const char *buffer,
size_t len) size_t len)
{ {
http_stream *s = (http_stream *)stream; http_stream *s = GIT_CONTAINER_OF(stream, http_stream, parent);
http_subtransport *t = OWNING_SUBTRANSPORT(s); http_subtransport *t = OWNING_SUBTRANSPORT(s);
git_buf request = GIT_BUF_INIT; git_buf request = GIT_BUF_INIT;
...@@ -1252,7 +1252,7 @@ on_error: ...@@ -1252,7 +1252,7 @@ on_error:
static void http_stream_free(git_smart_subtransport_stream *stream) static void http_stream_free(git_smart_subtransport_stream *stream)
{ {
http_stream *s = (http_stream *)stream; http_stream *s = GIT_CONTAINER_OF(stream, http_stream, parent);
if (s->chunk_buffer) if (s->chunk_buffer)
git__free(s->chunk_buffer); git__free(s->chunk_buffer);
...@@ -1365,7 +1365,7 @@ static int http_action( ...@@ -1365,7 +1365,7 @@ static int http_action(
const char *url, const char *url,
git_smart_service_t action) git_smart_service_t action)
{ {
http_subtransport *t = (http_subtransport *)subtransport; http_subtransport *t = GIT_CONTAINER_OF(subtransport, http_subtransport, parent);
int ret; int ret;
assert(stream); assert(stream);
...@@ -1419,7 +1419,7 @@ static void free_auth_contexts(git_vector *contexts) ...@@ -1419,7 +1419,7 @@ static void free_auth_contexts(git_vector *contexts)
static int http_close(git_smart_subtransport *subtransport) static int http_close(git_smart_subtransport *subtransport)
{ {
http_subtransport *t = (http_subtransport *) subtransport; http_subtransport *t = GIT_CONTAINER_OF(subtransport, http_subtransport, parent);
clear_parser_state(t); clear_parser_state(t);
...@@ -1459,7 +1459,7 @@ static int http_close(git_smart_subtransport *subtransport) ...@@ -1459,7 +1459,7 @@ static int http_close(git_smart_subtransport *subtransport)
static void http_free(git_smart_subtransport *subtransport) static void http_free(git_smart_subtransport *subtransport)
{ {
http_subtransport *t = (http_subtransport *) subtransport; http_subtransport *t = GIT_CONTAINER_OF(subtransport, http_subtransport, parent);
http_close(subtransport); http_close(subtransport);
......
...@@ -63,7 +63,7 @@ static int git_smart__set_callbacks( ...@@ -63,7 +63,7 @@ static int git_smart__set_callbacks(
git_transport_certificate_check_cb certificate_check_cb, git_transport_certificate_check_cb certificate_check_cb,
void *message_cb_payload) void *message_cb_payload)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
t->progress_cb = progress_cb; t->progress_cb = progress_cb;
t->error_cb = error_cb; t->error_cb = error_cb;
...@@ -128,7 +128,7 @@ static int git_smart__set_custom_headers( ...@@ -128,7 +128,7 @@ static int git_smart__set_custom_headers(
git_transport *transport, git_transport *transport,
const git_strarray *custom_headers) const git_strarray *custom_headers)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
size_t i; size_t i;
if (t->custom_headers.count) if (t->custom_headers.count)
...@@ -212,7 +212,7 @@ static int git_smart__connect( ...@@ -212,7 +212,7 @@ static int git_smart__connect(
int direction, int direction,
int flags) int flags)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
git_smart_subtransport_stream *stream; git_smart_subtransport_stream *stream;
int error; int error;
git_pkt *pkt; git_pkt *pkt;
...@@ -315,7 +315,7 @@ cleanup: ...@@ -315,7 +315,7 @@ cleanup:
static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transport *transport) static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transport *transport)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
if (!t->have_refs) { if (!t->have_refs) {
git_error_set(GIT_ERROR_NET, "the transport has not yet loaded the refs"); git_error_set(GIT_ERROR_NET, "the transport has not yet loaded the refs");
...@@ -330,7 +330,7 @@ static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transpo ...@@ -330,7 +330,7 @@ static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transpo
int git_smart__negotiation_step(git_transport *transport, void *data, size_t len) int git_smart__negotiation_step(git_transport *transport, void *data, size_t len)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
git_smart_subtransport_stream *stream; git_smart_subtransport_stream *stream;
int error; int error;
...@@ -387,21 +387,21 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream ...@@ -387,21 +387,21 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream
static void git_smart__cancel(git_transport *transport) static void git_smart__cancel(git_transport *transport)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
git_atomic_set(&t->cancelled, 1); git_atomic_set(&t->cancelled, 1);
} }
static int git_smart__is_connected(git_transport *transport) static int git_smart__is_connected(git_transport *transport)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
return t->connected; return t->connected;
} }
static int git_smart__read_flags(git_transport *transport, int *flags) static int git_smart__read_flags(git_transport *transport, int *flags)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
*flags = t->flags; *flags = t->flags;
...@@ -410,7 +410,7 @@ static int git_smart__read_flags(git_transport *transport, int *flags) ...@@ -410,7 +410,7 @@ static int git_smart__read_flags(git_transport *transport, int *flags)
static int git_smart__close(git_transport *transport) static int git_smart__close(git_transport *transport)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
git_vector *common = &t->common; git_vector *common = &t->common;
unsigned int i; unsigned int i;
git_pkt *p; git_pkt *p;
...@@ -447,7 +447,7 @@ static int git_smart__close(git_transport *transport) ...@@ -447,7 +447,7 @@ static int git_smart__close(git_transport *transport)
static void git_smart__free(git_transport *transport) static void git_smart__free(git_transport *transport)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
git_vector *refs = &t->refs; git_vector *refs = &t->refs;
unsigned int i; unsigned int i;
git_pkt *p; git_pkt *p;
...@@ -479,7 +479,7 @@ static int ref_name_cmp(const void *a, const void *b) ...@@ -479,7 +479,7 @@ static int ref_name_cmp(const void *a, const void *b)
int git_transport_smart_certificate_check(git_transport *transport, git_cert *cert, int valid, const char *hostname) int git_transport_smart_certificate_check(git_transport *transport, git_cert *cert, int valid, const char *hostname)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
assert(transport && cert && hostname); assert(transport && cert && hostname);
...@@ -491,7 +491,7 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce ...@@ -491,7 +491,7 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce
int git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods) int git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods)
{ {
transport_smart *t = (transport_smart *)transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
assert(out && transport); assert(out && transport);
...@@ -503,7 +503,7 @@ int git_transport_smart_credentials(git_cred **out, git_transport *transport, co ...@@ -503,7 +503,7 @@ int git_transport_smart_credentials(git_cred **out, git_transport *transport, co
int git_transport_smart_proxy_options(git_proxy_options *out, git_transport *transport) int git_transport_smart_proxy_options(git_proxy_options *out, git_transport *transport)
{ {
transport_smart *t = (transport_smart *) transport; transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
return git_proxy_options_dup(out, &t->proxy); return git_proxy_options_dup(out, &t->proxy);
} }
......
...@@ -132,7 +132,7 @@ static int ssh_stream_read( ...@@ -132,7 +132,7 @@ static int ssh_stream_read(
size_t *bytes_read) size_t *bytes_read)
{ {
int rc; int rc;
ssh_stream *s = (ssh_stream *)stream; ssh_stream *s = GIT_CONTAINER_OF(stream, ssh_stream, parent);
*bytes_read = 0; *bytes_read = 0;
...@@ -170,7 +170,7 @@ static int ssh_stream_write( ...@@ -170,7 +170,7 @@ static int ssh_stream_write(
const char *buffer, const char *buffer,
size_t len) size_t len)
{ {
ssh_stream *s = (ssh_stream *)stream; ssh_stream *s = GIT_CONTAINER_OF(stream, ssh_stream, parent);
size_t off = 0; size_t off = 0;
ssize_t ret = 0; ssize_t ret = 0;
...@@ -196,7 +196,7 @@ static int ssh_stream_write( ...@@ -196,7 +196,7 @@ static int ssh_stream_write(
static void ssh_stream_free(git_smart_subtransport_stream *stream) static void ssh_stream_free(git_smart_subtransport_stream *stream)
{ {
ssh_stream *s = (ssh_stream *)stream; ssh_stream *s = GIT_CONTAINER_OF(stream, ssh_stream, parent);
ssh_subtransport *t; ssh_subtransport *t;
if (!stream) if (!stream)
...@@ -479,7 +479,7 @@ static int _git_ssh_session_create( ...@@ -479,7 +479,7 @@ static int _git_ssh_session_create(
{ {
int rc = 0; int rc = 0;
LIBSSH2_SESSION* s; LIBSSH2_SESSION* s;
git_socket_stream *socket = (git_socket_stream *) io; git_socket_stream *socket = GIT_CONTAINER_OF(io, git_socket_stream, parent);
assert(session); assert(session);
...@@ -730,7 +730,7 @@ static int _ssh_action( ...@@ -730,7 +730,7 @@ static int _ssh_action(
const char *url, const char *url,
git_smart_service_t action) git_smart_service_t action)
{ {
ssh_subtransport *t = (ssh_subtransport *) subtransport; ssh_subtransport *t = GIT_CONTAINER_OF(subtransport, ssh_subtransport, parent);
switch (action) { switch (action) {
case GIT_SERVICE_UPLOADPACK_LS: case GIT_SERVICE_UPLOADPACK_LS:
...@@ -752,7 +752,7 @@ static int _ssh_action( ...@@ -752,7 +752,7 @@ static int _ssh_action(
static int _ssh_close(git_smart_subtransport *subtransport) static int _ssh_close(git_smart_subtransport *subtransport)
{ {
ssh_subtransport *t = (ssh_subtransport *) subtransport; ssh_subtransport *t = GIT_CONTAINER_OF(subtransport, ssh_subtransport, parent);
assert(!t->current_stream); assert(!t->current_stream);
...@@ -763,7 +763,7 @@ static int _ssh_close(git_smart_subtransport *subtransport) ...@@ -763,7 +763,7 @@ static int _ssh_close(git_smart_subtransport *subtransport)
static void _ssh_free(git_smart_subtransport *subtransport) static void _ssh_free(git_smart_subtransport *subtransport)
{ {
ssh_subtransport *t = (ssh_subtransport *) subtransport; ssh_subtransport *t = GIT_CONTAINER_OF(subtransport, ssh_subtransport, parent);
assert(!t->current_stream); assert(!t->current_stream);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment