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

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

Category: Incorrect expression
Function: test_macro_names
Component: Tests
CID: 209383

Details:

893         zassert_true(!strcmp(TO_STRING(DT_ALIAS(test_alias)),
894                      "DT_N_S_test_S_gpio_deadbeef"),
895                  "alias");
896         zassert_true(!strcmp(TO_STRING(DT_NODELABEL(test_nodelabel)),
897                      "DT_N_S_test_S_gpio_deadbeef"),
898                  "nodelabel");
>>>     CID 209383:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("DT_N_S_test_S_gpio_deadbeef", "DT_N_S_test_S_gpio_deadbeef")" is always 0 because ""DT_N_S_test_S_gpio_deadbeef"" is compared against itself.
899         zassert_true(!strcmp(TO_STRING(DT_NODELABEL(test_nodelabel_allcaps)),
900                      "DT_N_S_test_S_gpio_deadbeef"),
901                  "nodelabel (all caps)");
902     }
903    
904     static int a[] = DT_PROP(TEST_ARRAYS, a);
887     static void test_macro_names(void)
888     {
889         /* white box */
890         zassert_true(!strcmp(TO_STRING(DT_PATH(test, gpio_deadbeef)),
891                      "DT_N_S_test_S_gpio_deadbeef"),
892                  "path");
>>>     CID 209383:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("DT_N_S_test_S_gpio_deadbeef", "DT_N_S_test_S_gpio_deadbeef")" is always 0 because ""DT_N_S_test_S_gpio_deadbeef"" is compared against itself.
893         zassert_true(!strcmp(TO_STRING(DT_ALIAS(test_alias)),
894                      "DT_N_S_test_S_gpio_deadbeef"),
895                  "alias");
896         zassert_true(!strcmp(TO_STRING(DT_NODELABEL(test_nodelabel)),
897                      "DT_N_S_test_S_gpio_deadbeef"),
898                  "nodelabel");
884     #define TO_STRING(x) TO_STRING_(x)
885     #define TO_STRING_(x) #x
886    
887     static void test_macro_names(void)
888     {
889         /* white box */
>>>     CID 209383:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("DT_N_S_test_S_gpio_deadbeef", "DT_N_S_test_S_gpio_deadbeef")" is always 0 because ""DT_N_S_test_S_gpio_deadbeef"" is compared against itself.
890         zassert_true(!strcmp(TO_STRING(DT_PATH(test, gpio_deadbeef)),
891                      "DT_N_S_test_S_gpio_deadbeef"),
892                  "path");
893         zassert_true(!strcmp(TO_STRING(DT_ALIAS(test_alias)),
894                      "DT_N_S_test_S_gpio_deadbeef"),
895                  "alias");
890         zassert_true(!strcmp(TO_STRING(DT_PATH(test, gpio_deadbeef)),
891                      "DT_N_S_test_S_gpio_deadbeef"),
892                  "path");
893         zassert_true(!strcmp(TO_STRING(DT_ALIAS(test_alias)),
894                      "DT_N_S_test_S_gpio_deadbeef"),
895                  "alias");
>>>     CID 209383:    (CONSTANT_EXPRESSION_RESULT)
>>>     "strcmp("DT_N_S_test_S_gpio_deadbeef", "DT_N_S_test_S_gpio_deadbeef")" is always 0 because ""DT_N_S_test_S_gpio_deadbeef"" is compared against itself.
896         zassert_true(!strcmp(TO_STRING(DT_NODELABEL(test_nodelabel)),
897                      "DT_N_S_test_S_gpio_deadbeef"),
898                  "nodelabel");
899         zassert_true(!strcmp(TO_STRING(DT_NODELABEL(test_nodelabel_allcaps)),
900                      "DT_N_S_test_S_gpio_deadbeef"),
901                  "nodelabel (all caps)");

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