2.1 Code Refine 과정

🚨

SWUD에서 Code Reverse 기능을 사용하기 전에 반드시 Code Refine하는 과정이 필요하다. Compile이 정상적으로 진행되었어도 설계에 맞지 않는 문법이나 AUTOSAR 표준 타입을 참조하지 않는 경우 수정 작업을 진행 후 Code Reverse 기능을 사용해야한다.
MISRA rule을 적용한 코드를 Code Reverse 기능을 사용한다.

1. AUTOSAR 표준 타입

  • AUTOSAR_DatatTypes에 정의되어 있는 ImplementationDataTypes를 사용하도록 수정한다.

      bool -> boolean
      unsigned char -> uint8
      unsigned int -> uint16 또는 uint32
      char -> sint8
      int -> sint16 또는 sint32
      float -> float32
      double -> float64
      ...
    

2. MISRA rule

💡

기존 Legacy 코드를 MISRA rule이 적용된 코드로 수정해서 Code Reverse를 진행한다.
MISRA C:2012를 기반으로 작성되었습니다.

1. A standard C environment

Rule 1.1

📖

The program shall contain no violationsof the standard C syntax and
constraints, and shall not exceed the implementation’s tr anslation
limits
프로그램은 C 표준 문법과 제약 조건을 위반해서는 안 되며, 구현체의 변환 한계를 초과해서는 안 된다

CategoryAnalysisApplies to
RequiredDecidable, Single Translation UnitC90, C99

🚧

세미콜론(;) 누락 – 이는 표준 C 문법 위반이며 컴파일 에러를 발생시킴
너무 많은 매크로나 include 사용으로 번역 유닛이 한계를 초과할 수 있음

Rule 1.2

📖

Language extensions should not be used

CategoryAnalysisApplies to
AdvisoryUndecidable, Single Translation UnitC90, C99

Rule 1.3

📖

There shall be no occurrence of undefi ned or critical unspecifi ed
behaviour

CategoryAnalysisApplies to
RequiredUndecidable, SystemC90, C99

2. Unused code

Rule 2.1

📖

A project shall not contain unreachable code

CategoryAnalysisApplies to
RequiredUndecidable, SystemC90, C99