MISRA C

MISRA C is a set of software development guidelines for the C programming language developed by The MISRA Consortium. Its aims are to facilitate code safety, security, portability and reliability in the context of embedded systems, specifically those systems programmed in ISO C / C90 / C99.[1]

There is also a set of guidelines for MISRA C++ not covered by this article.

History

  • Draft: 1997[2]
  • First edition: 1998 (rules, required/advisory)
  • Second edition: 2004 (rules, required/advisory)
  • Third edition: 2012 (directives; rules, Decidable/Undecidable)
  • MISRA compliance: 2016, updated 2020
  • MISRA C:2023 (MISRA C Third edition, Second revision)

For the first two editions of MISRA-C (1998 and 2004) all Guidelines were considered as Rules. With the publication of MISRA C:2012 a new category of Guideline was introduced - the Directive whose compliance is more open to interpretation, or relates to process or procedural matters.

Adoption

Although originally specifically targeted at the automotive industry, MISRA C has evolved as a widely accepted model for best practices by leading developers in sectors including automotive, aerospace, telecom, medical devices, defense, railway, and others. For example:

  • The Joint Strike Fighter project C++ Coding Standards[3] are based on MISRA-C:1998.
  • The NASA Jet Propulsion Laboratory C Coding Standards[4] are based on MISRA-C:2004.
  • IEC 81001-5-1:2021 Health software and health IT systems safety, effectiveness and security - Part 5-1: Security - Activities in the product lifecycle cites MISRA C as an example of secure coding best practices.
  • ISO 26262 Functional Safety - Road Vehicles cites MISRA C as being an appropriate sub-set of the C language:
    • ISO 26262-6:2011 Part 6: Product development at the software level[5] cites MISRA-C:2004 and MISRA AC AGC.
    • ISO 26262-6:2018 Part 6: Product development at the software level[6] cites MISRA C:2012.
  • The AUTOSAR General Software Specification (SRS_BSW_00007) likewise cites MISRA C:
    • The AUTOSAR 4.2 General Software Specification[7] requires that If the BSW Module implementation is written in C language, then it shall conform to the MISRA C:2004 Standard.
    • The AUTOSAR 4.3 General Software Specification[8] requires that If the BSW Module implementation is written in C language, then it shall conform to the MISRA C:2012 Standard.

Guideline classification and categorization

When a new software project is started, the latest MISRA standard should be used. Previous standards are still available for use with legacy software projects that need to refer to it.[9]

Classification

Each Guideline is classified[10] as Mandatory (new for MISRA C:2012), Required or Advisory. Furthermore, the MISRA Compliance document permits Advisory guidelines to be Disapplied.

  • Mandatory guidelines shall always be complied with
  • Required guidelines shall be complied with, unless subject to a Deviation
  • Advisory guidelines are considered good practice, but compliance is less formal.

Categorization

The rules can be divided logically into a number of categories:

  • Avoiding possible compiler differences, for example, the size of C's int type may vary but int16_t (standardized in C99) is always 16 bits.
  • Avoiding using functions and constructs that are prone to failure, for example, malloc may fail.
  • Produce maintainable and debuggable code, for example, naming conventions and commenting.
  • Best practice rules.
  • Complexity limits.

Scope

MISRA C:2012 separately classifies each guideline as either Single Translation Unit or System.[10]

Decidability

MISRA C:2012 classifies the rules (but not the directives) as Decidable or Undecidable.

Achieving compliance

MISRA compliance

MISRA published documents to provide additional guidance to understand and achieve MISRA compliance.

  • MISRA Compliance:2016, was released by MISRA in April 2016.[11]
  • MISRA Compliance:2020, revised edition, was released in February 2020.[12]

Compliance

In order for a piece of software to claim to be compliant to the MISRA C Guidelines, all mandatory rules shall be met and all required rules and directives shall either be met or subject to a formal deviation. Advisory rules may be disapplied without a formal deviation, but this should still be recorded in the project documentation.

