Skip to content

Commit a902e29

Browse files
committed
fix formatting and indentation issues
1 parent 454374e commit a902e29

1 file changed

Lines changed: 92 additions & 38 deletions

File tree

ibm_db.c

Lines changed: 92 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,8 @@ static void _python_ibm_db_free_stmt_struct(stmt_handle *handle)
653653
}
654654
snprintf(messageStr, sizeof(messageStr), "Py_TYPE(handle)->tp_free called for handle=%p", (void *)handle);
655655
LogMsg(DEBUG, messageStr, fileName);
656-
if (handle != NULL) {
656+
if (handle != NULL)
657+
{
657658
Py_TYPE(handle)->tp_free((PyObject *)handle);
658659
}
659660
LogMsg(INFO, "exit _python_ibm_db_free_stmt_struct()", fileName);
@@ -1936,11 +1937,14 @@ static PyObject *_python_ibm_db_connect_helper(PyObject *self, PyObject *args, i
19361937
if (conn_res == NULL)
19371938
{
19381939
conn_res = PyObject_NEW(conn_handle, &conn_handleType);
1939-
if (conn_res != NULL) {
1940+
if (conn_res != NULL)
1941+
{
19401942
conn_res->henv = 0;
19411943
conn_res->hdbc = 0;
19421944
LogMsg(DEBUG, "Created a new connection handle", fileName);
1943-
} else {
1945+
}
1946+
else
1947+
{
19441948
LogMsg(ERROR, "Failed to allocate memory for connection handle", fileName);
19451949
return NULL;
19461950
}
@@ -3264,7 +3268,8 @@ static void _python_ibm_db_debug(PyObject *self, PyObject *args)
32643268
{
32653269
PyErr_SetString(PyExc_IOError, "Failed to open the log file");
32663270
}
3267-
else {
3271+
else
3272+
{
32683273
fclose(log_file);
32693274
}
32703275
}
@@ -9930,12 +9935,15 @@ static PyObject *ibm_db_conn_errormsg(PyObject *self, PyObject *args)
99309935
PyErr_SetString(PyExc_Exception, "Connection is not active");
99319936
}
99329937
return_str = ALLOC_N(char, DB2_MAX_ERR_MSG_LEN);
9933-
if (return_str != NULL) {
9938+
if (return_str != NULL)
9939+
{
99349940
snprintf(messageStr, sizeof(messageStr), "Allocated return_str: %p, size: %d", return_str, DB2_MAX_ERR_MSG_LEN);
99359941
LogMsg(DEBUG, messageStr, fileName);
99369942
memset(return_str, 0, DB2_MAX_ERR_MSG_LEN);
99379943
LogMsg(DEBUG, "Initialized return_str with zeros", fileName);
9938-
} else {
9944+
}
9945+
else
9946+
{
99399947
LogMsg(ERROR, "Memory allocation for return_str failed", fileName);
99409948
return NULL;
99419949
}
@@ -10033,7 +10041,8 @@ static PyObject *ibm_db_conn_warn(PyObject *self, PyObject *args)
1003310041
LogMsg(DEBUG, messageStr, fileName);
1003410042
}
1003510043
return_str = ALLOC_N(char, DB2_MAX_ERR_MSG_LEN);
10036-
if (return_str != NULL) {
10044+
if (return_str != NULL)
10045+
{
1003710046
PyErr_Clear();
1003810047
memset(return_str, 0, SQL_SQLSTATE_SIZE + 1);
1003910048
}
@@ -10047,7 +10056,8 @@ static PyObject *ibm_db_conn_warn(PyObject *self, PyObject *args)
1004710056
LogMsg(DEBUG, messageStr, fileName);
1004810057
}
1004910058
conn_res->error_recno_tracker++;
10050-
if (return_str != NULL) {
10059+
if (return_str != NULL)
10060+
{
1005110061
retVal = StringOBJ_FromASCII(return_str);
1005210062
snprintf(messageStr, sizeof(messageStr), "Returning warning message: %s", return_str);
1005310063
LogMsg(INFO, messageStr, fileName);
@@ -10125,9 +10135,12 @@ static PyObject *ibm_db_stmt_warn(PyObject *self, PyObject *args)
1012510135
LogMsg(DEBUG, messageStr, fileName);
1012610136
}
1012710137
return_str = ALLOC_N(char, DB2_MAX_ERR_MSG_LEN);
10128-
if (return_str != NULL) {
10138+
if (return_str != NULL)
10139+
{
1012910140
memset(return_str, 0, DB2_MAX_ERR_MSG_LEN);
10130-
} else {
10141+
}
10142+
else
10143+
{
1013110144
LogMsg(ERROR, "Memory allocation for return_str failed", fileName);
1013210145
return NULL;
1013310146
}
@@ -10225,12 +10238,15 @@ static PyObject *ibm_db_stmt_errormsg(PyObject *self, PyObject *args)
1022510238
LogMsg(DEBUG, messageStr, fileName);
1022610239
}
1022710240
return_str = ALLOC_N(char, DB2_MAX_ERR_MSG_LEN);
10228-
if (return_str != NULL) {
10241+
if (return_str != NULL)
10242+
{
1022910243
snprintf(messageStr, sizeof(messageStr), "Allocated return_str: %p, size: %d", return_str, DB2_MAX_ERR_MSG_LEN);
1023010244
LogMsg(DEBUG, messageStr, fileName);
1023110245
memset(return_str, 0, DB2_MAX_ERR_MSG_LEN);
1023210246
LogMsg(DEBUG, "Initialized return_str with zeros", fileName);
10233-
} else {
10247+
}
10248+
else
10249+
{
1023410250
LogMsg(ERROR, "Memory allocation for return_str failed", fileName);
1023510251
return NULL;
1023610252
}
@@ -10336,12 +10352,15 @@ static PyObject *ibm_db_conn_error(PyObject *self, PyObject *args)
1033610352
LogMsg(DEBUG, messageStr, fileName);
1033710353
}
1033810354
return_str = ALLOC_N(char, SQL_SQLSTATE_SIZE + 1);
10339-
if (return_str != NULL) {
10355+
if (return_str != NULL)
10356+
{
1034010357
snprintf(messageStr, sizeof(messageStr), "Allocated return_str: %p, size: %d", return_str, SQL_SQLSTATE_SIZE + 1);
1034110358
LogMsg(DEBUG, messageStr, fileName);
1034210359
memset(return_str, 0, SQL_SQLSTATE_SIZE + 1);
1034310360
LogMsg(DEBUG, "Initialized return_str with zeros", fileName);
10344-
} else {
10361+
}
10362+
else
10363+
{
1034510364
LogMsg(ERROR, "Memory allocation for return_str failed", fileName);
1034610365
return NULL;
1034710366
}
@@ -10443,10 +10462,13 @@ static PyObject *ibm_db_stmt_error(PyObject *self, PyObject *args)
1044310462
return_str = ALLOC_N(char, DB2_MAX_ERR_MSG_LEN);
1044410463
snprintf(messageStr, sizeof(messageStr), "Allocated return_str: %p, size: %d", return_str, DB2_MAX_ERR_MSG_LEN);
1044510464
LogMsg(DEBUG, messageStr, fileName);
10446-
if (return_str != NULL) {
10465+
if (return_str != NULL)
10466+
{
1044710467
memset(return_str, 0, DB2_MAX_ERR_MSG_LEN);
1044810468
LogMsg(DEBUG, "Initialized return_str with zeros", fileName);
10449-
} else {
10469+
}
10470+
else
10471+
{
1045010472
LogMsg(ERROR, "Failed to allocate memory for return_str", fileName);
1045110473
PyErr_SetString(PyExc_MemoryError, "Failed to allocate memory for error message string.");
1045210474
return NULL;
@@ -15799,7 +15821,8 @@ static int _ibm_db_chaining_flag(stmt_handle *stmt_res, SQLINTEGER flag, error_m
1579915821
errTuple = PyTuple_New(err_cnt + client_err_cnt);
1580015822
/* Allocate enough space for largest possible int value. */
1580115823
err_fmt = (char *)PyMem_Malloc(strlen("Error 2147483647: %s\n") * (err_cnt + client_err_cnt) + 1);
15802-
if (err_fmt != NULL) {
15824+
if (err_fmt != NULL)
15825+
{
1580315826
err_fmt[0] = '\0';
1580415827
errNo = 1;
1580515828
while (error_list != NULL)
@@ -15830,7 +15853,9 @@ static int _ibm_db_chaining_flag(stmt_handle *stmt_res, SQLINTEGER flag, error_m
1583015853
PyMem_Free(err_fmt);
1583115854
}
1583215855
PyErr_SetObject(PyExc_Exception, err_msg);
15833-
} else {
15856+
}
15857+
else
15858+
{
1583415859
LogMsg(EXCEPTION, "Failed to allocate memory for error message format.", fileName);
1583515860
PyErr_SetString(PyExc_MemoryError, "Failed to allocate memory for error message format.");
1583615861
return -1;
@@ -15989,11 +16014,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1598916014
/* Execute SQL for all set of parameters */
1599016015
numOfRows = PyTuple_Size(params);
1599116016
head_error_list = ALLOC(error_msg_node);
15992-
if (head_error_list != NULL) {
16017+
if (head_error_list != NULL)
16018+
{
1599316019
memset(head_error_list, 0, sizeof(error_msg_node));
1599416020
head_error_list->next = NULL;
1599516021
}
15996-
else {
16022+
else
16023+
{
1599716024
LogMsg(ERROR, "Memory allocation for head_error_list failed", fileName);
1599816025
}
1599916026
if (numOfRows > 0)
@@ -16007,10 +16034,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1600716034
if (!PyTuple_Check(param))
1600816035
{
1600916036
sprintf(error, "Value parameter %d is not a tuple", i + 1);
16010-
if (head_error_list != NULL) {
16037+
if (head_error_list != NULL)
16038+
{
1601116039
_build_client_err_list(head_error_list, error);
1601216040
err_count++;
16013-
} else {
16041+
}
16042+
else
16043+
{
1601416044
LogMsg(ERROR, "head_error_list is NULL, cannot build client error list", fileName);
1601516045
}
1601616046
continue;
@@ -16021,10 +16051,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1602116051
{
1602216052
/* More are passed in -- Warning - Use the max number present */
1602316053
sprintf(error, "Value parameter tuple %d has more parameters than previous tuple", i + 1);
16024-
if (head_error_list != NULL) {
16054+
if (head_error_list != NULL)
16055+
{
1602516056
_build_client_err_list(head_error_list, error);
1602616057
err_count++;
16027-
} else {
16058+
}
16059+
else
16060+
{
1602816061
LogMsg(ERROR, "head_error_list is NULL, cannot build client error list", fileName);
1602916062
}
1603016063
continue;
@@ -16035,10 +16068,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1603516068
* -- Error
1603616069
*/
1603716070
sprintf(error, "Value parameter tuple %d has fewer parameters than previous tuple", i + 1);
16038-
if (head_error_list != NULL) {
16071+
if (head_error_list != NULL)
16072+
{
1603916073
_build_client_err_list(head_error_list, error);
1604016074
err_count++;
16041-
} else {
16075+
}
16076+
else
16077+
{
1604216078
LogMsg(ERROR, "head_error_list is NULL, cannot build client error list", fileName);
1604316079
}
1604416080
continue;
@@ -16053,10 +16089,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1605316089
if (data == NULL)
1605416090
{
1605516091
sprintf(error, "NULL value passed for value parameter: %d", i + 1);
16056-
if (head_error_list != NULL) {
16092+
if (head_error_list != NULL)
16093+
{
1605716094
_build_client_err_list(head_error_list, error);
1605816095
err_count++;
16059-
} else {
16096+
}
16097+
else
16098+
{
1606016099
LogMsg(ERROR, "head_error_list is NULL, cannot build client error list", fileName);
1606116100
}
1606216101
break;
@@ -16068,10 +16107,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1606816107
if ((TYPE(data) != PYTHON_NIL) && (TYPE(data) != PYTHON_TRUE) && (TYPE(data) != PYTHON_FALSE) && (ref_data_type[curr->param_num - 1] != TYPE(data)) && (ref_data_type[curr->param_num - 1] != PYTHON_NIL))
1606916108
{
1607016109
sprintf(error, "Value parameter tuple %d has types that are not homogeneous with previous tuple", i + 1);
16071-
if (head_error_list != NULL) {
16110+
if (head_error_list != NULL)
16111+
{
1607216112
_build_client_err_list(head_error_list, error);
1607316113
err_count++;
16074-
} else {
16114+
}
16115+
else
16116+
{
1607516117
LogMsg(ERROR, "head_error_list is NULL, cannot build client error list", fileName);
1607616118
}
1607716119
break;
@@ -16204,10 +16246,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1620416246
sprintf(error, "Binding Error 1: %s",
1620516247
IBM_DB_G(__python_stmt_err_msg));
1620616248
LogMsg(ERROR, error, fileName);
16207-
if (head_error_list != NULL) {
16249+
if (head_error_list != NULL)
16250+
{
1620816251
_build_client_err_list(head_error_list, error);
1620916252
err_count++;
16210-
} else {
16253+
}
16254+
else
16255+
{
1621116256
LogMsg(ERROR, "head_error_list is NULL, cannot build client error list", fileName);
1621216257
}
1621316258
break;
@@ -16266,10 +16311,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1626616311
_python_ibm_db_check_sql_errors(stmt_res->hstmt, SQL_HANDLE_STMT, rc, 1, NULL, -1, 1);
1626716312
sprintf(error, "Sending data failed: %s", IBM_DB_G(__python_stmt_err_msg));
1626816313
LogMsg(ERROR, error, fileName);
16269-
if (head_error_list != NULL) {
16314+
if (head_error_list != NULL)
16315+
{
1627016316
_build_client_err_list(head_error_list, error);
1627116317
err_count++;
16272-
} else {
16318+
}
16319+
else
16320+
{
1627316321
LogMsg(ERROR, "head_error_list is NULL, cannot build client error list", fileName);
1627416322
}
1627516323
break;
@@ -16287,10 +16335,13 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1628716335
sprintf(error, "SQLExecute failed: %s", IBM_DB_G(__python_stmt_err_msg));
1628816336
LogMsg(ERROR, error, fileName);
1628916337
PyErr_SetString(PyExc_Exception, error);
16290-
if (head_error_list != NULL) {
16338+
if (head_error_list != NULL)
16339+
{
1629116340
_build_client_err_list(head_error_list, error);
1629216341
err_count++;
16293-
} else {
16342+
}
16343+
else
16344+
{
1629416345
LogMsg(ERROR, "head_error_list is NULL, cannot build client error list", fileName);
1629516346
}
1629616347
break;
@@ -16306,11 +16357,14 @@ static PyObject *ibm_db_execute_many(PyObject *self, PyObject *args)
1630616357
}
1630716358

1630816359
/* Set statement attribute SQL_ATTR_CHAINING_END */
16309-
if (head_error_list != NULL) {
16360+
if (head_error_list != NULL)
16361+
{
1631016362
rc = _ibm_db_chaining_flag(stmt_res, SQL_ATTR_CHAINING_END, head_error_list->next, err_count);
1631116363
snprintf(messageStr, sizeof(messageStr), "SQL_ATTR_CHAINING_END flag set. rc: %d", rc);
1631216364
LogMsg(DEBUG, messageStr, fileName);
16313-
} else {
16365+
}
16366+
else
16367+
{
1631416368
LogMsg(ERROR, "head_error_list is NULL, cannot process the error list", fileName);
1631516369
}
1631616370
if (head_error_list != NULL)

0 commit comments

Comments
 (0)