From: Aki Tuomi Date: Tue, 24 Nov 2015 13:50:32 +0000 (+0200) Subject: Use sizeof instead of magic number X-Git-Tag: dnsdist-1.0.0-alpha1~203^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12ff58be34eec08ead23893610ca0b6cb9a15f45;p=pdns Use sizeof instead of magic number --- diff --git a/modules/godbcbackend/sodbc.cc b/modules/godbcbackend/sodbc.cc index 10c1b274d..6b03c5f09 100644 --- a/modules/godbcbackend/sodbc.cc +++ b/modules/godbcbackend/sodbc.cc @@ -276,11 +276,11 @@ SSqlStatement* SODBCStatement::nextRow(row_t& row) row.push_back( "" ); } else { SQLCHAR coldata[128*1024]; - result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, 131702, &len ); - std::string strres = std::string(reinterpret_cast(coldata), std::min(131701,len)); // do not use nil byte + result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, sizeof(coldata), &len); + std::string strres = std::string(reinterpret_cast(coldata), std::min(sizeof(coldata)-1,len)); // do not use nil byte while(result == SQL_SUCCESS_WITH_INFO && len > 0) { // all data is consumed if len < 1 - result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, 131702, &len ); - strres = strres + std::string(reinterpret_cast(coldata), std::min(131701,len)); + result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, sizeof(coldata), &len ); + strres = strres + std::string(reinterpret_cast(coldata), std::min(sizeof(coldata)-1,len)); cerr<<"len="<