Note: For compliance purposes, there is no distinction between rules and directives.

Deviations

Many MISRA C rules can be characterized as guidelines because under certain condition software engineers may deviate from rules and still be considered compliant with the standard. Deviations must be documented either in the code or in a file. In addition; proof must be provided that the software engineer has considered the safety of the system and that deviating from the rule will not have a negative impact, requirements for deviations also include:

  • The rule deviated from.
  • Rationale for deviation.[13]

Published documents

MISRA C:1998

The first edition of MISRA C, "Guidelines for the use of the C language in vehicle based software", which was published in 1998 and is officially known as MISRA-C:1998.[14]

MISRA-C:1998 has 127 rules, of which 93 are required and 34 are advisory; the rules are numbered in sequence from 1 to 127.

MISRA C:2004

In 2004, a second edition "Guidelines for the use of the C language in critical systems", or MISRA-C:2004 was produced, with many substantial changes to the guidelines, including a complete renumbering of the rules.

MISRA-C:2004 contains 142 rules, of which 122 are "required" and 20 are "advisory"; they are divided into 21 topical categories, from "Environment" to "Run-time failures".

MISRA C:2012

Main document

In 2013, the third edition, MISRA C:2012, was published. MISRA C:2012 extends support to the C99 version of the C language (while maintaining guidelines for C90), in addition to including a number of improvements that can reduce the cost and complexity of compliance, whilst aiding consistent, safe use of C in critical systems.[15]

MISRA-C:2012 contains 143 rules and 16 "directives" (that is, rules whose compliance is more open to interpretation, or relates to process or procedural matters); each of which is classified as mandatory, required, or advisory. They are separately classified as either Single Translation Unit or System. Additionally, the rules are classified as Decidable or Undecidable.

Amendment 1

In April 2016, MISRA published (as a free download) MISRA C:2012 - Amendment 1: Additional Security Guidelines[16] which added fourteen new security guidelines.

Amendment 2

In February 2020, MISRA published (as a free download) MISRA C:2012 - Amendment 2: Updates for ISO/IEC 9899:2011/18 Core functionality[17] which adds mapping for the undefined, unspecified and implementation defined behaviours within C11/C18.

Supporting documents

MISRA have published the following addenda to support MISRA C:2012:

  • MISRA C:2012 - Addendum 1: Rule Mappings,[18] which contains bi-directional rule mappings between MISRA C:2004 and the new version. It is intended to assist users in migration.
  • MISRA C:2012 - Addendum 2: Coverage of MISRA C:2012 against ISO/IEC TS 17961:2013 "C Secure"[19]
  • MISRA C:2012 - Addendum 3: Coverage of MISRA C:2012 against CERT C[20]

MISRA C:2023

In May 2023 MISRA published MISRA C:2023 (MISRA C Third edition, Second revision) which incorporates Amendments 2 – 4 (AMD2, AMD3, AMD4) and Technical Corrigendum 2 (TC2) and incorporates support for C11 and C17 language features. [21]

Example suite

An exemplar suite (for MISRA-C:2004 and MISRA C:2012) is available from the MISRA GitLab[22] repository (login required). This allows tool-users to evaluate and compare the checking support provided by the various MISRA tools; additionally, it gives tool-implementers some guidance as to the intent of the MISRA Guidelines.

Tools

While there exist many software tools that claim to check code for "MISRA conformance", there is no MISRA certification process.[23]

Most of the guidelines can be checked using tools that perform static code analysis. The remaining guidelines require the use of dynamic code analysis.

Tools that check code for MISRA conformance include:

C/C++ compilers that support MISRA conformance include:

Criticism

Some research results question the effectiveness of MISRA C 2004.

In a paper that compares earlier work on MISRA C:1998 with MISRA C:2004, Les Hatton comes to the conclusion that:[30]

