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 some cppcheck reports: #11
Conversation
[ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used.
Hello Julien, Thank you for your contribution! Similar to other open source projects, the MariaDB Corporation needs to have shared ownership of all code that is included in the MariaDB C/ODBC distribution. The easiest way to achieve this is by submitting your code under the BSD-new license. The other alternative is to sign the code contribution agreement which can be found here: https://mariadb.com/kb/en/mariadb/mca/ Please indicate in a comment below that you are contributing your new code of the whole pull request, including one or several files that are either new files or modified ones, under the BSD-new license or that you have filled out the contribution agreement and sent it. Best regards, |
@@ -86,7 +86,7 @@ MADB_Desc *MADB_DescInit(MADB_Dbc *Dbc,enum enum_madb_desc_type DescType, my_boo | |||
MADB_FREE(Desc); | |||
Desc= NULL; | |||
} | |||
if (isExternal) | |||
if (Desc && isExternal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess would be cleaner to change both "Desc= NULL" to "return NULL", and remove Desc checks
@@ -1312,12 +1309,13 @@ SQLRETURN MADB_StmtExecute(MADB_Stmt *Stmt) | |||
SQLRETURN MADB_StmtBindCol(MADB_Stmt *Stmt, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, | |||
SQLPOINTER TargetValuePtr, SQLLEN BufferLength, SQLLEN *StrLen_or_Ind) | |||
{ | |||
MADB_Desc *Ard= Stmt->Ard; | |||
MADB_Desc *Ard; | |||
MADB_DescRecord *Record; | |||
|
|||
if (!Stmt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is redundant. I guess it is better to remove it, and leave initialization as is
SQLULEN ArraySize= Stmt->Ard->Header.ArraySize; | ||
MADB_Desc *ArdDesc= Stmt->Ard; | ||
SQLULEN ArraySize; | ||
MADB_Desc *ArdDesc; | ||
MYSQL_ROWS *SaveCursor= NULL; | ||
|
||
if (!Stmt || !Stmt->stmt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - !Stmt is safe to remove from here, and leave only !Stmt->stmt, and leave initialization as is
[ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. All of my past & future contributions to MariaDB may be licensed under the BSD-new license.
Thank you Lawrinn for your feedback. I tried to apply what you suggested:
|
[ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. All of my past & future contributions to MariaDB may be licensed under the BSD-new license.
[ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. All of my past & future contributions to MariaDB may be licensed under the BSD-new license.
[ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. All of my past & future contributions to MariaDB may be licensed under the BSD-new license.
* Fix some cppcheck reports: [ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. * Fix some cppcheck reports: [ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. All of my past & future contributions to MariaDB may be licensed under the BSD-new license. * Fix some cppcheck reports: [ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. All of my past & future contributions to MariaDB may be licensed under the BSD-new license. * Fix some cppcheck reports: [ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. All of my past & future contributions to MariaDB may be licensed under the BSD-new license. * Fix some cppcheck reports: [ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc. [ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used. [ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used. [ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used. [ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used. [ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt. [ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used. All of my past & future contributions to MariaDB may be licensed under the BSD-new license.
[ma_desc.c:107] -> [ma_desc.c:104]: (warning) Either the condition 'Desc' is redundant or there is possible null pointer dereference: Desc.
[ma_parse.c:45]: (style) Variable 'p' is assigned a value that is never used.
[ma_parse.c:46]: (style) Variable 'Tokens' is assigned a value that is never used.
[ma_statement.c:113]: (style) Variable 'NewStmt' is assigned a value that is never used.
[ma_statement.c:444]: (style) Variable 'Length' is assigned a value that is never used.
[ma_statement.c:1315] -> [ma_statement.c:1318]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt.
[ma_statement.c:1798] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt.
[ma_statement.c:1799] -> [ma_statement.c:1802]: (warning) Either the condition '!Stmt' is redundant or there is possible null pointer dereference: Stmt.
[ma_string.c:88]: (style) Variable 'Count' is assigned a value that is never used.