# 1 The code shall conform to ISO 9899, with no extensions permitted
# STATUS: Use compiler
defmisra1(data):
return
# 2 Code written in languages other than C should only be used if there is a defined interface
# STATUS: ?
defmisra2(data):
return
# 3 Assembler language functions that are called from C should be written as C functions containing only in-line assembly language, and in-line assembly language should not be embedded in normal C code
# 14 The type char shall always be declared as unsigned char or signed char
# STATUS: Done
defmisra14(data):
fortokenindata.tokenlist:
iftoken.str!='char':
continue
iftoken.isUnsignedortoken.isSigned:
continue
reportError(token,'style','14 The type char shall always be declared as unsigned char or signed char')
# 15 Floating point implementations should comply with a defined floating point standard
# STATUS: Done
defmisra15(data):
reportError(data.tokenlist[0],'style','15 Make sure the floating point implementation comply with a defined floating point standard')
# 16 The underlying bit representation of floating point numbers shall not be used in any way by the programmer
# STATUS: TODO : ValueType information is needed
defmisra16(data):
return
# 17 typedef names shall not be reused
# STATUS: Done (Cppcheck duplicateTypedef)
defmisra17(data):
return
# Constants
# ---------
# 18 Numeric constants should be suffixed to indicate type if possible
# STATUS: TODO
defmisra18(data):
return
# 19 Octal constants shall not be used
# STATUS: TODO
defmisra19(data):
return
# Declarations and Definitions
# ----------------------------
# 20 All object and function identifiers shall be declared before use
# STATUS: Use compiler
defmisra20(data):
return
# 21 Identifiers in inner scope shall not use same name as identifier in outer scope
# STATUS: Done. Use compiler (-Wshadow etc). Cppcheck has some checking also.
defmisra21(data):
return
# 22 Declaration of object should be at function scope unless a wider scope is necessary
# STATUS: TODO
defmisra22(data):
return
# 23 All declarations at file scope should be static if possible
# STATUS: TODO
defmisra23(data):
return
# 24 Identifiers shall not simultaneously have both internal and external linkage
# STATUS: Probably done. Use compiler.
defmisra24(data):
return
# 25 An identifier with external linkage shall have exactly one external definition
# STATUS: TODO
defmisra25(data):
return
# 26 If objects are declared more than once they shall have compatible declarations
# STATUS: Done. Use compiler.
defmisra26(data):
return
# 27 External objects should not be declared in more than one file
# STATUS: TODO
defmisra27(data):
return
# 28 The register storage class specifier should not be used
# STATUS: Done
defmisra28(data):
fortokenindata.tokenlist:
iftoken.str=='register':
reportError(token,'style','28 The register storage class specifier should not be used')
# 29 The use of a tag shall agree with its declaration
# STATUS: TODO
defmisra29(data):
return
# Initialisation
# --------------
# 30 All automatic variables shall have a value assigned to them before use
# STATUS: Done. Cppcheck uninitVar etc..
defmisra30(data):
return
# 31 Braces shall be used to indicate and match the structure in the non-zero initialisation of arrays and structures
# STATUS: TODO
defmisra31(data):
return
# 32 In an enumerator list the = construct shall not be used to explicitly initialise members other than the first unless it is used to initialise all items
# STATUS: TODO
defmisra32(data):
return
# Operators
# ---------
# 33 The right hand of a && or || shall not have side effects
# 59 The statements forming the body of an if, else, else if, .. shall always be enclosed in braces
# STATUS: TODO
defmisra59(data):
return
# 60 All if, else if constructs should contain a final else clause
# STATUS: TODO
defmisra60(data):
return
# 61 Every non-empty case clause in a switch statement shall be terminated with a break statement
# STATUS: TODO
defmisra61(data):
return
# 62 All switch statements shall contain a final default clause
# STATUS: Done. Compiler.
defmisra62(data):
return
# 63 A switch expression should not represent a Boolean value
# STATUS: TODO
defmisra63(data):
return
# 64 Every switch statement should have at least one case
# STATUS: TODO
defmisra64(data):
return
# 65 Floating point variables shall not be used as loop counters
# STATUS: TODO
defmisra65(data):
return
# 66 Only expression concerned with loop control should appear within a for statement
# STATUS: TODO
defmisra66(data):
return
# 67 Numeric variables being used within a for loop for iteration counting should not be modified in the body of the loop
# STATUS: TODO
defmisra67(data):
return
# Functions
# ---------
# 68 Functions shall always be declared at file scope
# STATUS: TODO
defmisra68(data):
return
# 69 Functions with a variable number of arguments shall not be used
# STATUS: TODO
defmisra69(data):
return
# 70 Functions shall not call themselves directly or indirectly
# STATUS: TODO
defmisra70(data):
return
# 71 Functions shall always have prototype declarations and the prototype shall be visible at both the function definition and call
# STATUS: Done. Compilers warn about mismatches.
defmisra71(data):
return
# 72 For each function parameter the type given and definition shall be identical, and the return type shall be identical
# STATUS: TODO
defmisra72(data):
return
#73 Identifiers shall either be given for all parameters in a prototype declaration, or none
# STATUS: TODO
defmisra73(data):
return
#74 If identifiers are given for any parameters, then the identifiers used in declaration and definition shall be identical
# STATUS: Done. Cppcheck builtin checker
defmisra74(data):
return
#75 Every function shall have an explicit return type
# STATUS: Done. Should be checked by compilers.
defmisra75(data):
return
# 76 Functions with no parameter list shall be declared with parameter type void
# STATUS: TODO
defmisra76(data):
return
# 77 The unqualified type of parameters passed to a function shall be compatible with the unqualified expected types defined in the function prototype
# STATUS: TODO
defmisra77(data):
return
# 78 The number of parameters passed to a function shall match the function prototype
# STATUS: TODO
defmisra78(data):
return
# 79 The value returned by void functions shall not be used
# STATUS: Done. Compilers
defmisra79(data):
return
# 80 Void expressions shall not be passed as function parameters
# STATUS: Done. Compilers
defmisra80(data):
return
# 81 const qualification should be used on function parameters that are passed by reference, where it is intended that the function will not modify the parameter
# STATUS: TODO
defmisra81(data):
return
# 82 A function should have a single exit point
# STATUS: TODO
defmisra82(data):
return
# 83 For functions that do not have void return type..
# STATUS: TODO
defmisra83(data):
return
# 84 For functions with void return type, return statements shall not have an expression
# STATUS: TODO
defmisra84(data):
return
# 85 Functions called with no parameters should have empty parentheses
# STATUS: TODO
defmisra85(data):
return
# 86 If a function returns error information then that information should be tested
# STATUS: TODO
defmisra86(data):
return
# Preprocessing Directives
# ------------------------
# 87 #include statements in a file shall only be preceded by other pre-processor directives or comments
# STATUS: TODO
defmisra87(data):
return
# 88 Non-standard characters shall not occur in header file names in #include directives
# STATUS: TODO
defmisra88(data):
return
# 89 The #include directive shall be followed be either a <filename> of "filename" sequence
# STATUS: TODO
defmisra89(data):
return
# 90 C macros shall only be used for symbolic constants, function like macros, type qualifiers and storage class specifiers
# STATUS: TODO
defmisra90(data):
return
# 91 Macros shall not be #define'd and #undef'd within a block
# STATUS: TODO
defmisra91(data):
return
# 92 #undef should not be used
# STATUS: TODO
defmisra92(data):
return
# 93 A function should be used in preference to a function-like macro
# STATUS: TODO
defmisra93(data):
return
# 94 A function-like macro shall not be 'called' without all of its arguments
# STATUS: TODO
defmisra94(data):
return
# 95 Arguments to a function-like macro shall not contain tokens that look like pre-processor directives
# STATUS: TODO
defmisra95(data):
return
# 96 In the definition of a function-like macro the whole definition, and each instance of a parameter, shall be enclosed in parenthesis
# STATUS: TODO
defmisra96(data):
return
# 97 Identifiers in pre-processor directives should be defined before use
# STATUS: TODO
defmisra97(data):
return
# 98 There shall be at most one occurance of the # or ## pre-processor operators in a single macro definition
# STATUS: TODO
defmisra98(data):
return
# 99 All use of #pragma directive shall be documented and explained
# STATUS: TODO
defmisra99(data):
return
# 100 The defined pre-processor operator shall only be used in one of the two standard forms
# STATUS: TODO
defmisra100(data):
return
# Pointers and arrays
# -------------------
# 101 Pointer arithmetic shall not be used
# STATUS: TODO
defmisra101(data):
return
# 102 No more than 2 levels of pointer indirection should be used
# STATUS: TODO
defmisra102(data):
return
# 103 Relational operators shall not be applied to pointer types except where both operands are of the same type and point to the same array, structure or union
# STATUS: TODO
defmisra103(data):
return
# 104 Non-constant pointers to functions shall not be used
# STATUS: TODO
defmisra104(data):
return
# 105 All functions pointed to by a single pointer to a function shall be identical in the number and type of parameters and the return type
# STATUS: TODO
defmisra105(data):
return
# 106 The address of an object with automatic storage shall not be assigned to an object which may persist after the object has ceased to exist
# STATUS: TODO
defmisra106(data):
return
# 107 The null pointer shall not be dereferenced
# STATUS: Cppcheck has this checking
defmisra107(data):
return
# Structures and unions
# ---------------------
# 108 In the specification of a structure or union type, all members of the structure or union shall be fully specified
# STATUS: TODO
defmisra108(data):
return
# 109 Overlapping variable storage shall not be used
# STATUS: TODO
defmisra109(data):
return
# 110 Unions shall not be used to access the sub-parts of larger data types
# STATUS: TODO
defmisra110(data):
return
# 111 Bit fields shall only be defined to be one of type unsigned int or signed int
# STATUS: TODO
defmisra111(data):
return
# 112 Bit fields of type signed int shall be at least 2 bits long
# STATUS: TODO
defmisra112(data):
return
# 113 All members of a structure or union shall be named and shall only be access with their name
# STATUS: TODO
defmisra113(data):
return
# Standard libraries
# ------------------
# 114 Reserved words and the standard library function names shall not be redefined or undefined
# STATUS: TODO
defmisra114(data):
return
# 115 Standard library names shall not be reused
# STATUS: TODO
defmisra115(data):
return
# 116 All libraries used in production code shall be written to comply with the provisions of MISRA
# STATUS: TODO
defmisra116(data):
return
# 117 The validity of values passed to library functions shall be checked
# STATUS: Cppcheck (--library)
defmisra117(data):
return
# 118 Dynamic heap memory allocation shall not be used
# STATUS: TODO
defmisra118(data):
return
# 119 The error indicator errno shall not be used
# STATUS: TODO
defmisra119(data):
return
# 120 The macro offsetof, in library <stddef.h>, shall not be used
# STATUS: TODO
defmisra120(data):
return
# 121 <local.h> and the setlocale function shall not be used
# STATUS: TODO
defmisra121(data):
return
# 122 The setjmp macro and the longjmp function shall not be used
# STATUS: TODO
defmisra122(data):
return
# 123 The signal handling facilities of <signal.h> shall not be used
# STATUS: TODO
defmisra123(data):
return
# 124 The input/output library <stdio.h> shall not be used in production code
# STATUS: TODO
defmisra124(data):
return
# 125 The library functions atof,atoi and atol shall not be used
# STATUS: TODO
defmisra125(data):
return
# 126 The library functions abort,exit,getenv and system shall not be used
# STATUS: TODO
defmisra126(data):
return
# 127 The time handling functions of library <time.h> shall not be used