In view of the apparent widening influence of the MISRA C standard, this paper attempts to assess whether important deficiencies in the original standard have been addressed satisfactorily. Unfortunately, they have not and the important real to false positive ratio is not much better in MISRA C 2004 than it was in MISRA C 1998 and it is unacceptably low in both.

He goes on to state:[30]

In its present form, the only people to benefit from the MISRA C 2004 update would appear to be tool vendors and it is to be hoped that steps will be taken both to simplify the wording and to reduce the false positive ratio in future revisions by taking a little more notice of published experimental data and being less tempted to invent rules on the basis that they seem a good idea.

A study at the TU Delft, by Cathal Boogerd and Leon Moonen, empirically assesses the value of MISRA C:2004. It comes to similar results:[31]

From the data obtained, we can make the following key observations. First, there are 9 out of 72 rules for which violations were observed that perform significantly better (α = 0.05) than a random predictor at locating fault-related lines. The true positive rates for these rules range from 24-100%. Second, we observed a negative correlation between MISRA rule violations and observed faults. In addition, 29 out of 72 rules had a zero true positive rate. Taken together with Adams' observation that all modifications have a non-zero probability of introducing a fault, this makes it possible that adherence to the MISRA standard as a whole would have made the software less reliable.

See also

References

  1. ^ "MISRA clarifies safe and secure uses of the C language". www.misra.org.uk. Archived from the original on 2020-08-04. Retrieved 2019-10-09.
  2. ^ In spring 1997 software engineers at the Austin Rover Group (ARG) sent a draft C coding standard to Programming Research Ltd (PRL) for review. The review was performed by PRL's then senior consultant, David Blyth, who proposed replacing the draft with an appreciably stronger set of coding rules. Those rules, with minor changes, formed the basis of the first edition of MISRA C.
  3. ^ "Joint Strike Fighter Air Vehicle C++ Coding Standards" (PDF). Retrieved 2019-07-16.
  4. ^ "JPL Institutional Coding Standard for the C Programming Language" (PDF). Retrieved 2019-07-16.
  5. ^ "ISO 26262-6:2011 Road vehicles -- Functional safety -- Part 6: Product development at the software level". iso.org. ISO. Retrieved 2019-07-16.
  6. ^ "ISO 26262-6:2018 Road vehicles -- Functional safety -- Part 6: Product development at the software level". iso.org. ISO. Retrieved 2019-07-16.
  7. ^ "AUTOSAR 4.2 General Software Specification" (PDF). autosar.org. Retrieved 2019-07-16.
  8. ^ "AUTOSAR 4.3 General Specification of Basic Software Modules" (PDF). autosar.org. AutoSAR. 2016-11-30. Retrieved 2019-07-16.
  9. ^ MISRA publications
  10. ^ a b "Fact Sheet: MISRA C:2012 (PDF)" (PDF). programmingresearch.com. Retrieved 10 June 2013.
  11. ^ "MISRA Compliance:2016 (PDF)". MISRA. Retrieved 22 July 2016.
  12. ^ "MISRA Compliance:2020 (PDF)" (PDF). MISRA. Retrieved 8 April 2020.
  13. ^ "Achieving MISRA C:2012 Compliance". Parasoft. Retrieved May 29, 2017.
  14. ^ "A brief history of MISRA C". MISRA. 2013-03-18. Retrieved 2014-06-30.
  15. ^ "MISRA C:2012 release date announced". MISRA. 26 February 2013. Retrieved 10 June 2013.
  16. ^ "MISRA C:2012 - Amendment 1 (PDF)". MISRA. April 2016. Retrieved 31 October 2019.
  17. ^ "MISRA C:2012 - Amendment 2 (PDF)". MISRA. February 2020. Retrieved 6 January 2021.
  18. ^ "MISRA C:2012 - Addendum 1: Rule Mapping (PDF)".
  19. ^ "MISRA C:2012 - Addendum 2: Coverage of MISRA C:2012 against ISO/IEC TS 17961:2013 "C Secure" (PDF)".
  20. ^ "MISRA C:2012 - Addendum 3: Coverage of MISRA C:2012 against CERT C (PDF)".
  21. ^ "MISRA".
  22. ^ MISRA GitLab repository
  23. ^ "MISRA C FAQ list." MISRA Consortium
  24. ^ "Helix QAC for C and C++ | Perforce".
  25. ^ "Clearlake Capital-Backed Perforce Software to Acquire Rogue Wave Software | Perforce".
  26. ^ "Klocwork for C, C++, C#, Java, and JavaScript | Perforce".
  27. ^ "C/C++ Built-in Test Configurations". Parasoft. 17 October 2022. Retrieved 9 March 2023.
  28. ^ MISRA conformance checking, PC-lint/FlexeLint, Gimpel Software.
  29. ^ Languages and Standards; iar.com
  30. ^ a b Language subsetting in an industrial context: a comparison of MISRA C 1998 and MISRA C; Les Hatton; University of Kingston; 2004.
  31. ^ Assessing the Value of Coding Standards: An Empirical Study; C.J. Boogerd and L. Moonen; Delft University of Technology; 2008.

