Menu

Uninitialized variables check not working well at the moment

2021-05-18
2021-05-20
  • Daniel Marjamäki

    I am rewriting a part of the check for the uninitialized variables and believe that it will be noisy in the near future.

    I would prefer that you relax a bit with reporting problems for a week or so.. fixes are on the way.

     
    • Daniel Marjamäki

      I would prefer that you relax a bit with reporting problems for a week or so.. fixes are on the way.

      Feel free to report problems that you see now.

      It seems to me that most false positives currently in daca@home are caused by;
      * variable is initialized in function call. https://trac.cppcheck.net/ticket/10279
      * XtSetArg was not configured properly. Should be fixed in git HEAD.

       
  • Paul Fultz

    Paul Fultz - 2021-05-19

    We should just get rid of checkUninitVar and move all the logic to valueflow.

    I created a PR at least to fix the valueFlowUninit tests:

    https://github.com/danmar/cppcheck/pull/3262

    These tests are useful in checking changes to valueflow. I have a possible fix for #10263 but I want to make sure it wont break the valueFlowUninit tests(as the change might affect them).

     
  • Daniel Marjamäki

    I wanted to rewrite CheckUninitVar::isVariableUsage. It did not rely on AST properly and it was a mess. I think it's so much better now.

    I would be happy to get rid of the data flow logic from checkUninitVar.. when we feel that valueFlowUninit is enough. I feel that we should primarily fix false negatives by updating the valueflow.

     

    Last edit: Daniel Marjamäki 2021-05-19
  • Daniel Marjamäki

    There are many bugs that valueFlowUninit fails to detect, for instance for arrays and structs.

     
    • Paul Fultz

      Paul Fultz - 2021-05-20

      Yea, we shouldn't delete the checkUninit but rather move it to valueflow. Instead of warning about a uninit var, just set valueflow value to uninit.

      Although, it would be nice to use the analyzers to find struct members and arrays, but this is quite a bit more work. If we can just move what we currently have, this can help simplify the uninit checking and testing.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.