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.

MSPM0L1306: How to fix the warnings "DL_I2C_fillTargetTXFIFO()", "memset()"

Part Number: MSPM0L1306

Tool/software:

Hi experts,

When my customer compiled software using mspm0_sdk, he found many warnings.

CCS: v12.8.0
SDK: v2.01.00.03

Q1: If it is possible for the user to fix (remove) these warnings, could you tell me how to do so?
Q2: Also, are there plans to fix these warnings as part of the SDK?


Since this contains customer information, only the error content has been excerpted.

#1
main.c:364:10: warning: passing argument 1 of 'memset' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
	  364 |  memset( s_aEventBuffer, 0U, sizeof( s_aEventBuffer ) );
	      |          ^~~~~~~~~~~~~~

#2
gcc-arm-none-eabi-9-2019-q4-major/arm-none-eabi/include/string.h:33:9: note: expected 'void *' but argument is of type 'volatile SCommonEventData *' {aka 'volatile struct <anonymous> *'}
	   33 | void *  memset (void *, int, size_t);
      |         ^~~~~~

#3
main.c:571:29: warning: cast from function call of type 'uint32_t' {aka 'long unsigned int'} to non-matching type 'double' [-Wbad-function-cast]
	  571 |  byRetVal = (uint8_t) ceil( (double) getVoltage() / VOLTAGE );
      |                             ^

#4
main.c:571:13: warning: cast from function call of type 'double' to non-matching type 'unsigned char' [-Wbad-function-cast]
	  571 |  byRetVal = (uint8_t) ceil( (double) getVoltage() / VOLTAGE );
	      |             ^

#5
I2C.c:57:61: warning: passing argument 2 of 'DL_I2C_fillTargetTXFIFO' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
	   57 |     byFIFOWriteSize = DL_I2C_fillTargetTXFIFO( LPI2C2_INST, &s_pSendData[s_bySendIndex],
	      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~

#6
dl_i2c.h:980:57: note: expected 'uint8_t *' {aka 'unsigned char *'} but argument is of type 'volatile uint8_t *' {aka 'volatile unsigned char *'}
	  980 | uint8_t DL_I2C_fillTargetTXFIFO(I2C_Regs *i2c, uint8_t *buffer, uint8_t count);
	      |                                                ~~~~~~~~~^~~~~~

#7
startup_mspm0l130x_gcc.c:58:6: warning: no previous prototype for 'initStub' [-Wmissing-prototypes]
	   58 | void initStub(void){;}

Best regards,
O.H

  • Hi O.H,

    Most of these warnings are type inconsistency warnings. Do these warning come from example code in SDK? If so I can feedback to our software team.

    By the way it will not lead to a function error, right? 

  • Hi Yuhao Zhao,

    Thank you for your reply.

    Most of these warnings are type inconsistency warnings. Do these warning come from example code in SDK? If so I can feedback to our software team.

    #1~4 are the contents of the customer's own code. However, #5~7 are the parts related to the SDK driver.

    By the way it will not lead to a function error, right? 

    The operation itself is as expected.

    Best regards,
    O.H

  • Hi O.H,

    I try to test the example code 'i2c_target_rw_multibyte_fifo_interrupts_LP_MSPM0L1306_nortos_ticlang', which has the DL_I2C_fillTargetTXFIFO. But there is no warning. Could that be the wrong usage of customer's code?

  • Only #7 is part of the SDK. 

    ---------------

    #2/#6 are advisory; no action is required

    ----------------

    #1/#5 need to be explicitly cast to get rid of the "volatile", to make sure you're conscious that it won't be treated as "volatile" by the function:

    #1 should be coded "memset( (void *)s_aEventBuffer, 0U, sizeof( s_aEventBuffer ) );"

    #5 should be coded "byFIFOWriteSize = DL_I2C_fillTargetTXFIFO( LPI2C2_INST, (uint8_t *)&s_pSendData[s_bySendIndex],"

    ----------------

    #7 should be preceded by a prototype "extern void initStub(void);". I suspect this is an artifact of -pedantic. Perhaps the prior "alias" was supposed to serve as the prototype?

    ----------------

    I'm not sure what's happening with #3/#4 -- maybe something to do with casting between signed and unsigned types. (I don't have my C standard document handy.) I suspect this is an artifact of -pedantic.

  • More on #3/#4: The description of -Wbad-function-cast (here) is a bit thin (what constitutes "matching", given the "usual arithmetic conversions" in C?), but it does seem to apply only to function call results. You may succeed by assigning the intermediate results to local variables and casting them instead. (The optimizer will squash it all back together.) Or add "-Wno-bad-function-cast" to stop checking.

    More on #7: This file is copied from the SDK, but it's in your Project now. I expect you can make the indicated modification to your local copy to get rid of the warning.

  • Hi Yuhao Zhao, Bruce McKenney,

    Thank you for your support. 

    We will share the information you provide with our customers and ask them to try and improve it.

    Best regards,
    O.H