Read other articles:

1926 film The Ridin' RascalDirected byClifford SmithWritten byHarrison Jacobs (scenario)Isadore Bernstein (adaptation)Based onMavericksby William MacLeod RaineProduced byCarl LaemmleStarringArt AcordOlive HasbrouckBuck ConnorsCinematographyEdward LindenProductioncompanyUniversal PicturesDistributed byUniversal PicturesRelease date September 19, 1926 (1926-09-19) Running time5 reelsCountryUnited StatesLanguageSilent (English intertitles) The Ridin' Rascal is a 1926 American sile...

 

El Hierro Bendera El Hierro El Hierro merupakan sebuah pulau di Spanyol. Pulau ini terletak di bagian Samudera Atlantik. Tepatnya di Kepulauan Canary, Spanyol. Pada tahun 2003, pulau ini memiliki jumlah penduduk sebanyak 10.162 jiwa dan memiliki luas wilayah 278 km². Pulau ini memiliki angka kepadatan penduduk sebesar 37 jiwa/km². Kota terbesar di pulau ini ialah Valverde. Pranala luar El Hierro - official tourism website of the Canary Islands Information on flora and vegetation of El ...

 

Assassin spiders Austrarchaea sp. Klasifikasi ilmiah Kerajaan: Animalia Filum: Arthropoda Kelas: Arachnida Ordo: Araneae Subordo: Araneomorphae Superfamili: Archaeoidea Famili: ArchaeidaeC. L. Koch & Berendt, 1854 Genera lihat teks Diversitas 3 genera, 28 spesies Archaeidae adalah keluarga laba-laba dengan 25 spesies dijelaskan dalam tiga genera. Umumnya dikenal sebagai laba-laba pembunuh, mereka juga dikenal sebagai laba-laba pelikan karena anatomi khusus mereka: mereka memiliki keliser...

Geological feature in California The Northridge Blind Thrust Fault (also known as the Pico Thrust Fault) is a thrust fault that is located in the San Fernando Valley area of Los Angeles. It is the fault that triggered the Mw 6.7 1994 Northridge earthquake which caused $13–50 billion in property damage (equivalent to 24–93 billion today) and was one of the costliest natural disasters in U.S. history.[1][2] Map showing active faults of California in gray, blind thrust faults...

 

Ancient Mayan society was similar to other societies in regard to their social classes. The two main categories in society were the elite class and the commoner class. The elites had control over every city's politics and religion; however, the vast majority of the population fell into the commoners category. The Maya lived in houses surrounded by extended family. The type of house that an individual had depended largely on how much power they had. The elites had houses that were larger and m...

 

