The-Software-Experts




Google
 




   catch your bugs!
  Home
  Newsletter
  Forum
  Shop

  SW-Training
  - Software Design
  - Safe Coding in C
  - Software Inspection
  - Software Testing
  

  SW-Design
  - Architecture
  - Module Design
  

  Coding in C
  - Safe Coding in C
  

  Refactoring
  - Principles
  - Methods
  

  SW-Testing
  - Principles
  - Static Analysis
  - Inspections
  - Module Tests
  - Functional Tests
  - Integration Tests
  - Test Documentation
  - Links
  

  SW-Documentation
  - SGML Principles
  - Printing SGML
  - Links
  

  SW-Processes
  - Process Descriptions
  - Process Assessments
  - Self Evaluation
  - Food for Thought
  - Links
  

Safety Software
Design Training

IEC 61508 compliant
Safety Software
Design for Microcontroller

SW Document
Templates

CMMI and SPICE
compliant document
templates

SW Process
Description

CMMI Level 4 and
SPICE compliant SW
development procedure

SGML Package for
Documentation

Edit and print SGML
Documemts. Professional.
fast, easy to use.

Test Bench
for C/C++

Perl based test
environment for easy
component testing

Safe Coding in C Training

This course has the prerequisite that you already know the C programming language and have some experience in programming. However there are some traps and pitfalls in C which you have to avoid if you want to write C code of good quality. An analysis of the C standard will make you aware of the problematic areas and will give you the understanding why these traps are in the programming language. This is followed by a detailed exploration of each problematic area with examples and exercises. After the course you will be able to understand and avoid the traps and pitfalls and restrict yourself to a safe subset of the programming language. This subset will be similar to the suggested practices addressed by the MISRA standard. The course has a length of 2 full days and can be held in English or German. The training material is in English. I would be glad to receive your requests for inhouse trainings. You can use our contact sheet for this.

The contents of the course are:

The problem of C Standard

There is a C-standard, but not all things are defined by this standard. Most programmers are not aware of these open and undefined items which often differ from compiler to compiler. Only knowing about these problematic areas will make you a successful programmer. The following subjects will be addressed:

  • Overview
  • Unspecified behavior
  • Undefined behavior
  • Implementation defined behavior
  • Defect reports
  • Empirically determined misbehavior

Difficulties in C

Expressions

There are various possibilities of injecting errors into C expressions, as e.g. the mixing of data types. Different data types are often used randomly and mixed in a C-program without being aware of the implications. Additionally to this the compiler will perform promotion and balancing which performs an implicit modification of the data types. Compiler mechanisms and the resulting pitfalls are explained and shown in various examples. Further there is the influence of operators and other elements which may lead to errors. E.g. there is a precedence of operators in C, there are so called side effects and the order of their evaluation which may lead to behaviour you would not have expected. The concepts and the resulting possible pitfalls are explained in detail. The following areas are addressed:

  • Floating Point Arithmetic
  • Order of Evaluation
  • Precedence of Operators
  • Mixing of Signed and Unsigned
  • Data Conversion (Compatible types, Type of constants, Type qualifiers and Type specifiers, Integral promotion, Balancing, Type casting, Bitfields, Representation of negative numbers)

Scope, Linkage and Namespaces

This part of the course will make you acquainted with the scope of data definitions and the linkage of data. From these principles possible errors may arise in your program, especially by later maintenance activities. It will be explained for which ranges of your program data can be defined and how the mechanisms of the compiler and linker work on the various data definitions. Further there are different namespaces in C, which means that the same identifier (name) can be used for various purposes. This could lead to confusion and should be avoided by naming restrictions.

Pointers

Pointers in C can be also a source of trouble. Some commonly performed sins will be pointer out in the course, their implicationts are explained and recommendations about how to avoid them are given.

The Pre-Processor

Using the pre-processor the wrong way will make your program loose its portability. Some pre-processor mechanisms are eplained in the course which will improve your pre-processor usage.

Interfaces

There are old style and new style interfaces in C. Some recommendations about their usage is given. Furhter there will be a lot of hints about how to avoid errors coming from a mismatch of interfaces between functions.

Memory

C allows various types of memory usage. These types are explained and hints are given which ones are suitable for safe programming.

Naming Conventions

Having unclear namings of your variables in C may lead to unexpected trouble. A good naming convention which is followed strictly will help you to avoid many of the addressed problems as e.g. scope and linkage problems. Naming conventions are often seen as a formalistic effort without a lot of meaning. But quite the contrary is the case. They will make life easier in coding, maintenance and for inspections and they will help you to avoid errors in your program. Some important elements which should be present in names of variables and functions wil be outlined in the course.









Imprint