summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Bargren <cbargren@gmail.com>2015-12-28 07:43:24 -0700
committerChris Bargren <cbargren@gmail.com>2015-12-28 11:45:00 -0700
commit4df17045c178194c5617c7df24bbc762895a222b (patch)
tree69c86a1826f4d6fec792d8a16c479e877ccd5263
parent0b1e6e42e3cc94e746a3a9453dd9b0702062b757 (diff)
downloadlibgit2-4df17045c178194c5617c7df24bbc762895a222b.tar.gz
Removing #define for SSH_PREFIX_COUNT and using ARRAY_SIZE instead
Also moving var declarations to top of blocks to support bad old compilers
-rw-r--r--src/transports/ssh.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index c1f97fa47..700998bf0 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -20,8 +20,7 @@
#define OWNING_SUBTRANSPORT(s) ((ssh_subtransport *)(s)->parent.subtransport)
-static const char * ssh_prefixes[] = { "ssh://", "ssh+git://", "git+ssh://" };
-#define SSH_PREFIX_COUNT (sizeof(ssh_prefixes) / sizeof(ssh_prefixes[0]))
+static const char *ssh_prefixes[] = { "ssh://", "ssh+git://", "git+ssh://" };
static const char cmd_uploadpack[] = "git-upload-pack";
static const char cmd_receivepack[] = "git-receive-pack";
@@ -64,9 +63,9 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
{
char *repo;
int len;
+ size_t i;
- size_t i = 0;
- for (i = 0; i < SSH_PREFIX_COUNT; ++i) {
+ for (i = 0; i < ARRAY_SIZE(ssh_prefixes); ++i) {
const char *p = ssh_prefixes[i];
if (!git__prefixcmp(url, p)) {
@@ -503,6 +502,7 @@ static int _git_ssh_setup_conn(
char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL;
const char *default_port="22";
int auth_methods, error = 0;
+ size_t i;
ssh_stream *s;
git_cred *cred = NULL;
LIBSSH2_SESSION* session=NULL;
@@ -518,8 +518,7 @@ static int _git_ssh_setup_conn(
s->session = NULL;
s->channel = NULL;
- size_t i = 0;
- for (i = 0; i < SSH_PREFIX_COUNT; ++i) {
+ for (i = 0; i < ARRAY_SIZE(ssh_prefixes); ++i) {
const char *p = ssh_prefixes[i];
if (!git__prefixcmp(url, p)) {