JogonalanKecamatanPeta lokasi Kecamatan JogonalanNegara IndonesiaProvinsiJawa TengahKabupatenKlatenPemerintahan • CamatMurdoko,SH.Populasi • Total58,526 jiwaKode Kemendagri33.10.08 Kode BPS3310090 Luas26,70 km²Desa/kelurahan18 Jogonalan (Jawa: ꦗꦒꦤꦭꦤ꧀, translit. Jaganalan) adalah sebuah kecamatan di Kabupaten Klaten, Jawa Tengah Batas Wilayah Utara Kecamatan Karangnongko Timur laut Kecamatan Kebonarum Timur Kecamatan Klaten Selatan Tenggara Ke...

Largest component of the executive branch of the government of the Philippines Politics of the Philippines Government Constitution of the Philippines Charter Change Laws Legal codes Taxation Executive President of the Philippines Bongbong Marcos (PFP) Vice President of the Philippines Sara Duterte (HNP) Cabinet (lists) Executive departments Local government Legislature Congress of the Philippines 19th Congress Senate President Migz Zubiri (Independent) House of Representatives Speaker Martin ...

 

István Vad Informazioni personali Arbitro di Calcio Federazione  Ungheria Professione Imprenditore Altezza 179 cm Peso 78 kg Attività nazionale Anni Campionato Ruolo 2004- Soproni Liga Arbitro Attività internazionale 2007- UEFA e FIFA Arbitro Esordio Croazia-Andorra 4-015 ottobre 2008 István Vad (Budapest, 30 maggio 1979) è un arbitro di calcio ungherese. Indice 1 Carriera 2 Note 2.1 Fonti 3 Altri progetti Carriera Arbitro del massimo campionato nazionale ungherese dal 2004, è int...

 

Voce principale: Rimini Baseball Club. Rimini Baseball ClubStagione 2015Sport baseball Squadra Rimini Manager Orlando Muñoz Pitching coachCoach Pier Paolo Illuminati Cesar Heredia Paolo Siroli Andrea Palumbo Presidente Cesare Rino Zangheri IBLVincitore Champions Cupfase a gruppi 2014 2016 Il Rimini Baseball Club ha preso parte alla Italian Baseball League 2015. Indice 1 Divise e sponsor 2 Roster 3 Organigramma 4 Risultati 4.1 Italian Baseball League 4.1.1 Italian Baseball Series 5 Voci...

British musician (1946–2017) This article is about the composer and guitarist. For the musician and disability activist known as Johnny Crescendo, see Alan Holdsworth. Allan HoldsworthHoldsworth in 2012Background informationBorn(1946-08-06)6 August 1946Bradford, EnglandDied15 April 2017(2017-04-15) (aged 70)Vista, California, USGenresJazz fusioninstrumental rockprogressive rockOccupation(s)MusiciancomposerproducerInstrument(s)GuitarSynthAxeviolinYears active1969–2017LabelsCTIJMS–Cr...

 

