Commit 2878ad08316155bfaf7b2d7b3204aece13c9936a

Edward Thomson 2018-10-29T08:59:33

streams: remove unused tls functions The implementations of git_openssl_stream_new and git_mbedtls_stream_new have callers protected by #ifdefs and are never called unless compiled in. There's no need for a dummy implementation. Remove them.

diff --git a/src/streams/mbedtls.c b/src/streams/mbedtls.c
index 27e076c..fdc9f6f 100644
--- a/src/streams/mbedtls.c
+++ b/src/streams/mbedtls.c
@@ -490,23 +490,4 @@ int git_mbedtls_stream_global_init(void)
 	return 0;
 }
 
-int git_mbedtls_stream_new(git_stream **out, const char *host, const char *port)
-{
-	GIT_UNUSED(out);
-	GIT_UNUSED(host);
-	GIT_UNUSED(port);
-
-	giterr_set(GITERR_SSL, "mbedTLS is not supported in this version");
-	return -1;
-}
-
-int git_mbedtls__set_cert_location(const char *path, int is_dir)
-{
-	GIT_UNUSED(path);
-	GIT_UNUSED(is_dir);
-
-	giterr_set(GITERR_SSL, "mbedTLS is not supported in this version");
-	return -1;
-}
-
 #endif
diff --git a/src/streams/mbedtls.h b/src/streams/mbedtls.h
index effe458..7de94b9 100644
--- a/src/streams/mbedtls.h
+++ b/src/streams/mbedtls.h
@@ -13,9 +13,11 @@
 
 extern int git_mbedtls_stream_global_init(void);
 
+#ifdef GIT_MBEDTLS
+extern int git_mbedtls__set_cert_location(const char *path, int is_dir);
+
 extern int git_mbedtls_stream_new(git_stream **out, const char *host, const char *port);
 extern int git_mbedtls_stream_wrap(git_stream **out, git_stream *in, const char *host);
-
-extern int git_mbedtls__set_cert_location(const char *path, int is_dir);
+#endif
 
 #endif
diff --git a/src/streams/openssl.c b/src/streams/openssl.c
index 1092c30..e39622d 100644
--- a/src/streams/openssl.c
+++ b/src/streams/openssl.c
@@ -799,23 +799,4 @@ int git_openssl_set_locking(void)
 	return -1;
 }
 
-int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
-{
-	GIT_UNUSED(out);
-	GIT_UNUSED(host);
-	GIT_UNUSED(port);
-
-	giterr_set(GITERR_SSL, "openssl is not supported in this version");
-	return -1;
-}
-
-int git_openssl__set_cert_location(const char *file, const char *path)
-{
-	GIT_UNUSED(file);
-	GIT_UNUSED(path);
-
-	giterr_set(GITERR_SSL, "openssl is not supported in this version");
-	return -1;
-}
-
 #endif
diff --git a/src/streams/openssl.h b/src/streams/openssl.h
index 7296b7a..826d1ef 100644
--- a/src/streams/openssl.h
+++ b/src/streams/openssl.h
@@ -13,9 +13,11 @@
 
 extern int git_openssl_stream_global_init(void);
 
+#ifdef GIT_OPENSSL
+extern int git_openssl__set_cert_location(const char *file, const char *path);
+
 extern int git_openssl_stream_new(git_stream **out, const char *host, const char *port);
 extern int git_openssl_stream_wrap(git_stream **out, git_stream *in, const char *host);
-
-extern int git_openssl__set_cert_location(const char *file, const char *path);
+#endif
 
 #endif
diff --git a/src/streams/stransport.h b/src/streams/stransport.h
index 7994b36..1026e20 100644
--- a/src/streams/stransport.h
+++ b/src/streams/stransport.h
@@ -11,7 +11,11 @@
 
 #include "git2/sys/stream.h"
 
+#ifdef GIT_SECURE_TRANSPORT
+
 extern int git_stransport_stream_new(git_stream **out, const char *host, const char *port);
 extern int git_stransport_stream_wrap(git_stream **out, git_stream *in, const char *host);
 
 #endif
+
+#endif