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 :209369] Pointless string comparison in tests/lib/devicetree/src/main.c #24040

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#L68

Category: Incorrect expression
Function: test_alias_props
Component: Tests
CID: 209369

Details:

66         zassert_equal(DT_REG_ADDR(TEST_ALIAS), 0xdeadbeef, "reg[0] addr");
67         zassert_equal(DT_REG_SIZE(TEST_ALIAS), 0x1000, "reg[0] len");
68         zassert_true(!strcmp(DT_LABEL(TEST_ALIAS), "TEST_GPIO_1"), "label");
69         zassert_equal(DT_PROP(TEST_ALIAS, gpio_controller), 1,
70                   "gpio-controller");
71         zassert_equal(DT_PROP(TEST_ALIAS, ngpios), 32, "ngpios");
>>>     CID 209369:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("okay", "okay")" is always 0 because ""okay"" is compared against itself.
72         zassert_true(!strcmp(DT_PROP(TEST_ALIAS, status), "okay"), "status");
73         zassert_equal(DT_PROP_LEN(TEST_ALIAS, compatible), 1,
74                   "compatible len");
75         zassert_true(!strcmp(DT_PROP_BY_IDX(TEST_ALIAS, compatible, 0),
76                      "vnd,gpio"),
77                  "compatible[0]");
69         zassert_equal(DT_PROP(TEST_ALIAS, gpio_controller), 1,
70                   "gpio-controller");
71         zassert_equal(DT_PROP(TEST_ALIAS, ngpios), 32, "ngpios");
72         zassert_true(!strcmp(DT_PROP(TEST_ALIAS, status), "okay"), "status");
73         zassert_equal(DT_PROP_LEN(TEST_ALIAS, compatible), 1,
74                   "compatible len");
>>>     CID 209369:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("vnd,gpio", "vnd,gpio")" is always 0 because ""vnd,gpio"" is compared against itself.
75         zassert_true(!strcmp(DT_PROP_BY_IDX(TEST_ALIAS, compatible, 0),
76                      "vnd,gpio"),
77                  "compatible[0]");
78     }
79    
80     static void test_nodelabel_props(void)
62    
63     static void test_alias_props(void)
64     {
65         zassert_equal(DT_NUM_REGS(TEST_ALIAS), 1, "num regs");
66         zassert_equal(DT_REG_ADDR(TEST_ALIAS), 0xdeadbeef, "reg[0] addr");
67         zassert_equal(DT_REG_SIZE(TEST_ALIAS), 0x1000, "reg[0] len");
>>>     CID 209369:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("TEST_GPIO_1", "TEST_GPIO_1")" is always 0 because ""TEST_GPIO_1"" is compared against itself.
68         zassert_true(!strcmp(DT_LABEL(TEST_ALIAS), "TEST_GPIO_1"), "label");
69         zassert_equal(DT_PROP(TEST_ALIAS, gpio_controller), 1,
70                   "gpio-controller");
71         zassert_equal(DT_PROP(TEST_ALIAS, ngpios), 32, "ngpios");
72         zassert_true(!strcmp(DT_PROP(TEST_ALIAS, status), "okay"), "status");
73         zassert_equal(DT_PROP_LEN(TEST_ALIAS, compatible), 1,

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.

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