This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MISRA-C

MISRA stands for "Motor Industry Software Reliability Association". IAR has an Embedded Workbench which I believe is a Tester to verify the implementation for the MISRA C rules.

Does KEIL have a such a tool?

If there a PDF document available that spells out the rules. I have search and all I can find are test suites.

Parents
  • goto really is useful in some situations.

    However, all usage should be very similar to the usage of break and continue, but with the ability to make it multi-level, i.e. to break out of (or restart) more than one encapsulation.

    You might have a function:

    void fnk(void) {
    
    restart:
        do_something();
        for (;;) {
            do_more();
            switch (x) {
                case 1:
                    if (error) goto fail;
                    do_work();
                    break;
                case 10:
                    do_even_more();
                    break;
                default:
                    goto restart;
            }
        }
    
    fail:
        do_cleanup();
    }
    

    Yes, it is possible to solve all flow problems with flags, a large set of conditionals, and optional extra loops, but there comes a point where these flags gets very hard to read. The code must check if it should leave (or restart) first level, then second level, ...

Reply
  • goto really is useful in some situations.

    However, all usage should be very similar to the usage of break and continue, but with the ability to make it multi-level, i.e. to break out of (or restart) more than one encapsulation.

    You might have a function:

    void fnk(void) {
    
    restart:
        do_something();
        for (;;) {
            do_more();
            switch (x) {
                case 1:
                    if (error) goto fail;
                    do_work();
                    break;
                case 10:
                    do_even_more();
                    break;
                default:
                    goto restart;
            }
        }
    
    fail:
        do_cleanup();
    }
    

    Yes, it is possible to solve all flow problems with flags, a large set of conditionals, and optional extra loops, but there comes a point where these flags gets very hard to read. The code must check if it should leave (or restart) first level, then second level, ...

Children