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

[Coverity CID :209376] Pointless string comparison in tests/lib/devicetree/src/main.c #24033

Closed
zephyrbot opened this issue Apr 2, 2020 · 1 comment
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/29c0c08fd4abc34aae4e1bf579cc506eaabef428/tests/lib/devicetree/src/main.c#L1079

Category: Incorrect expression
Function: test_clocks
Component: Tests
CID: 209376

Details:

1104         /* DT_INST_CLOCKS_LABEL_BY_IDX */
1105         zassert_true(!strcmp(DT_INST_CLOCKS_LABEL_BY_IDX(0, 0),
1106                      "TEST_CLOCK"),
1107                  "label 0");
1108    
1109         /* DT_INST_CLOCKS_LABEL */
>>>     CID 209376:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("TEST_CLOCK", "TEST_CLOCK")" is always 0 because ""TEST_CLOCK"" is compared against itself.
1110         zassert_true(!strcmp(DT_INST_CLOCKS_LABEL(0), "TEST_CLOCK"),
1111                  "label 0");
1112    
1113         /* DT_INST_CLOCKS_CELL_BY_IDX */
1114         zassert_equal(DT_INST_CLOCKS_CELL_BY_IDX(0, bits, 2), 2,
1115                   "clk 2 bits");
1099                   "fixed clk freq");
1100    
1101         /* DT_INST */
1102         zassert_equal(DT_NUM_INST(DT_DRV_COMPAT), 1, "one instance");
1103    
1104         /* DT_INST_CLOCKS_LABEL_BY_IDX */
>>>     CID 209376:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("TEST_CLOCK", "TEST_CLOCK")" is always 0 because ""TEST_CLOCK"" is compared against itself.
1105         zassert_true(!strcmp(DT_INST_CLOCKS_LABEL_BY_IDX(0, 0),
1106                      "TEST_CLOCK"),
1107                  "label 0");
1108    
1109         /* DT_INST_CLOCKS_LABEL */
1110         zassert_true(!strcmp(DT_INST_CLOCKS_LABEL(0), "TEST_CLOCK"),
1078         /* DT_CLOCKS_LABEL_BY_IDX */
1079         zassert_true(!strcmp(DT_CLOCKS_LABEL_BY_IDX(TEST_TEMP, 0),
1080                      "TEST_CLOCK"),
1081                  "label 0");
1082    
1083         /* DT_CLOCKS_LABEL */
>>>     CID 209376:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("TEST_CLOCK", "TEST_CLOCK")" is always 0 because ""TEST_CLOCK"" is compared against itself.
1084         zassert_true(!strcmp(DT_CLOCKS_LABEL(TEST_TEMP), "TEST_CLOCK"),
1085                  "label 0");
1086    
1087         /* DT_CLOCKS_CELL_BY_IDX */
1088         zassert_equal(DT_CLOCKS_CELL_BY_IDX(TEST_TEMP, bits, 2), 2,
1089                   "clk 2 bits");
1073    
1074     #undef DT_DRV_COMPAT
1075     #define DT_DRV_COMPAT vnd_adc_temp_sensor
1076     static void test_clocks(void)
1077     {
1078         /* DT_CLOCKS_LABEL_BY_IDX */
>>>     CID 209376:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("TEST_CLOCK", "TEST_CLOCK")" is always 0 because ""TEST_CLOCK"" is compared against itself.
1079         zassert_true(!strcmp(DT_CLOCKS_LABEL_BY_IDX(TEST_TEMP, 0),
1080                      "TEST_CLOCK"),
1081                  "label 0");
1082    
1083         /* DT_CLOCKS_LABEL */
1084         zassert_true(!strcmp(DT_CLOCKS_LABEL(TEST_TEMP), "TEST_CLOCK"),

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v32951/p12996.

Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the CODEOWNERS file.

@zephyrbot zephyrbot added bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug labels Apr 2, 2020
@nashif nashif assigned mbolivar-nordic and unassigned nashif Apr 2, 2020
@galak
Copy link
Collaborator

galak commented Apr 2, 2020

False positive, this is what the test is trying to do.

@galak galak closed this as completed Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

4 participants