この記事は検証可能な参考文献や出典が全く示されていないか、不十分です。出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方)出典検索?: コルク – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL(2017年4月) コルクを打ち抜いて作った瓶の栓 コルク(木栓、�...

 

ヨハネス12世 第130代 ローマ教皇 教皇就任 955年12月16日教皇離任 964年5月14日先代 アガペトゥス2世次代 レオ8世個人情報出生 937年スポレート公国(中部イタリア)スポレート死去 964年5月14日 教皇領、ローマ原国籍 スポレート公国親 父アルベリーコ2世(スポレート公)、母アルダその他のヨハネステンプレートを表示 ヨハネス12世(Ioannes XII、937年 - 964年5月14日)は、ロ...

The Te of Piglet PengarangBenjamin HoffBahasaInggrisSubjekTaoisme, FilsafatPenerbitDutton BooksTanggal terbit1992Halaman257ISBNISBN 0-525-93496-0OCLC25413491Desimal Dewey299/.514 20LCCPR6025.I65 Z69 1992Didahului olehThe Tao of Pooh  The Te of Piglet adalah sebuah buku non-fiksi filsafat tahun 1992 yang ditulis oleh Benjamin Hoff sebagai susulan dari karya tahun 1982 buatannya The Tao of Pooh.[1] Buku tersebut ditulis oleh Dutton Books dan bertahan selama 21 pekan ...

 

Indiana Hoosiers field hockeyFull nameIndiana Hoosiers field hockeyNickname(s)HoosiersFounded2000[1]Home groundIU Field Hockey Complex[1][2](Capacity 500)CoachKayla BashoreUniversityIndiana UniversityConferenceBig Ten ConferenceNCAA Tournament appearances2005, 2009[3] The Indiana Hoosiers field hockey team is the intercollegiate field hockey program representing Indiana University. The school competes in the Big Ten Conference in Division I of the National Coll...

 

Egyptian politician (1929–2008) Yousef Sabri Abu Taleb Giad Al-HaqMinister of Defence of EgyptIn officeApril 1989 – May 1991PresidentHosni MubarakPrime MinisterAtef SedkiPreceded byAbd al-Halim Abu GhazalaSucceeded byMohamed Hussein Tantawi Personal detailsBorn24 May 1929Died29 September 2008 (aged 79)Political partyIndependentMilitary serviceAllegiance EgyptBranch/service Egyptian ArmyYears of service1948–1991Rank Colonel General[1]CommandsCommander-in-C...

Chilean–American actor, presenter, model and producer In this Spanish name, the first or paternal surname is de la Fuente and the second or maternal family name is Sabarots. Cristián de la Fuentede la Fuente in 2011BornCristián Andrés de la Fuente Sabarots (1974-03-10) March 10, 1974 (age 50)Santiago, ChileOccupationsActortelevision presentermodelproducerYears active1994–presentHeight1.85 m (6 ft 1 in)Spouse Angélica Castro ​(m. 2002...

 

PaddingtonSydney, New South WalesPaddington Town HallJumlah penduduk11,660[1] • KepadatanGalat Lua: Tidak dapat mengkonversi populasi "11.660'"`UNIQ--ref-00000000-QINU`"'" menjadi bilangan.Kode pos2021Luas1,5 km2 (0,6 sq mi)Letak3 km (2 mi) sebelah timur Sydney CBDLGA City of Sydney Municipality of WoollahraDaerah pemilihan negara bagianSydneyDivisi FederalWentworth Suburban di sekitar Paddington: Darlinghurst Rushcutters Bay ...

 

  لمعانٍ أخرى، طالع البلدة القديمة (توضيح). البلدة القديمةالبلدة القديمةمعلومات عامةنوع المبنى settlement site (en) المكان محافظة العلا - المدينة المنورةالمنطقة الإدارية العلا البلد  السعوديةمعلومات أخرىالإحداثيات 26°37′N 37°55′E / 26.62°N 37.92°E / 26.62; 37.92 تعديل - تعديل...

The Marvel Super Heroesserie TV d'animazione Lingua orig.inglese PaeseStati Uniti MusicheJacques Urbont StudioGrantray-Lawrence Animation ReteSyndication 1ª TV1º settembre – 1º dicembre 1966 Episodi65 (completa) Rapporto4:3 Durata ep.22 min 1ª TV it.22 giugno 1978 – ? Episodi it.65 (completa) Genereazione, avventura, fantascienza The Marvel Super Heroes è la prima serie televisiva d'animazione tratta dai fumett...

 

Muse of epic poetry This article is about the muse. For the steam instrument, see Calliope (music). For other uses, see Calliope (disambiguation). CalliopeGoddess of Epic PoetryMember of the MusesDetail of painting The Muses Urania and Calliope by Simon Vouet, in which she holds a copy of the OdysseyAbodeMount OlympusSymbolsLyrePersonal informationParentsZeus and MnemosyneSiblingsEuterpe, Polyhymnia, Urania, Clio, Erato, Thalia, Terpsichore, Melpomene and several paternal half-siblingsConsort...