From 3f3e200aef80ac33e6bf116c656ebc28d5918836 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Mon, 23 Mar 2020 12:56:02 +0100 Subject: Doc: Fix coverity warnings in SQL snippets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-83008 Change-Id: I126bc04719cd221a3d80ae825fca44e63aeec934 Reviewed-by: Topi Reiniƶ --- src/sql/doc/snippets/code/doc_src_sql-driver.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/sql/doc/snippets/code') diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp index 076a3367dc..6b5a5e0335 100644 --- a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp +++ b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp @@ -60,8 +60,8 @@ void testProc() QSqlQuery q; q.exec("call qtestproc (@outval1, @outval2)"); q.exec("select @outval1, @outval2"); -q.next(); -qDebug() << q.value(0) << q.value(1); // outputs "42" and "43" +if (q.next()) + qDebug() << q.value(0) << q.value(1); // outputs "42" and "43" //! [2] } @@ -87,7 +87,8 @@ db.setDatabaseName("C:\\test.gdb"); //! [25] // connect to database using the Latin-1 character set db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1"); -db.open(); +if (db.open()) + qDebug("The database connection is open."); //! [25] } @@ -96,8 +97,8 @@ void exProc() //! [26] QSqlQuery q; q.exec("execute procedure my_procedure"); -q.next(); -qDebug() << q.value(0); // outputs the first RETURN/OUT value +if (q.next()) + qDebug() << q.value(0); // outputs the first RETURN/OUT value //! [26] qDebug( \ -- cgit v1.2.3