Menu

Misra rules 7.3 FALSE positive

2021-04-27
2021-04-27
  • Jean-Loic MARTIN

    Hi all, i'm facing a problem with MISRA rule 7.3.
    This rule indicates that the suffix 'l' shouldn't not be used.
    Prefer using 'L' suffix if needed.

    But the rule generates false positive on my struct.

    typedef struct 
    {
        /** Frequency of clock A in Hz (set 0 to turn it off) */
        uint32_t ul_clka;
        /** Frequency of clock B in Hz (set 0 to turn it off) */
        uint32_t ul_clkb;
        /** Frequency of master clock in Hz */
        uint32_t ul_mck;
    } pwm_clock_t;
    

    I'm using CppCheck 2.3 on Windows 10.

    I have attached small code.

    The command is:
    "c:\Program Files\Cppcheck\cppcheck.exe" --enable=all --inline-suppr --suppress=unusedFunction --suppress=missingInclude --addon=misra.json misra_7_3.c

    The result is :

    misra_7_3.c:5:11: style: The lowercase character â?olâ?? shall not be used in a literal suffix [misra-c2012-7.3]
     uint32_t ul_clka;
              ^
    misra_7_3.c:7:11: style: The lowercase character â?olâ?? shall not be used in a literal suffix [misra-c2012-7.3]
     uint32_t ul_clkb;
              ^
    misra_7_3.c:9:11: style: The lowercase character â?olâ?? shall not be used in a literal suffix [misra-c2012-7.3]
     uint32_t ul_mck;
              ^
    misra_7_3.c:16:10: style: The lowercase character â?olâ?? shall not be used in a literal suffix [misra-c2012-7.3]
            .ul_clka = 100000U,
             ^
    misra_7_3.c:17:10: style: The lowercase character â?olâ?? shall not be used in a literal suffix [misra-c2012-7.3]
            .ul_clkb = 0u,
             ^
    misra_7_3.c:18:10: style: The lowercase character â?olâ?? shall not be used in a literal suffix [misra-c2012-7.3]
            .ul_mck = 64000000U
    

    Note: I have not attached the "misra-rules.txt" file due to licence terms.

    It's clear that it's a false positive.

     
  • Georgiy Komarov

    Georgiy Komarov - 2021-04-27

    Thank you! The following PR should fix this: https://github.com/danmar/cppcheck/pull/3236 .

     
  • Jean-Loic MARTIN

    Thank you for your answer Georgiy !

     

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.