Code

Convert memcpy(a,b,20) to hashcpy(a,b).
[git.git] / connect.c
index 4422a0d8d38c225c6c4716ce8ff826bc1acbd981..e501ccce259e7ac1a4e92fecc713950e82d3b71a 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -10,7 +10,7 @@
 #include <netdb.h>
 #include <signal.h>
 
-static char *server_capabilities = NULL;
+static char *server_capabilities;
 
 static int check_ref(const char *name, int len, unsigned int flags)
 {
@@ -77,7 +77,7 @@ struct ref **get_remote_heads(int in, struct ref **list,
                if (nr_match && !path_match(name, nr_match, match))
                        continue;
                ref = xcalloc(1, sizeof(*ref) + len - 40);
-               memcpy(ref->old_sha1, old_sha1, 20);
+               hashcpy(ref->old_sha1, old_sha1);
                memcpy(ref->name, buffer + 41, len - 40);
                *list = ref;
                list = &ref->next;
@@ -208,7 +208,7 @@ static struct ref *try_explicit_object_name(const char *name)
        len = strlen(name) + 1;
        ref = xcalloc(1, sizeof(*ref) + len);
        memcpy(ref->name, name, len);
-       memcpy(ref->new_sha1, sha1, 20);
+       hashcpy(ref->new_sha1, sha1);
        return ref;
 }
 
@@ -318,7 +318,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
                        int len = strlen(src->name) + 1;
                        dst_peer = xcalloc(1, sizeof(*dst_peer) + len);
                        memcpy(dst_peer->name, src->name, len);
-                       memcpy(dst_peer->new_sha1, src->new_sha1, 20);
+                       hashcpy(dst_peer->new_sha1, src->new_sha1);
                        link_dst_tail(dst_peer, dst_tail);
                }
                dst_peer->peer_ref = src;
@@ -493,8 +493,8 @@ static void git_tcp_connect(int fd[2], char *host)
 }
 
 
-static char *git_proxy_command = NULL;
-static const char *rhost_name = NULL;
+static char *git_proxy_command;
+static const char *rhost_name;
 static int rhost_len;
 
 static int git_proxy_command_options(const char *var, const char *value)
@@ -737,14 +737,9 @@ int git_connect(int fd[2], char *url, const char *prog)
 
 int finish_connect(pid_t pid)
 {
-       int ret;
-
-       for (;;) {
-               ret = waitpid(pid, NULL, 0);
-               if (!ret)
-                       break;
+       while (waitpid(pid, NULL, 0) < 0) {
                if (errno != EINTR)
-                       break;
+                       return -1;
        }
-       return ret;
+       return 0;
 }