MISRA Checks are one of the most mature and widely used coding standards that include checks which make sure you avoid common programming errors. Today, if you are a C/C++ developer working on embedded systems, it is extremely important that you include MISRA checks as a part of your development process. It is the most widely adopted standard by various industries including rail, aerospace, military and medical sector. These coding guidelines ensure best practices in developing secure and safe electronic systems in embedded systems. Listed below are some of the MISRA checks which ensure robustness and maintainability of your code.
Unsafe API MISRA C: 2012 21.7
The Standard Library functions atof, atoi, atol and atoll of <stdlib.h> shall not be used. This check detects errors when converting a string to a number. It also maps to CERT C Coding Standard rule ERR34-C.
int x (const char * ex) { return atoi(numstr); } // Noncompliant Code
int x(const char * ex) { return strtol(numstr, NULL, 10); } // Compliant Code
Uninitialized memory access MISRA C: 2012 9.3
Arrays shall not be partially initialized. If one or several array items are initialized explicitly, all the items should be explicitly initialized.
int noncompliant[4] = { [0] = 3,[1] = 1, 0 }; // Noncompliant Code
int compliant[4] = { [0] = 3,[1] = 1,[2] = 4 }; // Compliant Code
MISRA checks on EMBOLD
Though MISRA coding standards are great by themselves, just having them as a part of your development process as guidelines is not enough. You need to ensure that these checks are enforced. And a tool like Embold can help you with that.
Some of the EMBOLD features that help you make sure that you code is MISRA complaint are:
EMBOLD Quality Gates
Quality gates help you keeps a watch on your repository based on the quality thresholds set by you and lets you know when a failure happens. Know how you can set the Quality gate profile here (https://docs.embold.io/quality-gate-profiles/#quality-gate-profiles)
Pull Request
Embold facilitates a easier review of changes in your code. When a new pull request is made, Embold automatically scans the changed files and reports various issues on Embold UI. Learn more about PR (https://docs.embold.io/development-history/#pull-request-workflow)
Enable/Disable Rules
You can prioritize issues by enabling or disabling them through Embold’s code checker configurations. Read more (https://docs.embold.io/code-checker-configuration/#code-checker-configuration)
PDF/ CSV Report download
PDF Compliance Report: This report contains statistics, details of scan summary, issue name, graphical representation of violations that are tagged against MISRA.
CSV MISRA Report: This report contains information (criticality etc) about all the MISRA violations in that repository.
To conclude, having a safe and secure code is need of the hour and a tool like EMBOLD will ensure that you catch and fix issues as early as possible in the development cycle.
Comments are closed.