Skip to content

Commit

Permalink
fix incorrect cast from bool to int, and an invalid return value
Browse files Browse the repository at this point in the history
  • Loading branch information
prototypicalpro committed Dec 30, 2019
1 parent c2eca31 commit f9e4d25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/SSLClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int SSLClient::connect(IPAddress ip, uint16_t port) {
// connection check
if (get_arduino_client().connected()) {
m_error("Cannot have two connections at the same time! Please create another SSLClient instance.", func_name);
return -1;
return 0;
}
// reset indexs for saftey
m_write_idx = 0;
Expand All @@ -112,16 +112,13 @@ int SSLClient::connect(const char *host, uint16_t port) {
// connection check
if (get_arduino_client().connected()) {
m_error("Cannot have two connections at the same time! Please create another SSLClient instance.", func_name);
return -1;
return 0;
}
// reset indexs for saftey
m_write_idx = 0;
// first, if we have a session, check if we're trying to resolve the same host
// as before
const bool connect_ok = get_arduino_client().connect(host, port);
// first we need our hidden client member to negotiate the socket for us,
// since most times socket functionality is implemented in hardeware.
if (!connect_ok) {
if (!get_arduino_client().connect(host, port)) {
m_error("Failed to connect using m_client. Are you connected to the internet?", func_name);
setWriteError(SSL_CLIENT_CONNECT_FAIL);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/SSLClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class SSLClient : public Client {
*
* The implementation for this function can be found in SSLClientImpl::connect_impl(const char*, uint16_t)
*
* @pre The underlying client object (passed in through the constructor) is in a non-
* @pre The underlying client object (passed in through the constructor) is in a non-
* error state, and must be able to access the IP.
* @pre SSLClient can only have one connection at a time, so the client
* object must not already be connected.
Expand Down

0 comments on commit f9e4d25

Please sign in to comment.