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 some cppcheck reports: #11

Merged
merged 5 commits into from Oct 15, 2016
Merged

Fix some cppcheck reports: #11

merged 5 commits into from Oct 15, 2016

Conversation

serval2412
Copy link
Contributor

[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.

[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.
@lawrinn
Copy link
Collaborator

lawrinn commented Oct 15, 2016

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,
Lawrin

@@ -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)
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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.
@serval2412
Copy link
Contributor Author

Thank you Lawrinn for your feedback. I tried to apply what you suggested:

  • license in the comment of the patch
  • changes in code
    hope it's more suitable now

[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.
@lawrinn lawrinn merged commit 4705b82 into mariadb-corporation:master Oct 15, 2016
lawrinn pushed a commit that referenced this pull request Oct 17, 2016
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants