From 6762fe087bd75e60b3e551f94c8ecda89d374c83 Mon Sep 17 00:00:00 2001 From: Philip Kelley Date: Thu, 29 Nov 2012 08:29:26 -0500 Subject: [PATCH] Remove casts of return values of type void * --- src/transports/cred.c | 2 +- src/transports/git.c | 4 ++-- src/transports/http.c | 6 +++--- src/transports/local.c | 4 ++-- src/transports/smart.c | 2 +- src/transports/smart_pkt.c | 32 ++++++++++++++++---------------- src/transports/smart_protocol.c | 4 ++-- src/transports/winhttp.c | 10 +++++----- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/transports/cred.c b/src/transports/cred.c index e137ca9ac..8c97924e4 100644 --- a/src/transports/cred.c +++ b/src/transports/cred.c @@ -34,7 +34,7 @@ int git_cred_userpass_plaintext_new( if (!cred) return -1; - c = (git_cred_userpass_plaintext *)git__malloc(sizeof(git_cred_userpass_plaintext)); + c = git__malloc(sizeof(git_cred_userpass_plaintext)); GITERR_CHECK_ALLOC(c); c->parent.credtype = GIT_CREDTYPE_USERPASS_PLAINTEXT; diff --git a/src/transports/git.c b/src/transports/git.c index c931dd82b..e8a7bde36 100644 --- a/src/transports/git.c +++ b/src/transports/git.c @@ -154,7 +154,7 @@ static int git_stream_alloc( if (!stream) return -1; - s = (git_stream *)git__calloc(sizeof(git_stream), 1); + s = git__calloc(sizeof(git_stream), 1); GITERR_CHECK_ALLOC(s); s->parent.subtransport = &t->parent; @@ -335,7 +335,7 @@ int git_smart_subtransport_git(git_smart_subtransport **out, git_transport *owne if (!out) return -1; - t = (git_subtransport *)git__calloc(sizeof(git_subtransport), 1); + t = git__calloc(sizeof(git_subtransport), 1); GITERR_CHECK_ALLOC(t); t->owner = owner; diff --git a/src/transports/http.c b/src/transports/http.c index b8fc4fe79..4ef99e3f5 100644 --- a/src/transports/http.c +++ b/src/transports/http.c @@ -545,7 +545,7 @@ static int http_stream_write_chunked( int count = MIN(CHUNK_SIZE - s->chunk_buffer_len, len); if (!s->chunk_buffer) - s->chunk_buffer = (char *)git__malloc(CHUNK_SIZE); + s->chunk_buffer = git__malloc(CHUNK_SIZE); memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count); s->chunk_buffer_len += count; @@ -626,7 +626,7 @@ static int http_stream_alloc(http_subtransport *t, if (!stream) return -1; - s = (http_stream *)git__calloc(sizeof(http_stream), 1); + s = git__calloc(sizeof(http_stream), 1); GITERR_CHECK_ALLOC(s); s->parent.subtransport = &t->parent; @@ -838,7 +838,7 @@ int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *own if (!out) return -1; - t = (http_subtransport *)git__calloc(sizeof(http_subtransport), 1); + t = git__calloc(sizeof(http_subtransport), 1); GITERR_CHECK_ALLOC(t); t->owner = (transport_smart *)owner; diff --git a/src/transports/local.c b/src/transports/local.c index db9a08a57..62e8024b5 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -43,7 +43,7 @@ static int add_ref(transport_local *t, const char *name) git_object *obj = NULL, *target = NULL; git_buf buf = GIT_BUF_INIT; - head = (git_remote_head *)git__calloc(1, sizeof(git_remote_head)); + head = git__calloc(1, sizeof(git_remote_head)); GITERR_CHECK_ALLOC(head); head->name = git__strdup(name); @@ -78,7 +78,7 @@ static int add_ref(transport_local *t, const char *name) } /* And if it's a tag, peel it, and add it to the list */ - head = (git_remote_head *)git__calloc(1, sizeof(git_remote_head)); + head = git__calloc(1, sizeof(git_remote_head)); GITERR_CHECK_ALLOC(head); if (git_buf_join(&buf, 0, name, peeled) < 0) return -1; diff --git a/src/transports/smart.c b/src/transports/smart.c index 00f8832e0..94d389b52 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -300,7 +300,7 @@ int git_transport_smart(git_transport **out, git_remote *owner, void *param) if (!param) return -1; - t = (transport_smart *)git__calloc(sizeof(transport_smart), 1); + t = git__calloc(sizeof(transport_smart), 1); GITERR_CHECK_ALLOC(t); t->parent.set_callbacks = git_smart__set_callbacks; diff --git a/src/transports/smart_pkt.c b/src/transports/smart_pkt.c index df9863728..c0674301b 100644 --- a/src/transports/smart_pkt.c +++ b/src/transports/smart_pkt.c @@ -30,7 +30,7 @@ static int flush_pkt(git_pkt **out) { git_pkt *pkt; - pkt = (git_pkt *) git__malloc(sizeof(git_pkt)); + pkt = git__malloc(sizeof(git_pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_FLUSH; @@ -46,7 +46,7 @@ static int ack_pkt(git_pkt **out, const char *line, size_t len) GIT_UNUSED(line); GIT_UNUSED(len); - pkt = (git_pkt_ack *) git__calloc(1, sizeof(git_pkt_ack)); + pkt = git__calloc(1, sizeof(git_pkt_ack)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_ACK; @@ -73,7 +73,7 @@ static int nak_pkt(git_pkt **out) { git_pkt *pkt; - pkt = (git_pkt *) git__malloc(sizeof(git_pkt)); + pkt = git__malloc(sizeof(git_pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_NAK; @@ -86,7 +86,7 @@ static int pack_pkt(git_pkt **out) { git_pkt *pkt; - pkt = (git_pkt *) git__malloc(sizeof(git_pkt)); + pkt = git__malloc(sizeof(git_pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_PACK; @@ -99,7 +99,7 @@ static int comment_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_comment *pkt; - pkt = (git_pkt_comment *) git__malloc(sizeof(git_pkt_comment) + len + 1); + pkt = git__malloc(sizeof(git_pkt_comment) + len + 1); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_COMMENT; @@ -118,7 +118,7 @@ static int err_pkt(git_pkt **out, const char *line, size_t len) /* Remove "ERR " from the line */ line += 4; len -= 4; - pkt = (git_pkt_err *) git__malloc(sizeof(git_pkt_err) + len + 1); + pkt = git__malloc(sizeof(git_pkt_err) + len + 1); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_ERR; @@ -136,7 +136,7 @@ static int data_pkt(git_pkt **out, const char *line, size_t len) line++; len--; - pkt = (git_pkt_data *) git__malloc(sizeof(git_pkt_data) + len); + pkt = git__malloc(sizeof(git_pkt_data) + len); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_DATA; @@ -154,7 +154,7 @@ static int progress_pkt(git_pkt **out, const char *line, size_t len) line++; len--; - pkt = (git_pkt_progress *) git__malloc(sizeof(git_pkt_progress) + len); + pkt = git__malloc(sizeof(git_pkt_progress) + len); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_PROGRESS; @@ -174,7 +174,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len) int error; git_pkt_ref *pkt; - pkt = (git_pkt_ref *) git__malloc(sizeof(git_pkt_ref)); + pkt = git__malloc(sizeof(git_pkt_ref)); GITERR_CHECK_ALLOC(pkt); memset(pkt, 0x0, sizeof(git_pkt_ref)); @@ -196,7 +196,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len) if (line[len - 1] == '\n') --len; - pkt->head.name = (char *) git__malloc(len + 1); + pkt->head.name = git__malloc(len + 1); GITERR_CHECK_ALLOC(pkt->head.name); memcpy(pkt->head.name, line, len); @@ -219,7 +219,7 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len) git_pkt_ok *pkt; const char *ptr; - pkt = (git_pkt_ok *) git__malloc(sizeof(*pkt)); + pkt = git__malloc(sizeof(*pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_OK; @@ -228,7 +228,7 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len) ptr = strchr(line, '\n'); len = ptr - line; - pkt->ref = (char *) git__malloc(len + 1); + pkt->ref = git__malloc(len + 1); GITERR_CHECK_ALLOC(pkt->ref); memcpy(pkt->ref, line, len); @@ -243,7 +243,7 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len) git_pkt_ng *pkt; const char *ptr; - pkt = (git_pkt_ng *) git__malloc(sizeof(*pkt)); + pkt = git__malloc(sizeof(*pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_NG; @@ -252,7 +252,7 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len) ptr = strchr(line, ' '); len = ptr - line; - pkt->ref = (char *) git__malloc(len + 1); + pkt->ref = git__malloc(len + 1); GITERR_CHECK_ALLOC(pkt->ref); memcpy(pkt->ref, line, len); @@ -262,7 +262,7 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len) ptr = strchr(line, '\n'); len = ptr - line; - pkt->msg = (char *) git__malloc(len + 1); + pkt->msg = git__malloc(len + 1); GITERR_CHECK_ALLOC(pkt->msg); memcpy(pkt->msg, line, len); @@ -278,7 +278,7 @@ static int unpack_pkt(git_pkt **out, const char *line, size_t len) GIT_UNUSED(len); - pkt = (git_pkt_unpack *) git__malloc(sizeof(*pkt)); + pkt = git__malloc(sizeof(*pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_UNPACK; diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c index 7a604aaff..80ff72681 100644 --- a/src/transports/smart_protocol.c +++ b/src/transports/smart_protocol.c @@ -597,7 +597,7 @@ static int parse_report(gitno_buffer *buf, git_push *push) gitno_consume(buf, line_end); if (pkt->type == GIT_PKT_OK) { - push_status *status = (push_status *) git__malloc(sizeof(push_status)); + push_status *status = git__malloc(sizeof(push_status)); GITERR_CHECK_ALLOC(status); status->ref = git__strdup(((git_pkt_ok *)pkt)->ref); status->msg = NULL; @@ -610,7 +610,7 @@ static int parse_report(gitno_buffer *buf, git_push *push) } if (pkt->type == GIT_PKT_NG) { - push_status *status = (push_status *) git__malloc(sizeof(push_status)); + push_status *status = git__malloc(sizeof(push_status)); GITERR_CHECK_ALLOC(status); status->ref = git__strdup(((git_pkt_ng *)pkt)->ref); status->msg = git__strdup(((git_pkt_ng *)pkt)->msg); diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c index fa1bbb7e3..dab25f9fb 100644 --- a/src/transports/winhttp.c +++ b/src/transports/winhttp.c @@ -104,7 +104,7 @@ static int apply_basic_credential(HINTERNET request, git_cred *cred) goto on_error; } - wide = (wchar_t *)git__malloc(wide_len * sizeof(wchar_t)); + wide = git__malloc(wide_len * sizeof(wchar_t)); if (!wide) goto on_error; @@ -389,7 +389,7 @@ replay: return -1; } - buffer = (char *)git__malloc(CACHED_POST_BODY_BUF_SIZE); + buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE); while (len > 0) { DWORD bytes_written; @@ -702,7 +702,7 @@ static int winhttp_stream_write_chunked( int count = MIN(CACHED_POST_BODY_BUF_SIZE - s->chunk_buffer_len, len); if (!s->chunk_buffer) - s->chunk_buffer = (char *)git__malloc(CACHED_POST_BODY_BUF_SIZE); + s->chunk_buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE); memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count); s->chunk_buffer_len += count; @@ -756,7 +756,7 @@ static int winhttp_stream_alloc(winhttp_subtransport *t, winhttp_stream **stream if (!stream) return -1; - s = (winhttp_stream *)git__calloc(sizeof(winhttp_stream), 1); + s = git__calloc(sizeof(winhttp_stream), 1); GITERR_CHECK_ALLOC(s); s->parent.subtransport = &t->parent; @@ -988,7 +988,7 @@ int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *own if (!out) return -1; - t = (winhttp_subtransport *)git__calloc(sizeof(winhttp_subtransport), 1); + t = git__calloc(sizeof(winhttp_subtransport), 1); GITERR_CHECK_ALLOC(t); t->owner = (transport_smart *)owner;