This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCSTUDIO: MISRAC 10.1 false positive?

Part Number: CCSTUDIO
Other Parts Discussed in Thread: HALCOGEN, TMS570LS1227

code:

typedef int sint32;
typedef unsigned char uint8;
typedef unsigned int uint32;

typedef enum{
    JOB_OK,
    JOB_FAILED,
    JOB_PENDING,
    JOB_CANCELLED,
    BLOCK_INCONSISTENT,
    BLOCK_INVALID
}TI_FeeJobResultType;

typedef enum{
	FEE_JobDone,
	FEE_JobBusy,
	FEE_JobFail
}FEE_JobStatus;

TI_FeeJobResultType TI_Fee_GetJobResult(uint8 u8EEPIndex);
TI_FeeJobResultType TI_Fee_GetJobResult(uint8 u8EEPIndex){
	return JOB_OK;
}
FEE_JobStatus FEE_GetJobStatus(void);
FEE_JobStatus FEE_GetJobStatus(void){
	FEE_JobStatus jobStatus;
	TI_FeeJobResultType jobResult=TI_Fee_GetJobResult(0U);
	sint32 j=(jobResult==JOB_OK);
	jobStatus= (j ? FEE_JobDone : FEE_JobFail);//line 29
	return jobStatus;
}

Compile command:

armcl --misra_required=warning --misra_advisory=warning --check_misra="advisory,required" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-arm_15.12.7.LTS/include" -ps a.c

Compiler message:

"a.c", line 29: warning: (MISRA-C:2004 10.1/R) The value of an expression of integer type shall not be implicitly converted to a different underlying type if the expression is complex

  • Hi,

    Is the code you implemented or taken from any package released by TI?

    What is the device the code runs on?

  • The TI_Fee enum and TI_Fee function declaration are from HALCoGen 04.07.01. The other types and functions are user code. Device TMS570LS1227.

    But I don't think the problem is related with device because it's a C language problem. If you add the compiler directory like 'C:\ti\ccsv6\tools\compiler\ti-cgt-arm_15.12.7.LTS\bin' to your Windows PATH, you should be able to run the compile command everywhere.

  • Hi,

    Understood. The software package and/or the device helps me to route your query to the right team. The response from the expert will be posted here soon.

      The Misra C 2004 rule 10.1 is concerned with implicit integer type promotion.

      10.1: The value of an expression of integer type shall not be implicitly converted to a different underlying type if

      A) it is not a conversion to a wider integer type of the same signedness, or

      B) the expression is complex, or

      C) the expression is not constant and is a function argument, or

      D) the expression is not constant and is a return expression.

      If you change line 29 to the following simple statements, the warning will be gone:

      if (j){
             jobStatus = FEE_JobDone;
      }else{
             jobStatus = FEE_JobFail;
      }