diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2016-03-29 10:25:17 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-03-31 11:30:36 +0200 |
commit | 6439005484bdf6754b910b1ce025b3fb33b6623f (patch) | |
tree | 1a00f48ae11d3da3d928f2d3d68b3e299216328c /connectivity | |
parent | 1aa4df615fa5599d05e9dd5e925b5852676185fa (diff) |
use SAL_N_ELEMENTS more widely
found using
git grep -n 'sizeof.*/.*sizeof.*[0]'
Change-Id: Icd4a6cc1ca8ec8ebd68e1701a02789c74cf0eb2a
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/commontools/dbmetadata.cxx | 3 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/Awrapado.cxx | 24 | ||||
-rw-r--r-- | connectivity/source/drivers/postgresql/pq_statics.cxx | 20 | ||||
-rw-r--r-- | connectivity/source/parse/sqlnode.cxx | 4 |
4 files changed, 25 insertions, 26 deletions
diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index 26f857fe8948..f1a66cf791d1 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -336,8 +336,7 @@ namespace dbtools if ( !bSupport ) { const OUString url = m_pImpl->xConnectionMetaData->getURL(); - char pMySQL[] = "sdbc:mysql"; - bSupport = url.matchAsciiL(pMySQL,(sizeof(pMySQL)/sizeof(pMySQL[0]))-1); + bSupport = url.startsWith("sdbc:mysql"); } } catch( const Exception& ) diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx index bed72dd5831e..bde92c9b67f4 100644 --- a/connectivity/source/drivers/ado/Awrapado.cxx +++ b/connectivity/source/drivers/ado/Awrapado.cxx @@ -1628,7 +1628,7 @@ ADORecordset* WpADOConnection::getExportedKeys( const ::com::sun::star::uno::Any // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1668,7 +1668,7 @@ ADORecordset* WpADOConnection::getImportedKeys( const ::com::sun::star::uno::Any // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1710,7 +1710,7 @@ ADORecordset* WpADOConnection::getPrimaryKeys( const ::com::sun::star::uno::Any& // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1750,7 +1750,7 @@ ADORecordset* WpADOConnection::getIndexInfo( // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1792,7 +1792,7 @@ ADORecordset* WpADOConnection::getTablePrivileges( const ::com::sun::star::uno:: // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1838,7 +1838,7 @@ ADORecordset* WpADOConnection::getCrossReference( const ::com::sun::star::uno::A // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1887,7 +1887,7 @@ ADORecordset* WpADOConnection::getProcedures( const ::com::sun::star::uno::Any& // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -1928,7 +1928,7 @@ ADORecordset* WpADOConnection::getProcedureColumns( const ::com::sun::star::uno: // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -2000,7 +2000,7 @@ ADORecordset* WpADOConnection::getTables( const ::com::sun::star::uno::Any& cata varCriteria[nPos].setString(sTypeNames); // Create SafeArray Bounds and initialize the array - const sal_Int32 nCrit = sizeof varCriteria / sizeof varCriteria[0]; + const sal_Int32 nCrit = SAL_N_ELEMENTS(varCriteria); SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = nCrit; @@ -2037,7 +2037,7 @@ ADORecordset* WpADOConnection::getColumns( const ::com::sun::star::uno::Any& cat // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -2081,7 +2081,7 @@ ADORecordset* WpADOConnection::getColumnPrivileges( const ::com::sun::star::uno: // Create SafeArray Bounds and initialize the array rgsabound[0].lLbound = 0; - rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + rgsabound[0].cElements = SAL_N_ELEMENTS(varCriteria); psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); sal_Int32 nPos=0; @@ -2116,7 +2116,7 @@ ADORecordset* WpADOConnection::getTypeInfo(DataTypeEnum /*_eType*/) { // Create elements used in the array OLEVariant varCriteria[2]; - const int nCrit = sizeof varCriteria / sizeof varCriteria[0]; + const int nCrit = SAL_N_ELEMENTS(varCriteria); // Create SafeArray Bounds and initialize the array SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; diff --git a/connectivity/source/drivers/postgresql/pq_statics.cxx b/connectivity/source/drivers/postgresql/pq_statics.cxx index ffc95798a3cf..66a399bdedcd 100644 --- a/connectivity/source/drivers/postgresql/pq_statics.cxx +++ b/connectivity/source/drivers/postgresql/pq_statics.cxx @@ -217,7 +217,7 @@ Statics & getStatics() PropertyDef( statics.SCHEMA_NAME , tString ) }; statics.refl.tableDescriptor.pProps = createPropertyArrayHelper( - tableDescDef, sizeof(tableDescDef)/sizeof(PropertyDef), 0 ); + tableDescDef, SAL_N_ELEMENTS(tableDescDef), 0 ); // Column props set statics.refl.column.implName = "org.openoffice.comp.pq.sdbcx.Column"; @@ -265,7 +265,7 @@ Statics & getStatics() }; statics.refl.columnDescriptor.pProps = createPropertyArrayHelper( - columnDescDef, sizeof(columnDescDef)/sizeof(PropertyDef), 0 ); + columnDescDef, SAL_N_ELEMENTS(columnDescDef), 0 ); // Key properties statics.refl.key.implName = "org.openoffice.comp.pq.sdbcx.Key"; @@ -300,7 +300,7 @@ Statics & getStatics() PropertyDef( statics.UPDATE_RULE, tInt ) }; statics.refl.keyDescriptor.pProps = createPropertyArrayHelper( - keyDescDef, sizeof(keyDescDef)/sizeof(PropertyDef), 0 ); + keyDescDef, SAL_N_ELEMENTS(keyDescDef), 0 ); // KeyColumn props set @@ -338,7 +338,7 @@ Statics & getStatics() PropertyDef( statics.RELATED_COLUMN, tString ) }; statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper( - keycolumnDescDef, sizeof(keycolumnDescDef)/sizeof(PropertyDef), 0 ); + keycolumnDescDef, SAL_N_ELEMENTS(keycolumnDescDef), 0 ); // view props set statics.refl.view.implName = "org.openoffice.comp.pq.sdbcx.View"; @@ -360,7 +360,7 @@ Statics & getStatics() statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 ); statics.refl.viewDescriptor.serviceNames[0] = "com.sun.star.sdbcx.ViewDescriptor"; statics.refl.viewDescriptor.pProps = createPropertyArrayHelper( - viewDef, sizeof(viewDef)/sizeof(PropertyDef), 0 ); // reuse view, as it is identical + viewDef, SAL_N_ELEMENTS(viewDef), 0 ); // reuse view, as it is identical // user props set statics.refl.user.implName = "org.openoffice.comp.pq.sdbcx.User"; statics.refl.user.serviceNames = Sequence< OUString > ( 1 ); @@ -384,7 +384,7 @@ Statics & getStatics() PropertyDef( statics.PASSWORD , tString ) }; statics.refl.userDescriptor.pProps = createPropertyArrayHelper( - userDefWR, sizeof(userDefWR)/sizeof(PropertyDef), 0 ); + userDefWR, SAL_N_ELEMENTS(userDefWR), 0 ); // index props set statics.refl.index.implName = "org.openoffice.comp.pq.sdbcx.Index"; @@ -409,7 +409,7 @@ Statics & getStatics() statics.refl.indexDescriptor.serviceNames[0] = "com.sun.star.sdbcx.IndexDescriptor"; statics.refl.indexDescriptor.pProps = createPropertyArrayHelper( - indexDef, sizeof(indexDef)/sizeof(PropertyDef), 0 ); + indexDef, SAL_N_ELEMENTS(indexDef), 0 ); // indexColumn props set statics.refl.indexColumn.implName = "org.openoffice.comp.pq.sdbcx.IndexColumn"; @@ -446,7 +446,7 @@ Statics & getStatics() PropertyDef( statics.NAME , tString ) }; statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper( - indexColumnDescDef, sizeof(indexColumnDescDef)/sizeof(PropertyDef), 0 ); + indexColumnDescDef, SAL_N_ELEMENTS(indexColumnDescDef), 0 ); // resultset statics.refl.resultSet.implName = "org.openoffice.comp.pq.ResultSet"; @@ -464,7 +464,7 @@ Statics & getStatics() PropertyDef( statics.RESULT_SET_TYPE , tInt ) }; statics.refl.resultSet.pProps = createPropertyArrayHelper( - resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 ); + resultSet, SAL_N_ELEMENTS(resultSet), 0 ); // updateableResultset statics.refl.updateableResultSet.implName = "org.openoffice.comp.pq.UpdateableResultSet"; @@ -472,7 +472,7 @@ Statics & getStatics() statics.refl.updateableResultSet.serviceNames[0] = "com.sun.star.sdbc.ResultSet"; statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ ); statics.refl.updateableResultSet.pProps = createPropertyArrayHelper( - resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 ); + resultSet, SAL_N_ELEMENTS(resultSet), 0 ); // databasemetadata statics.tablesRowNames = std::vector< OUString > ( 5 ); diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 57db13ec1158..e203e644758f 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1331,7 +1331,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: static_assert(OSQLParseNode::UNKNOWN_RULE==0, "UNKNOWN_RULE must be 0 for memset to 0 to work"); memset(OSQLParser::s_nRuleIDs,0,sizeof(OSQLParser::s_nRuleIDs)); - struct + const struct { OSQLParseNode::Rule eRule; // the parse node's ID for the rule OString sRuleName; // the name of the rule ("select_statement") @@ -1439,7 +1439,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::cast_spec, "cast_spec" }, { OSQLParseNode::window_function, "window_function" } }; - const size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] ); + const size_t nRuleMapCount = SAL_N_ELEMENTS( aRuleDescriptions ); // added a new rule? Adjust this map! // +1 for UNKNOWN_RULE static_assert(nRuleMapCount + 1 == static_cast<size_t>(OSQLParseNode::rule_count), "must be equal"); |