Tool/software: Code Composer Studio
Hello MISRA experts,
I have the following function implemented in one of the firmware libraries. However, I get MISRA 10.1 violation. I can’t understand what I’m doing wrong.
Can someone please help me on this?
int32_t audio_buffer_size = 0; char *audio_buffer = (char *)NULL; int32_t FileIF_CopyFileToBuffer(const char *filename, int32_t offset, char *buffer, int32_t *buf_size, int32_t *file_size); int32_t SDCardIF_PlayAudioFile(const char *filename) { int32_t ret = SDCARD_IF_OP_SUCCESS; int32_t amount_read = audio_buffer_size; int32_t file_size = 0; if(IsNotInitialized()){ ret = SDCARD_IF_ERR_NOT_INITIALIZED; } else if((NULL == audio_buffer) || (0 == audio_buffer_size)){ ret = SDCARD_IF_ERR_AUDIO_BUFFER_NOT_SET; } else{ ret = FileIF_CopyFileToBuffer(filename, 0, audio_buffer, &amount_read, &file_size); // MISRA warning! } return ret; }
MISRA Error:
#1393-D (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 not constant and is a function argument
Thank you!