13.07.2015 Views

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CERT C Secure Coding StandardDCL32-CDCL35-CGuarantee that mutually visible identifiers are uniqueThe compiler encountered two or more identifiers that are identical in the first 31 characters.The ISO C99 standard allows a compiler to ignore characters past the first 31 in an identifier.Two distinct identifiers that are identical in the first 31 characters may lead to problems whenthe code is ported to a different compiler.Do not invoke a function using a type that does not match the function definitionThis warning is generated when a function pointer is set to refer to a function of anincompatible type. Calling this function through the function pointer will result in undefinedbehavior. Example:void my_function(int a);int main(void){int (*new_function)(int a) = my_function;return (*new_function)(10); /* the behavior is undefined */}19.3. Expressions (EXP)EXP01-CEXP12-CEXP30-CEXP32-CEXP33-CDo not take the size of a pointer to determine the size of the pointed-to typeThe size of the object(s) allocated by malloc(), calloc() or realloc() should be a multiple ofthe size of the base type of the result pointer. There<strong>for</strong>e, the sizeof expression should beapplied to this base type, and not to the pointer type.Do not ignore values returned by functionsThe compiler gives this warning when the result of a function call is ignored at some place,although it is not ignored <strong>for</strong> other calls to this function. This warning will not be issued whenthe function result is ignored <strong>for</strong> all calls, or when the result is explicitly ignored with a (void)cast.Do not depend on order of evaluation between sequence pointsBetween two sequence points, an object should only be modified once. Otherwise the behavioris undefined.Do not access a volatile object through a non-volatile referenceIf an attempt is made to refer to an object defined with a volatile-qualified type through useof an lvalue with non-volatile-qualified type, the behavior is undefined.Do not reference uninitialized memoryUninitialized automatic variables default to whichever value is currently stored on the stackor in the register allocated <strong>for</strong> the variable. Consequently, uninitialized memory can cause aprogram to behave in an unpredictable or unplanned manner and may provide an avenue<strong>for</strong> attack.857

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!