[PATCH 07/12] connect.c: replace some use of starts_with() with skip_prefix()
- From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Date
- Dec 18, 2013, 14:53 UTC
- Message-ID
- <1387378437-20646-8-git-send-email-pclouds@gmail.com>
- In-Reply-To
- <1387378437-20646-1-git-send-email-pclouds@gmail.com>
"name" will be reset unconditionally soon after skip_prefix() returns NULL.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- connect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/connect.c b/connect.c index c763eed..1bb70aa 100644 --- a/connect.c +++ b/connect.c @@ -131,7 +131,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len, for (;;) { struct ref *ref; unsigned char old_sha1[20]; - char *name; + const char *name; int len, name_len; char *buffer = packet_buffer; @@ -145,8 +145,8 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len, if (!len) break; - if (len > 4 && starts_with(buffer, "ERR ")) - die("remote error: %s", buffer + 4); + if ((name = skip_prefix(buffer, "ERR ")) != NULL) + die("remote error: %s", name); if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ') die("protocol error: expected sha/ref, got '%s'", buffer);
-- 1.8.5.1.208.g019362e