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(
const char *buffer,
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);
assert(t->connected);
......@@ -1218,7 +1218,7 @@ static int http_stream_write_single(
const char *buffer,
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);
git_buf request = GIT_BUF_INIT;
......@@ -1252,7 +1252,7 @@ on_error:
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)
git__free(s->chunk_buffer);
......@@ -1365,7 +1365,7 @@ static int http_action(
const char *url,
git_smart_service_t action)
{
http_subtransport *t = (http_subtransport *)subtransport;
http_subtransport *t = GIT_CONTAINER_OF(subtransport, http_subtransport, parent);
int ret;
assert(stream);
......@@ -1419,7 +1419,7 @@ static void free_auth_contexts(git_vector *contexts)
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);
......@@ -1459,7 +1459,7 @@ static int http_close(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);
......
......@@ -63,7 +63,7 @@ static int git_smart__set_callbacks(
git_transport_certificate_check_cb certificate_check_cb,
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->error_cb = error_cb;
......@@ -128,7 +128,7 @@ static int git_smart__set_custom_headers(
git_transport *transport,
const git_strarray *custom_headers)
{
transport_smart *t = (transport_smart *)transport;
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
size_t i;
if (t->custom_headers.count)
......@@ -212,7 +212,7 @@ static int git_smart__connect(
int direction,
int flags)
{
transport_smart *t = (transport_smart *)transport;
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
git_smart_subtransport_stream *stream;
int error;
git_pkt *pkt;
......@@ -315,7 +315,7 @@ cleanup:
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) {
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
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;
int error;
......@@ -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)
{
transport_smart *t = (transport_smart *)transport;
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
git_atomic_set(&t->cancelled, 1);
}
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;
}
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;
......@@ -410,7 +410,7 @@ static int git_smart__read_flags(git_transport *transport, int *flags)
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;
unsigned int i;
git_pkt *p;
......@@ -447,7 +447,7 @@ static int git_smart__close(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;
unsigned int i;
git_pkt *p;
......@@ -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)
{
transport_smart *t = (transport_smart *)transport;
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
assert(transport && cert && hostname);
......@@ -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)
{
transport_smart *t = (transport_smart *)transport;
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
assert(out && transport);
......@@ -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)
{
transport_smart *t = (transport_smart *) transport;
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
return git_proxy_options_dup(out, &t->proxy);
}
......
......@@ -132,7 +132,7 @@ static int ssh_stream_read(
size_t *bytes_read)
{
int rc;
ssh_stream *s = (ssh_stream *)stream;
ssh_stream *s = GIT_CONTAINER_OF(stream, ssh_stream, parent);
*bytes_read = 0;
......@@ -170,7 +170,7 @@ static int ssh_stream_write(
const char *buffer,
size_t len)
{
ssh_stream *s = (ssh_stream *)stream;
ssh_stream *s = GIT_CONTAINER_OF(stream, ssh_stream, parent);
size_t off = 0;
ssize_t ret = 0;
......@@ -196,7 +196,7 @@ static int ssh_stream_write(
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;
if (!stream)
......@@ -479,7 +479,7 @@ static int _git_ssh_session_create(
{
int rc = 0;
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);
......@@ -730,7 +730,7 @@ static int _ssh_action(
const char *url,
git_smart_service_t action)
{
ssh_subtransport *t = (ssh_subtransport *) subtransport;
ssh_subtransport *t = GIT_CONTAINER_OF(subtransport, ssh_subtransport, parent);
switch (action) {
case GIT_SERVICE_UPLOADPACK_LS:
......@@ -752,7 +752,7 @@ static int _ssh_action(
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);
......@@ -763,7 +763,7 @@ static int _ssh_close(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);
......
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