From 08bbf9aa20b0ad7c8f90db656c6e03389ef0e8ad Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 6 Nov 2016 01:05:14 -0400 Subject: [PATCH] TLSClient: Improved C+ Core Guidelines compliance --- src/TLSClient.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/TLSClient.cpp b/src/TLSClient.cpp index 7ad058fc7..c467517ee 100644 --- a/src/TLSClient.cpp +++ b/src/TLSClient.cpp @@ -186,7 +186,7 @@ void TLSClient::init ( if (ret < 0) { if (_debug && ret == GNUTLS_E_INVALID_REQUEST) - std::cout << "c: ERROR Priority error at: " << err << "\n"; + std::cout << "c: ERROR Priority error at: " << err << '\n'; throw format (STRING_TLS_INIT_FAIL, gnutls_strerror (ret)); } @@ -280,7 +280,7 @@ void TLSClient::connect (const std::string& host, const std::string& port) { #if GNUTLS_VERSION_NUMBER >= 0x03010a char* desc = gnutls_session_get_desc (_session); - std::cout << "c: INFO Handshake was completed: " << desc << "\n"; + std::cout << "c: INFO Handshake was completed: " << desc << '\n'; gnutls_free (desc); #else std::cout << "c: INFO Handshake was completed.\n"; @@ -315,7 +315,7 @@ int TLSClient::verify_certificate () const if (ret < 0) { if (_debug) - std::cout << "c: ERROR Certificate verification peers3 failed. " << gnutls_strerror (ret) << "\n"; + std::cout << "c: ERROR Certificate verification peers3 failed. " << gnutls_strerror (ret) << '\n'; return GNUTLS_E_CERTIFICATE_ERROR; } @@ -325,18 +325,18 @@ int TLSClient::verify_certificate () const // GNUTLS_CERT_UNEXPECTED_OWNER 1<<14 Hostname does not match if (_debug && status) - std::cout << "c: ERROR Certificate status=" << status << "\n"; + std::cout << "c: ERROR Certificate status=" << status << '\n'; #else int ret = gnutls_certificate_verify_peers2 (_session, &status); if (ret < 0) { if (_debug) - std::cout << "c: ERROR Certificate verification peers2 failed. " << gnutls_strerror (ret) << "\n"; + std::cout << "c: ERROR Certificate verification peers2 failed. " << gnutls_strerror (ret) << '\n'; return GNUTLS_E_CERTIFICATE_ERROR; } if (_debug && status) - std::cout << "c: ERROR Certificate status=" << status << "\n"; + std::cout << "c: ERROR Certificate status=" << status << '\n'; if ((status == 0) && (_trust != TLSClient::ignore_hostname)) { @@ -350,7 +350,7 @@ int TLSClient::verify_certificate () const if (cert_list_size == 0) { if (_debug) - std::cout << "c: ERROR Certificate get peers failed. " << gnutls_strerror (ret) << "\n"; + std::cout << "c: ERROR Certificate get peers failed. " << gnutls_strerror (ret) << '\n'; return GNUTLS_E_CERTIFICATE_ERROR; } @@ -358,7 +358,7 @@ int TLSClient::verify_certificate () const if (ret < 0) { if (_debug) - std::cout << "c: ERROR x509 init failed. " << gnutls_strerror (ret) << "\n"; + std::cout << "c: ERROR x509 init failed. " << gnutls_strerror (ret) << '\n'; return GNUTLS_E_CERTIFICATE_ERROR; } @@ -366,7 +366,7 @@ int TLSClient::verify_certificate () const if (ret < 0) { if (_debug) - std::cout << "c: ERROR x509 cert import. " << gnutls_strerror (ret) << "\n"; + std::cout << "c: ERROR x509 cert import. " << gnutls_strerror (ret) << '\n'; gnutls_x509_crt_deinit(cert); return GNUTLS_E_CERTIFICATE_ERROR; } @@ -374,7 +374,7 @@ int TLSClient::verify_certificate () const if (gnutls_x509_crt_check_hostname (cert, hostname) == 0) { if (_debug) - std::cout << "c: ERROR x509 cert check hostname. " << gnutls_strerror (ret) << "\n"; + std::cout << "c: ERROR x509 cert check hostname. " << gnutls_strerror (ret) << '\n'; gnutls_x509_crt_deinit(cert); return GNUTLS_E_CERTIFICATE_ERROR; } @@ -391,12 +391,12 @@ int TLSClient::verify_certificate () const if (ret < 0) { if (_debug) - std::cout << "c: ERROR certificate verification status. " << gnutls_strerror (ret) << "\n"; + std::cout << "c: ERROR certificate verification status. " << gnutls_strerror (ret) << '\n'; return GNUTLS_E_CERTIFICATE_ERROR; } if (_debug) - std::cout << "c: INFO " << out.data << "\n"; + std::cout << "c: INFO " << out.data << '\n'; gnutls_free (out.data); #endif @@ -502,7 +502,7 @@ void TLSClient::recv (std::string& data) if (received < 0 && gnutls_error_is_fatal (received) == 0) { if (_debug) - std::cout << "c: WARNING " << gnutls_strerror (received) << "\n"; + std::cout << "c: WARNING " << gnutls_strerror (received) << '\n'; } else if (received < 0) throw std::string (gnutls_strerror (received));