Menu

MISRA addon errors

2019-01-16
2019-05-08
  • Lucas Karpinski

    Lucas Karpinski - 2019-01-16

    Hi,

    I finished adding on to the misra.py script so that it generates an xml file that can be easily brought into cppcheckhtmlreport addon.

    I tested misra.py on multiple files previously and verified its functionality, but now that I can run it through entire directories, I noticed that occasionally when running parsedump() there can be issues. It seems that even though it checked the dump file and searched for the "dump" subnode, it wasn't able to find it and ended up populating Configurations as a None type, leading to innerScope being populated as a None type. I've noticed this error and a keyerror and was wondering if I'm missing anything here. This error is stopping me from running the misra check on my directories so I'd like to know what the issue is if possible.

    (This only happens on the occasional file)

    Traceback (most recent call last):
    File "/home/lucas/cppcheck_all/addons/misra.py", line 2206, in <module>
    checker.parseDump(globalfilelocation + ".dump")
    File "/home/lucas/cppcheck_all/addons/misra.py", line 2043, in parseDump
    self.misra_5_3(cfg)
    File "/home/lucas/cppcheck_all/addons/misra.py", line 705, in misra_5_3
    enum_token = innerScope.bodyStart.next
    AttributeError: 'NoneType' object has no attribute 'next'</module>

    Nothing in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message.

    Confidentiality Note: This message is intended only for the person or entity to which it is addressed. It may contain confidential and/or privileged material. Any review, transmission, dissemination or other use, or taking of any action in reliance upon this message by persons or entities other than the intended recipient is prohibited and may be unlawful. If you received this message in error, please contact the sender and delete it from your computer.

     
  • versat

    versat - 2019-01-17

    What Python version are you using?
    Is the issue reproducable? Does it happen always with the same file at the same place ? "occasional" sounds like it does not happen always with the same file, but i want to be sure.
    I guess it is not easy but could you maybe try to create a small example where this can be reproduced?
    Does the "dump" subnode exists in the dump file where the error occurrs?

     
  • Richard Smith

    Richard Smith - 2019-01-18

    I put in a PR a while ago that deal with this sort of thing for code that contained varidic macros. Rather than hunt down what was up with cppcheck I just added a check for None and skipped whatever check was happening.

    This might be a variant of that. If you want a way for cppcheck to produce a dump file that the misra checker will choke on then add in a varidic macro into the code and remove the lines in misra_5_2 and misra_5_3 that check for None. The ones like this:
    if var.nameToken is not None:

     
  • Lijun Chen

    Lijun Chen - 2019-05-08

    I encountered the same bug.
    By inspecting the dump, I found out that the failing node had the classStart and classEnd attributes instead of bodyStart andbodyEnd.
    I was using the 1.82 version of cppcheck present in Ubuntu archives.

    I managed to fix the problem by compiling the newest version of cppcheck, which generates the correct dump.

    Actually when I generated the dump with the old version of cppcheck, I was using misra.py from an newer version, so it was a version incompatibility issue (my fault).

    Hope it can help.

     

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.