]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutlsxx: add const and explicit specifiers where possible
authorDaiki Ueno <ueno@gnu.org>
Wed, 17 Feb 2021 05:38:41 +0000 (06:38 +0100)
committerDaiki Ueno <ueno@gnu.org>
Wed, 17 Feb 2021 05:41:16 +0000 (06:41 +0100)
Flagged by cppcheck.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/gnutlsxx.cpp
lib/includes/gnutls/gnutlsxx.h

index 3613502aba1c6c2242f52252be0a50911c5d846f..f87490d3715579b4a39a360ac631dba4ac3083cc 100644 (file)
@@ -397,7 +397,7 @@ namespace gnutls
     gnutls_db_remove_session (s);
   }
 
-  bool server_session::db_check_entry (gnutls_datum_t & session_data) const
+  bool server_session::db_check_entry (const gnutls_datum_t & session_data) const
   {
     int ret = gnutls_db_check_entry (s, session_data);
 
@@ -416,7 +416,7 @@ namespace gnutls
     gnutls_credentials_clear (s);
   }
 
-  void session::set_credentials (credentials & cred)
+  void session::set_credentials (const credentials & cred)
   {
     RETWRAP (gnutls_credentials_set (s, cred.get_type (), cred.ptr ()));
   }
index eeefb798a398474e205b47d0b9c41d8d81fe3089..23bbd4ea36f6b415bd7b2c855b17144720c5b64a 100644 (file)
@@ -42,7 +42,7 @@ namespace gnutls {
 
        class exception:public std::exception {
              public:
-               exception(int x);
+               explicit exception(int x);
                const char *what() const throw();
                int get_code();
              protected:
@@ -104,7 +104,7 @@ namespace gnutls {
              protected:
                gnutls_session_t s;
              public:
-               session(unsigned int);
+               explicit session(unsigned int);
                 virtual ~ session();
 
                gnutls_session_t ptr();
@@ -173,7 +173,7 @@ namespace gnutls {
                void set_max_handshake_packet_length(size_t max);
 
                void clear_credentials();
-               void set_credentials(class credentials & cred);
+               void set_credentials(const class credentials & cred);
 
                void set_transport_ptr(gnutls_transport_ptr_t ptr);
                void set_transport_ptr(gnutls_transport_ptr_t recv_ptr,
@@ -239,7 +239,7 @@ namespace gnutls {
        class server_session:public session {
              public:
                server_session();
-               server_session(int flags);
+               explicit server_session(int flags);
                ~server_session();
                void db_remove() const;
 
@@ -247,7 +247,7 @@ namespace gnutls {
                void set_db(const DB & db);
 
                // returns true if session is expired
-               bool db_check_entry(gnutls_datum_t & session_data) const;
+               bool db_check_entry(const gnutls_datum_t & session_data) const;
 
                // server side only
                const char *get_srp_username() const;
@@ -264,7 +264,7 @@ namespace gnutls {
        class client_session:public session {
              public:
                client_session();
-               client_session(int flags);
+               explicit client_session(int flags);
                ~client_session();
 
                void set_verify_cert(const char *hostname, unsigned flags);
@@ -281,7 +281,7 @@ namespace gnutls {
                } gnutls_credentials_type_t get_type() const;
              protected:
                friend class session;
-               credentials(gnutls_credentials_type_t t);
+               explicit credentials(gnutls_credentials_type_t t);
                void *ptr() const;
                void set_ptr(void *ptr);
                gnutls_credentials_type_t type;