changeset 338:79e21c33962d

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 11 Aug 2021 14:09:43 +0200
parents 8f109cfbfc5d
children d543832987da
files Framework/Odbc/OdbcDatabase.cpp Framework/Odbc/OdbcStatement.cpp Framework/Odbc/OdbcStatement.h
diffstat 3 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Odbc/OdbcDatabase.cpp	Wed Aug 11 11:49:56 2021 +0200
+++ b/Framework/Odbc/OdbcDatabase.cpp	Wed Aug 11 14:09:43 2021 +0200
@@ -70,7 +70,7 @@
     }
       
   public:
-    OdbcImplicitTransaction(OdbcDatabase& db) :
+    explicit OdbcImplicitTransaction(OdbcDatabase& db) :
       db_(db)
     {
       SetAutoCommitTransaction(db_.GetHandle(), true);
@@ -123,7 +123,11 @@
 
           if (state == "40001")
           {
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
             throw Orthanc::OrthancException(Orthanc::ErrorCode_DatabaseCannotSerialize);
+#else
+            throw Orthanc::OrthancException(Orthanc::ErrorCode_Database, "Collision between multiple writers");
+#endif
           }
         }
         
@@ -142,7 +146,7 @@
     }
       
   public:
-    OdbcExplicitTransaction(OdbcDatabase& db) :
+    explicit OdbcExplicitTransaction(OdbcDatabase& db) :
       db_(db),
       isOpen_(true)
     {
@@ -504,7 +508,7 @@
       }
 
       
-      void CheckMSSQLEncodings(OdbcDatabase& db)
+      void CheckMSSQLEncodings(const OdbcDatabase& db)
       {
         // https://en.wikipedia.org/wiki/History_of_Microsoft_SQL_Server
         if (db.GetDbmsMajorVersion() <= 14)
@@ -541,7 +545,7 @@
       }
 
 
-      void CheckMySQLEncodings(OdbcDatabase& db)
+      void CheckMySQLEncodings(const OdbcDatabase& db)
       {
         // https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html
 
--- a/Framework/Odbc/OdbcStatement.cpp	Wed Aug 11 11:49:56 2021 +0200
+++ b/Framework/Odbc/OdbcStatement.cpp	Wed Aug 11 14:09:43 2021 +0200
@@ -74,7 +74,11 @@
             (dialect == Dialect_MySQL && native == 1213) ||
             (dialect == Dialect_MSSQL && native == 1205))
         {
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
           throw Orthanc::OrthancException(Orthanc::ErrorCode_DatabaseCannotSerialize);
+#else
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_Database, "Collision between multiple writers");
+#endif
         }
       }
       else
--- a/Framework/Odbc/OdbcStatement.h	Wed Aug 11 11:49:56 2021 +0200
+++ b/Framework/Odbc/OdbcStatement.h	Wed Aug 11 14:09:43 2021 +0200
@@ -40,7 +40,7 @@
     SQLHSTMT handle_;
       
   public:
-    OdbcStatement(SQLHSTMT databaseHandle);
+    explicit OdbcStatement(SQLHSTMT databaseHandle);
 
     ~OdbcStatement();