Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GCC 14 -Wimplicit-int warnings #60

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion driver/class/ClientSidePreparedStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ namespace mariadb
if (!metadata) {
loadParametersData();
}
return metadata.get();
return metadata.release();
}


Expand Down
4 changes: 0 additions & 4 deletions driver/class/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,6 @@ namespace mariadb
throw SQLException(mysql_error(connection.get()), mysql_sqlstate(connection.get()), mysql_errno(connection.get()));
}

static const my_bool updateMaxLength= 1;

mysql_stmt_attr_set(stmtId, STMT_ATTR_UPDATE_MAX_LENGTH, &updateMaxLength);

if (mysql_stmt_prepare(stmtId, sql.c_str(), static_cast<unsigned long>(sql.length())))
{
SQLString err(mysql_stmt_error(stmtId)), sqlState(mysql_stmt_sqlstate(stmtId));
Expand Down
6 changes: 3 additions & 3 deletions driver/ma_api_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ SQLRETURN MA_SQLGetData(SQLHSTMT StatementHandle,
SQLLEN* StrLen_or_IndPtr)
{
MADB_Stmt* Stmt= (MADB_Stmt*)StatementHandle;
unsigned int i;
unsigned int i, columnCount;
MADB_DescRecord* IrdRec;

/* In case we don't have DM(it check for that) */
Expand All @@ -1522,9 +1522,9 @@ SQLRETURN MA_SQLGetData(SQLHSTMT StatementHandle,
{
return MADB_SetError(&Stmt->Error, MADB_ERR_HY090, NULL, 0);
}

columnCount= Stmt->metadata->getColumnCount();
/* reset offsets for other columns. Doing that here since "internal" calls should not do that */
for (i= 0; i < Stmt->metadata->getColumnCount(); i++)
for (i= 0; i < columnCount; i++)
{
if (i != Col_or_Param_Num - 1)
{
Expand Down
2 changes: 1 addition & 1 deletion driver/ma_bulk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ SQLRETURN MADB_ExecuteBulk(MADB_Stmt *Stmt, unsigned int ParamOffset)

if (Stmt->stmt->isServerSide() && !MADB_ServerSupports(Stmt->Connection, MADB_CAPABLE_PARAM_ARRAYS))
{
Stmt->stmt.reset(new ClientSidePreparedStatement(Stmt->Connection->guard.get(), STMT_STRING(Stmt), Stmt->Options.CursorType
MADB_CXX_RESET(Stmt->stmt, new ClientSidePreparedStatement(Stmt->Connection->guard.get(), STMT_STRING(Stmt), Stmt->Options.CursorType
, Stmt->Query.NoBackslashEscape));
// So far
useCallbacks= false;
Expand Down
39 changes: 21 additions & 18 deletions driver/ma_desc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ MADB_Desc *MADB_DescInit(MADB_Dbc *Dbc,enum enum_madb_desc_type DescType, my_boo
/* }}} */

/* {{{ MADB_DescFree */
SQLRETURN MADB_DescFree(MADB_Desc *Desc, my_bool RecordsOnly)
SQLRETURN MADB_DescFree(MADB_Desc *Desc, bool RecordsOnly)
{
MADB_DescRecord *Record;
unsigned int i;
Expand Down Expand Up @@ -356,6 +356,7 @@ MADB_DescSetIrdMetadata(MADB_Stmt *Stmt, const MYSQL_FIELD *Fields, unsigned int
{
return 1;
}
Stmt->Ird->Header.Count= i + 1;
}
return 0;
}
Expand Down Expand Up @@ -638,32 +639,34 @@ void MADB_DescSetRecordDefaults(MADB_Desc *Desc, MADB_DescRecord *Record)
}
/* }}} */

/* {{{ MADB_DescGetInternalRecord */
MADB_DescRecord *MADB_DescGetInternalRecord(MADB_Desc *Desc, SQLSMALLINT RecordNumber, SQLSMALLINT Type)
/* {{{ MADB_DescGetInternalRecord
[in] ReorordNumber - 0 based record index */
MADB_DescRecord* MADB_DescGetInternalRecord(MADB_Desc *Desc, SQLSMALLINT RecordNumber, SQLSMALLINT Type)
{
MADB_DescRecord *DescRecord;

if (RecordNumber > (SQLINTEGER)Desc->Records.elements &&
Type == MADB_DESC_READ)
if (RecordNumber >= (SQLINTEGER)Desc->Records.elements)
{
MADB_SetError(&Desc->Error, MADB_ERR_07009, nullptr, 0);
return nullptr;
}

while (RecordNumber >= (SQLINTEGER)Desc->Records.elements)
{
if (!(DescRecord= (MADB_DescRecord *)MADB_AllocDynamic(&Desc->Records)))
if (Type == MADB_DESC_READ)
{
MADB_SetError(&Desc->Error, MADB_ERR_HY001, nullptr, 0);
MADB_SetError(&Desc->Error, MADB_ERR_07009, nullptr, 0);
return nullptr;
}

MADB_DescSetRecordDefaults(Desc, DescRecord);

do {
if (!(DescRecord= (MADB_DescRecord *)MADB_AllocDynamic(&Desc->Records)))
{
MADB_SetError(&Desc->Error, MADB_ERR_HY001, nullptr, 0);
return nullptr;
}

MADB_DescSetRecordDefaults(Desc, DescRecord);
} while (RecordNumber >= (SQLINTEGER)Desc->Records.elements);

if (RecordNumber + 1 > Desc->Header.Count)
Desc->Header.Count= (SQLSMALLINT)(RecordNumber + 1);
}

if (RecordNumber + 1 > Desc->Header.Count)
Desc->Header.Count= (SQLSMALLINT)(RecordNumber + 1);

DescRecord= ((MADB_DescRecord *)Desc->Records.buffer) + RecordNumber;

return DescRecord;
Expand Down
2 changes: 1 addition & 1 deletion driver/ma_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum enum_madb_desc_type {MADB_DESC_APD= 0, MADB_DESC_ARD, MADB_DESC_IPD, MADB_D
MADB_DescRecord *MADB_DescGetInternalRecord(MADB_Desc *Desc, SQLSMALLINT RecordNumber, SQLSMALLINT Type);

MADB_Desc *MADB_DescInit(MADB_Dbc *Dbc, enum enum_madb_desc_type DescType, my_bool isExternal);
SQLRETURN MADB_DescFree(MADB_Desc *Desc, my_bool RecordsOnly);
SQLRETURN MADB_DescFree(MADB_Desc *Desc, bool RecordsOnly);
SQLRETURN MADB_DescGetField(SQLHDESC DescriptorHandle,
SQLSMALLINT RecNumber,
SQLSMALLINT FieldIdentifier,
Expand Down
11 changes: 6 additions & 5 deletions driver/ma_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ MYSQL_RES *MADB_GetDefaultColumnValues(MADB_Stmt *Stmt, const MYSQL_FIELD *field

for (i= 0; i < Stmt->metadata->getColumnCount(); i++)
{
// TODO: Shouldn't it be really IRD here?
MADB_DescRecord* Rec= MADB_DescGetInternalRecord(Stmt->Ard, i, MADB_DESC_READ);

if (!Rec->inUse || MADB_ColumnIgnoredInAllRows(Stmt->Ard, Rec) == TRUE)
if (!Rec || !Rec->inUse || MADB_ColumnIgnoredInAllRows(Stmt->Ard, Rec) == TRUE)
{
continue;
}
Expand Down Expand Up @@ -864,7 +865,7 @@ void* GetBindOffset(MADB_Header& Header, void* Ptr, SQLULEN RowNumber, std::size
}

/* Checking if column ignored in all bound rows. Should hel*/
BOOL MADB_ColumnIgnoredInAllRows(MADB_Desc *Desc, MADB_DescRecord *Rec)
bool MADB_ColumnIgnoredInAllRows(MADB_Desc *Desc, MADB_DescRecord *Rec)
{
SQLULEN row;
SQLLEN *IndicatorPtr;
Expand All @@ -873,13 +874,13 @@ BOOL MADB_ColumnIgnoredInAllRows(MADB_Desc *Desc, MADB_DescRecord *Rec)
{
IndicatorPtr= (SQLLEN *)GetBindOffset(Desc->Header, Rec->IndicatorPtr, row, sizeof(SQLLEN));

if (IndicatorPtr == NULL || *IndicatorPtr != SQL_COLUMN_IGNORE)
if (IndicatorPtr == nullptr || *IndicatorPtr != SQL_COLUMN_IGNORE)
{
return FALSE;
return false;
}
}

return TRUE;
return true;
}


Expand Down
5 changes: 4 additions & 1 deletion driver/ma_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const char * MADB_GetTypeName(const MYSQL_FIELD *Field);
my_bool MADB_CheckPtrLength(SQLINTEGER MaxLength, char *Ptr, SQLINTEGER NameLen);
std::size_t getArrayStep(MADB_Header& header, std::size_t pointedSize);
void * GetBindOffset(MADB_Header& DescHeader, void *Ptr, SQLULEN RowNumber, size_t PtrSize);
BOOL MADB_ColumnIgnoredInAllRows(MADB_Desc *Desc, MADB_DescRecord *Rec);
bool MADB_ColumnIgnoredInAllRows(MADB_Desc *Desc, MADB_DescRecord *Rec);

SQLRETURN MADB_DaeStmt(MADB_Stmt *Stmt, SQLUSMALLINT Operation);
MYSQL_RES * MADB_GetDefaultColumnValues(MADB_Stmt *Stmt, const MYSQL_FIELD *fields);
Expand Down Expand Up @@ -109,4 +109,7 @@ extern my_bool DummyError;

#define MADB_FRACTIONAL_PART(_decimals) ((_decimals) > 0 ? (_decimals) + 1/*Decimal point*/ : 0)

#define MADB_DELETE(PTR) do {delete (PTR); (PTR)= nullptr;} while(false)
#define MADB_CXX_RESET(PTR,NEWPTR) do {delete (PTR); (PTR)= (NEWPTR);} while(false)

#endif
6 changes: 3 additions & 3 deletions driver/ma_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ SQLRETURN MADB_GetTypeInfo(SQLHSTMT StatementHandle,

std::vector<std::vector<mariadb::bytes_view>> row;

Stmt->stmt.reset();
MADB_DELETE(Stmt->stmt);
if (DataType == SQL_ALL_TYPES)
{
Stmt->rs.reset(ResultSet::createResultSet(TypeInfoColumnName, TypeInfoColumnType, *TypeInfo));
MADB_CXX_RESET(Stmt->rs, ResultSet::createResultSet(TypeInfoColumnName, TypeInfoColumnType, *TypeInfo));
}
else
{
Expand All @@ -262,7 +262,7 @@ SQLRETURN MADB_GetTypeInfo(SQLHSTMT StatementHandle,
row.push_back(cit);
}
}
Stmt->rs.reset(ResultSet::createResultSet(TypeInfoColumnName, TypeInfoColumnType, row));
MADB_CXX_RESET(Stmt->rs, ResultSet::createResultSet(TypeInfoColumnName, TypeInfoColumnType, row));
}

Stmt->State= MADB_SS_EXECUTED;
Expand Down
6 changes: 3 additions & 3 deletions driver/ma_odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ struct MADB_Stmt
long long AffectedRows= 0;
MADB_Dbc *Connection;
struct st_ma_stmt_methods *Methods;
Unique::ResultSet rs;
Unique::PreparedStatement stmt;
Unique::ResultSetMetaData metadata;
ResultSet* rs= nullptr;
PreparedStatement* stmt= nullptr;
mariadb::ResultSetMetaData* metadata= nullptr;
Unique::MYSQL_RES DefaultsResult;
MADB_DescRecord *PutDataRec= nullptr;
MADB_Stmt *DaeStmt= nullptr;
Expand Down
4 changes: 1 addition & 3 deletions driver/ma_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void MADB_QUERY::reset()
Original.assign("");
RefinedText.assign("");
Tokens.clear();
PoorManParsing= ReturnsResult= false;
PoorManParsing= false;
}

int MADB_ParseQuery(MADB_QUERY * Query)
Expand Down Expand Up @@ -397,8 +397,6 @@ int ParseQuery(MADB_QUERY *Query)
/* We are currently at 2nd token of statement, and getting previous token position from Tokens array*/
StmtType= MADB_GetQueryType(MADB_Token(Query, Query->Tokens.size() - 2), p);

Query->ReturnsResult= Query->ReturnsResult || !QUERY_DOESNT_RETURN_RESULT(StmtType);

/* If we on first statement, setting QueryType*/
if (Query->Tokens.size() == 2)
{
Expand Down
2 changes: 0 additions & 2 deletions driver/ma_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ typedef struct {
SQLString RefinedText;
enum enum_madb_query_type QueryType= MADB_QUERY_NO_RESULT;
bool MultiStatement= false;
/* Keeping it so far */
bool ReturnsResult= false;
bool PoorManParsing= false;

bool BatchAllowed= false;
Expand Down
8 changes: 4 additions & 4 deletions driver/ma_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ SQLRETURN MADB_StmtMoreResults(SQLHSTMT StatementHandle)
/* We can't have it in MADB_StmtResetResultStructures, as it breaks dyn_cursor functionality.
Thus we free-ing bind structs on move to new result only */
MADB_FREE(Stmt->result);
Stmt->metadata.reset();
Stmt->rs.reset();
MADB_DELETE(Stmt->metadata);
MADB_DELETE(Stmt->rs);

try {
// TODO: that's not right to mess here with Protocol's lock. Protocol should take care of that
Expand All @@ -163,7 +163,7 @@ SQLRETURN MADB_StmtMoreResults(SQLHSTMT StatementHandle)
{
unsigned int ServerStatus;
mariadb_get_infov(Stmt->Connection->mariadb, MARIADB_CONNECTION_SERVER_STATUS, (void*)&ServerStatus);
Stmt->rs.reset(Stmt->stmt->getResultSet());
MADB_CXX_RESET(Stmt->rs, Stmt->stmt->getResultSet());
bool itsOutParams= ServerStatus & SERVER_PS_OUT_PARAMS;
bool haveOutParams= HasOutParams(Stmt);

Expand Down Expand Up @@ -198,7 +198,7 @@ SQLRETURN MADB_StmtMoreResults(SQLHSTMT StatementHandle)
ret= MADB_FromException(Stmt->Error, e);
}
catch (int32_t /*rc*/) {
ret= MADB_SetNativeError(&Stmt->Error, SQL_HANDLE_STMT, Stmt->stmt.get());
ret= MADB_SetNativeError(&Stmt->Error, SQL_HANDLE_STMT, Stmt->stmt);
}

MADB_StmtResetResultStructures(Stmt);
Expand Down
Loading