From 332e099b19bd04db46cfffdf7d06b8a888169d49 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 30 Mar 2019 11:43:22 +0000 Subject: Tidy fixes for latest clang --- libodbcpp/odbc-selectcommand.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libodbcpp/odbc-selectcommand.cpp') diff --git a/libodbcpp/odbc-selectcommand.cpp b/libodbcpp/odbc-selectcommand.cpp index ea94fce..82947a7 100644 --- a/libodbcpp/odbc-selectcommand.cpp +++ b/libodbcpp/odbc-selectcommand.cpp @@ -26,6 +26,7 @@ ODBC::SelectCommand::fetch() return fetch(SQL_FETCH_NEXT, 0); } +constexpr std::array truncated = { '0', '1', '0', '0', '4', '\0' }; bool ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset) { @@ -37,11 +38,10 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset) case SQL_SUCCESS_WITH_INFO: default: { - SQLCHAR sqlstatus[6]; - // NOLINTNEXTLINE(hicpp-no-array-decay) - RETCODE diagrc = SQLGetDiagRec(SQL_HANDLE_STMT, hStmt, 1, sqlstatus, nullptr, nullptr, 0, nullptr); + std::array sqlstatus {}; + RETCODE diagrc = SQLGetDiagRec(SQL_HANDLE_STMT, hStmt, 1, sqlstatus.data(), nullptr, nullptr, 0, nullptr); if (SQL_SUCCEEDED(diagrc)) { - if (!strncmp((const char*)sqlstatus, "01004", 5)) { + if (sqlstatus == truncated) { for (const auto & c : largeColumns) { c->resize(); } @@ -78,16 +78,16 @@ ODBC::SelectCommand::execute() throw Error(rc, SQL_HANDLE_STMT, hStmt); } for (int col = 0; col < colCount; col++) { - SQLCHAR _colName[300]; + std::array _colName {}; SQLSMALLINT nameLen, dp, nullable, bindType; SQLULEN bindSize; int sqlcol = col + 1; // NOLINTNEXTLINE(hicpp-no-array-decay) - if (!SQL_SUCCEEDED(rc = SQLDescribeCol(hStmt, sqlcol, _colName, sizeof(_colName), &nameLen, &bindType, + if (!SQL_SUCCEEDED(rc = SQLDescribeCol(hStmt, sqlcol, _colName.data(), _colName.size(), &nameLen, &bindType, &bindSize, &dp, &nullable))) { throw Error(rc, SQL_HANDLE_STMT, hStmt); } - Glib::ustring colName((const char *)_colName, nameLen); + Glib::ustring colName((const char *)_colName.data(), nameLen); DB::Column * ncol; switch (bindType) { case SQL_DECIMAL: -- cgit v1.2.3