Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-83008

Coverty Report for snippets/sql

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.15
    • Fix Version/s: 5.15.0 Beta3
    • Component/s: Documentation, SQL Support
    • Labels:
      None
    • Commits:
      3f3e200aef80ac33e6bf116c656ebc28d5918836 (qt/qtbase/5.15)
    • Sprint:
      Da Vinci sprint 6

      Description

      Coverty reports multiple Error handling issues (CHECKED_RETURN), (BAD_COMPARE) for the
      SQL snippets in 5.15:

      ** CID 274217:  Error handling issues  (CHECKED_RETURN)
      /qtbase/src/sql/doc/snippets/code/doc_src_sql-driver.cpp: 99 in exProc()()
      
      
      ________________________________________________________________________________________________________
      *** CID 274217:  Error handling issues  (CHECKED_RETURN)
      /qtbase/src/sql/doc/snippets/code/doc_src_sql-driver.cpp: 99 in exProc()()
      93     
      94     void exProc()
      95     {
      96     //! [26]
      97     QSqlQuery q;
      98     q.exec("execute procedure my_procedure");
      >>>     CID 274217:  Error handling issues  (CHECKED_RETURN)
      >>>     Calling "next" without checking return value (as is done elsewhere 103 out of 114 times).
      99     q.next();
      100     qDebug() << q.value(0); // outputs the first RETURN/OUT value
      101     //! [26]
      102     
      103     qDebug( \
      104     //! [31]
      
      ** CID 274216:    (BAD_COMPARE)
      /qtbase/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp: 220 in QSqlQuery_snippets()()
      /qtbase/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp: 210 in QSqlQuery_snippets()()
      
      
      ________________________________________________________________________________________________________
      *** CID 274216:    (BAD_COMPARE)
      /qtbase/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp: 220 in QSqlQuery_snippets()()
      214     
      215         {
      216         // examine with positional binding
      217     //! [15]
      218         QList<QVariant> list = query.boundValues().values();
      219         for (int i = 0; i < list.size(); ++i)
      >>>     CID 274216:    (BAD_COMPARE)
      >>>     This implicit conversion to a function pointer is suspicious: "endl".
      220             cout << i << ": " << list.at(i).toString().toUtf8().data() << Qt::endl;
      221     //! [15]
      222         }
      223     }
      224     
      225     void QSqlQueryModel_snippets()
      /qtbase/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp: 210 in QSqlQuery_snippets()()
      204         {
      205         // examine with named binding
      206     //! [14]
      207         QMap<QString, QVariant> sqlIterator(query.boundValues());
      208         for (auto i = sqlIterator.begin(); i != sqlIterator.end(); ++i) {
      209             cout << i.key().toUtf8().data() << ": "
      >>>     CID 274216:    (BAD_COMPARE)
      >>>     This implicit conversion to a function pointer is suspicious: "endl".
      210                  << i.value().toString().toUtf8().data() << Qt::endl;
      211         }
      212     //! [14]
      213         }
      214     
      215         {
      
      ** CID 274215:  Error handling issues  (CHECKED_RETURN)
      /qtbase/src/sql/doc/snippets/code/doc_src_sql-driver.cpp: 90 in setHost()()
      
      
      ________________________________________________________________________________________________________
      *** CID 274215:  Error handling issues  (CHECKED_RETURN)
      /qtbase/src/sql/doc/snippets/code/doc_src_sql-driver.cpp: 90 in setHost()()
      84     //! [24]
      85     
      86     
      87     //! [25]
      88     // connect to database using the Latin-1 character set
      89     db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1");
      >>>     CID 274215:  Error handling issues  (CHECKED_RETURN)
      >>>     Calling "open" without checking return value (as is done elsewhere 19 out of 23 times).
      90     db.open();
      91     //! [25]
      92     }
      93     
      94     void exProc()
      95     {
      
      ** CID 274214:  Error handling issues  (CHECKED_RETURN)
      /qtbase/src/sql/doc/snippets/code/doc_src_sql-driver.cpp: 63 in testProc()()
      
      
      ________________________________________________________________________________________________________
      *** CID 274214:  Error handling issues  (CHECKED_RETURN)
      /qtbase/src/sql/doc/snippets/code/doc_src_sql-driver.cpp: 63 in testProc()()
      57     void testProc()
      58     {
      59     //! [2]
      60     QSqlQuery q;
      61     q.exec("call qtestproc (@outval1, @outval2)");
      62     q.exec("select @outval1, @outval2");
      >>>     CID 274214:  Error handling issues  (CHECKED_RETURN)
      >>>     Calling "next" without checking return value (as is done elsewhere 103 out of 114 times).
      63     q.next();
      64     qDebug() << q.value(0) << q.value(1); // outputs "42" and "43"
      65     //! [2]
      66     }
      67     
      68     void callStoredProc()
      

      https://u2389337.ct.sendgrid.net/ls/click?upn=nJaKvJSIH-2FPAfmty-2BK5tYpPklAc1eEA-2F1zfUjH6teEzy58ra-2BnR-2Bra60-2BXnvcB-2Bm34NmsSsgh1JyHF6wn05FAuqnx-2B8nJeoxrXR1sHSV4u8-3DN3E-_-2FskHVTjZSnku1-2F-2BqB3hC3KtRcRypT2Mncaz89kVmZd8Et4pRJk8w7p7zZ4PZe-2F281qmAZTxAnHYUkdw7MXSTP-2FGMONMxzG35AgO7ZU7EoaFdgu6xBoBkD0Fr7rsTmqgPNAATyD-2Bb-2BnUYhSXCrh2aN-2BUWVpS2-2BXW1Y3K-2F-2FnHXD9WRAiJI2ctbb3jLXbVgdBGHk4WoZSgkkoods5s6-2BbEbTmq4NlU15ZD4yTDuo-2FgWnHQ-3D

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              paulwicking Paul Wicking
              Reporter:
              kkohne Kai Köhne
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes