-4

Essential type of the left hand operand usart[0U].tx_count (unsigned) is not the same as that of the right operand "0" (signed).

if(usart[RS485_PORT].tx_count == 0) // error in this line
phuclv
  • 37,963
  • 15
  • 156
  • 475
  • 1
    what's the type of the variables and fields? Please show a [mcve] – phuclv Sep 21 '21 at 06:29
  • Hi, Your solution works, can you tell me why it works? Thank you! – Sharon Deborah Sep 21 '21 at 06:37
  • 2
    The tool literally tells you what the problem is. As does the MISRA-C document. You cannot use MISRA-C without first studying MISRA-C. If you blindly trust some tool, you are in for disaster. – Lundin Sep 21 '21 at 09:52

1 Answers1

4

0 is a literal of type int which is a signed type, and tx_count is an unsigned field. Comparison between signed and unsigned are usually unexpected

To make the right hand side unsigned add the U suffix

if(usart[RS485_PORT].tx_count == 0U)
phuclv
  • 37,963
  • 15
  • 156
  • 475