]> granicus.if.org Git - neomutt/commitdiff
conn: define mutt_ssl_socket_setup even when building without SSL
authorDamien Riegel <damien.riegel@gmail.com>
Wed, 8 Nov 2017 20:26:39 +0000 (15:26 -0500)
committerRichard Russon <rich@flatcap.org>
Thu, 12 Apr 2018 08:51:56 +0000 (09:51 +0100)
Error conditions were duplicated for builds with and without SSL. This
can be factorized by letting mutt_ssl_socket_setup be defined even when
SSL is not enabled.

conn/conn.h
conn/ssl.h
mutt_socket.c

index a4f822b31e702e02a9c265e9f85424370e7f485e..ec0ae087695d781cd9f93b20eb90747a968fa10c 100644 (file)
 #include "connection.h"
 #include "sasl_plain.h"
 #include "socket.h"
+#include "ssl.h"
 #include "tunnel.h"
 #ifdef USE_SASL
 #include "sasl.h"
 #endif
-#ifdef USE_SSL
-#include "ssl.h"
-#endif
 
 #endif /* _CONN_CONN_H */
index c14ccf74693fc11614e1433a31f1186e83a29247..8a2b7ce80036564e74943dc05df59e353859ff5b 100644 (file)
@@ -28,6 +28,11 @@ struct Connection;
 
 int mutt_ssl_starttls(struct Connection *conn);
 int mutt_ssl_socket_setup(struct Connection *conn);
+#else
+static inline int mutt_ssl_socket_setup(struct Connection *conn)
+{
+  return -1;
+}
 #endif
 
 #endif /* _CONN_SSL_H */
index b00536837d0f79cbaf1dd7dac2aa838b021a2039..9477d688ff97ba0b3705ca01130b225b002617e1 100644 (file)
@@ -92,18 +92,16 @@ struct Connection *mutt_conn_find(const struct Connection *start, const struct A
     mutt_tunnel_socket_setup(conn);
   else if (account->flags & MUTT_ACCT_SSL)
   {
-#ifdef USE_SSL
     if (mutt_ssl_socket_setup(conn) < 0)
     {
+#ifndef USE_SSL
+      /* that's probably why it failed */
+      mutt_error(_("SSL is unavailable, cannot connect to %s"), account->host);
+#endif
       mutt_socket_free(conn);
+
       return NULL;
     }
-#else
-    mutt_error(_("SSL is unavailable, cannot connect to %s"), account->host);
-    mutt_socket_free(conn);
-
-    return NULL;
-#endif
   }
   else
   {