summaryrefslogtreecommitdiff
path: root/src/protocol.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-03-06 10:23:02 +0100
committerVicent Martí <tanoku@gmail.com>2012-04-11 19:16:10 +0200
commit84d250bfeb244d1fe82efafa296141c807135fb0 (patch)
tree1a22cb3db000fa0c12f3f07f203c89ab1aa7a09a /src/protocol.c
parent4376f7f6f4a46ecbcc0136948b68782956cd3c45 (diff)
downloadlibgit2-84d250bfeb244d1fe82efafa296141c807135fb0.tar.gz
error-handling: protocol, pkt
Diffstat (limited to 'src/protocol.c')
-rw-r--r--src/protocol.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/protocol.c b/src/protocol.c
index dd93623b3..4c4a7f79b 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -17,10 +17,12 @@ int git_protocol_store_refs(git_protocol *p, const char *data, size_t len)
const char *line_end, *ptr;
if (len == 0) { /* EOF */
- if (buf->size != 0)
- return p->error = git__throw(GIT_ERROR, "EOF and unprocessed data");
- else
+ if (buf->size != 0) {
+ giterr_set(GITERR_NET, "Unexpected EOF");
+ return p->error = -1;
+ } else {
return 0;
+ }
}
git_buf_put(buf, data, len);
@@ -34,17 +36,16 @@ int git_protocol_store_refs(git_protocol *p, const char *data, size_t len)
error = git_pkt_parse_line(&pkt, ptr, &line_end, buf->size);
if (error == GIT_ESHORTBUFFER)
return 0; /* Ask for more */
- if (error < GIT_SUCCESS)
- return p->error = git__rethrow(error, "Failed to parse pkt-line");
+ if (error < 0)
+ return p->error = -1;
git_buf_consume(buf, line_end);
- error = git_vector_insert(refs, pkt);
- if (error < GIT_SUCCESS)
- return p->error = git__rethrow(error, "Failed to add pkt to list");
+ if (git_vector_insert(refs, pkt) < 0)
+ return p->error = -1;
if (pkt->type == GIT_PKT_FLUSH)
p->flush = 1;
}
- return error;
+ return 0;
}